Search in sources :

Example 81 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class EngineWithoutPhaseResolvingTest method testServerReceive.

public void testServerReceive() throws Exception {
    mc.setTo(new EndpointReference("axis2/services/NullService"));
    mc.setServerSide(true);
    AxisEngine.receive(mc);
}
Also used : EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 82 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class EnumTest method testEnumPojo.

public void testEnumPojo() throws Exception {
    QName opEnumPojo = new QName("http://engine.axis2.apache.org", "enumPojo", "asix");
    Event event = new Event();
    event.setEventDesc("Event Description");
    event.setEventName("Event Name");
    event.setStartingDay(EnumService.Day.FRIDAY);
    // Constructing the arguments array for the method invocation
    Object[] opAddEventArgs = new Object[] { event };
    // Invoking the method
    RPCServiceClient serviceClient = getRPCClient();
    Options options = serviceClient.getOptions();
    EndpointReference targetEPR = new EndpointReference("local://services/EnumService");
    options.setTo(targetEPR);
    options.setAction("enumPojo");
    Class[] returnTypes = new Class[] { Event.class };
    Object[] ret = serviceClient.invokeBlocking(opEnumPojo, opAddEventArgs, returnTypes);
    // assertEquals(event, ret[0]);
    Event res = (Event) ret[0];
    assertEquals(event.getEventDesc(), res.getEventDesc());
    assertEquals(event.getEventName(), res.getEventName());
    assertEquals(event.getStartingDay(), res.getStartingDay());
}
Also used : Options(org.apache.axis2.client.Options) QName(javax.xml.namespace.QName) RPCServiceClient(org.apache.axis2.rpc.client.RPCServiceClient) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 83 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class OptionsSaveTest method testSaveAndRestore.

public void testSaveAndRestore() throws Exception {
    File theFile = null;
    String theFilename = null;
    boolean saved = false;
    boolean restored = false;
    boolean done = false;
    boolean comparesOk = false;
    AxisConfiguration axisConfiguration = new AxisConfiguration();
    ConfigurationContext configurationContext = new ConfigurationContext(axisConfiguration);
    log.debug("OptionsSaveTest:testSaveAndRestore():  BEGIN ---------------");
    // ---------------------------------------------------------
    // setup an options object to use
    // ---------------------------------------------------------
    Options options = new Options();
    options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
    options.setExceptionToBeThrownOnSOAPFault(true);
    options.setTimeOutInMilliSeconds(5000L);
    options.setUseSeparateListener(false);
    options.setAction("SoapAction");
    options.setFaultTo(new EndpointReference("http://ws.apache.org/axis2/faultTo"));
    options.setFrom(new EndpointReference("http://ws.apache.org/axis2/from"));
    options.setTo(new EndpointReference("http://ws.apache.org/axis2/to"));
    options.setReplyTo(new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL));
    TransportOutDescription transportOut = new TransportOutDescription("null");
    TransportOutDescription transportOut2 = new TransportOutDescription("happy");
    TransportOutDescription transportOut3 = new TransportOutDescription("golucky");
    transportOut.setSender(new HTTPClient4TransportSender());
    transportOut2.setSender(new HTTPClient4TransportSender());
    transportOut3.setSender(new HTTPClient4TransportSender());
    options.setTransportOut(transportOut);
    axisConfiguration.addTransportOut(transportOut3);
    axisConfiguration.addTransportOut(transportOut2);
    axisConfiguration.addTransportOut(transportOut);
    TransportInDescription transportIn = new TransportInDescription("null");
    TransportInDescription transportIn2 = new TransportInDescription("always");
    TransportInDescription transportIn3 = new TransportInDescription("thebest");
    transportIn.setReceiver(new SimpleHTTPServer());
    transportIn2.setReceiver(new SimpleHTTPServer());
    transportIn3.setReceiver(new SimpleHTTPServer());
    options.setTransportIn(transportIn);
    axisConfiguration.addTransportIn(transportIn2);
    axisConfiguration.addTransportIn(transportIn);
    axisConfiguration.addTransportIn(transportIn3);
    options.setMessageId("msgId012345");
    options.setProperty("key01", "value01");
    options.setProperty("key02", "value02");
    options.setProperty("key03", "value03");
    options.setProperty("key04", "value04");
    options.setProperty("key05", "value05");
    options.setProperty("key06", "value06");
    options.setProperty("key07", "value07");
    options.setProperty("key08", "value08");
    options.setProperty("key09", "value09");
    options.setProperty("key10", "value10");
    // ---------------------------------------------------------
    try {
        theFile = File.createTempFile("optionsSave", null);
        theFilename = theFile.getName();
        log.debug("OptionsSaveTest:testSaveAndRestore(): temp file = [" + theFilename + "]");
    } catch (Exception ex) {
        log.debug("OptionsSaveTest:testSaveAndRestore(): error creating temp file = [" + ex.getMessage() + "]");
        theFile = null;
    }
    if (theFile != null) {
        // ---------------------------------------------------------
        try {
            // setup an output stream to a physical file
            FileOutputStream outStream = new FileOutputStream(theFile);
            // attach a stream capable of writing objects to the
            // stream connected to the file
            ObjectOutputStream outObjStream = new ObjectOutputStream(outStream);
            // try to save the message context
            log.debug("OptionsSaveTest:testSaveAndRestore(): saving .....");
            saved = false;
            outObjStream.writeObject(options);
            // close out the streams
            outObjStream.flush();
            outObjStream.close();
            outStream.flush();
            outStream.close();
            saved = true;
            log.debug("OptionsSaveTest:testSaveAndRestore(): ....save operation completed.....");
            long filesize = theFile.length();
            log.debug("OptionsSaveTest:testSaveAndRestore(): file size after save [" + filesize + "]   temp file = [" + theFilename + "]");
        } catch (Exception ex2) {
            if (saved != true) {
                log.debug("OptionsSaveTest:testSaveAndRestore(): error during save [" + ex2.getClass().getName() + " : " + ex2.getMessage() + "]");
                ex2.printStackTrace();
            } else {
                log.debug("OptionsSaveTest:testSaveAndRestore(): error during restore [" + ex2.getClass().getName() + " : " + ex2.getMessage() + "]");
                ex2.printStackTrace();
            }
        }
        assertTrue(saved);
        // ---------------------------------------------------------
        try {
            // setup an input stream to the file
            FileInputStream inStream = new FileInputStream(theFile);
            // attach a stream capable of reading objects from the
            // stream connected to the file
            ObjectInputStream inObjStream = new ObjectInputStream(inStream);
            // try to restore the options
            log.debug("OptionsSaveTest:testSaveAndRestore(): restoring .....");
            restored = false;
            Options options_restored = (Options) inObjStream.readObject();
            inObjStream.close();
            inStream.close();
            options_restored.activate(configurationContext);
            restored = true;
            log.debug("OptionsSaveTest:testSaveAndRestore(): ....restored operation completed.....");
            comparesOk = options_restored.isEquivalent(options);
            log.debug("OptionsSaveTest:testSaveAndRestore():   Options equivalency [" + comparesOk + "]");
        } catch (Exception ex2) {
            log.debug("OptionsSaveTest:testSaveAndRestore(): error during restore [" + ex2.getClass().getName() + " : " + ex2.getMessage() + "]");
            ex2.printStackTrace();
        }
        assertTrue(restored);
        assertTrue(comparesOk);
        // if the save/restore of the object succeeded,
        // then don't keep the temporary file around
        boolean removeTmpFile = saved && restored && comparesOk;
        if (removeTmpFile) {
            try {
                theFile.delete();
            } catch (Exception e) {
            // just absorb it
            }
        }
        // indicate that the temp file was created ok
        done = true;
    }
    // this is false when there are problems with the temporary file
    assertTrue(done);
    log.debug("OptionsSaveTest:testSaveAndRestore():  END ---------------");
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Options(org.apache.axis2.client.Options) TransportInDescription(org.apache.axis2.description.TransportInDescription) ObjectOutputStream(java.io.ObjectOutputStream) SimpleHTTPServer(org.apache.axis2.transport.http.SimpleHTTPServer) FileInputStream(java.io.FileInputStream) EndpointReference(org.apache.axis2.addressing.EndpointReference) HTTPClient4TransportSender(org.apache.axis2.transport.http.impl.httpclient4.HTTPClient4TransportSender) FileOutputStream(java.io.FileOutputStream) File(java.io.File) TransportOutDescription(org.apache.axis2.description.TransportOutDescription) ObjectInputStream(java.io.ObjectInputStream)

Example 84 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class PausingHandlerExecutionTest method createClient.

private ServiceClient createClient() throws Exception {
    Options options = new Options();
    options.setTo(new EndpointReference("http://127.0.0.1:" + server.getPort() + "/axis2/services/EchoXMLService/echoOMElement"));
    options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
    options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
    options.setAction(operationName.getLocalPart());
    options.setUseSeparateListener(true);
    options.setTimeOutInMilliSeconds(50000);
    ConfigurationContext configContext = UtilServer.createClientConfigurationContext();
    ServiceClient sender = new ServiceClient(configContext, null);
    sender.setOptions(options);
    sender.engageModule("addressing");
    return sender;
}
Also used : Options(org.apache.axis2.client.Options) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) ServiceClient(org.apache.axis2.client.ServiceClient) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 85 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class ServiceClientTest method testFireAndForget.

public void testFireAndForget() throws Exception {
    EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:" + (UtilServer.TESTING_PORT) + // "http://127.0.0.1:" + 5556
    "/axis2/services/Echo/echoOMElementNoResponse");
    OMElement payload = createDummyOMElement();
    Options options = new Options();
    options.setTo(targetEPR);
    options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
    options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
    options.setAction("urn:echoOMElementNoResponse");
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
    ServiceClient sender = new ServiceClient(configContext, null);
    sender.setOptions(options);
    sender.fireAndForget(payload);
    Thread.sleep(100);
    String value = System.getProperty("echoOMElementNoResponse");
    System.setProperty("echoOMElementNoResponse", "");
    assertEquals(value, "echoOMElementNoResponse");
}
Also used : Options(org.apache.axis2.client.Options) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) ServiceClient(org.apache.axis2.client.ServiceClient) OMElement(org.apache.axiom.om.OMElement) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Aggregations

EndpointReference (org.apache.axis2.addressing.EndpointReference)261 Options (org.apache.axis2.client.Options)99 OMElement (org.apache.axiom.om.OMElement)67 AxisFault (org.apache.axis2.AxisFault)66 MessageContext (org.apache.axis2.context.MessageContext)58 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)57 ServiceClient (org.apache.axis2.client.ServiceClient)54 QName (javax.xml.namespace.QName)40 ArrayList (java.util.ArrayList)37 AxisService (org.apache.axis2.description.AxisService)28 Map (java.util.Map)25 MessageContext (org.apache.synapse.MessageContext)25 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)25 Test (org.junit.Test)20 IOException (java.io.IOException)19 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)18 RelatesTo (org.apache.axis2.addressing.RelatesTo)18 URL (java.net.URL)17 SOAPFactory (org.apache.axiom.soap.SOAPFactory)17 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)17