Search in sources :

Example 86 with EndpointReference

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

the class ServiceCreateTest method testServiceCreate.

public void testServiceCreate() throws AxisFault {
    AxisConfiguration axisConfig = configContext.getAxisConfiguration();
    AxisService service = AxisService.createService("org.apache.axis2.engine.MyService", axisConfig);
    assertNotNull(service);
    axisConfig.addService(service);
    assertEquals("MyService", service.getName());
    AxisOperation axisOperation = service.getOperation(new QName("add"));
    assertNotNull(axisOperation);
    AxisMessage messge = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    // messge.getSchemaElement().toString()
    assertNotNull(messge);
    assertNotNull(messge.getSchemaElement());
    assertNotNull(service.getOperation(new QName("putValue")));
    assertNotNull(axisConfig.getService("MyService"));
    RPCServiceClient client = new RPCServiceClient(clinetConfigurationctx, null);
    EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:" + (UtilServer.TESTING_PORT) + "/axis2/services/MyService/add");
    Options options = new Options();
    options.setTo(targetEPR);
    options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
    client.setOptions(options);
    ArrayList args = new ArrayList();
    args.add("100");
    args.add("200");
    OMElement response = client.invokeBlocking(new QName("http://engine.axis2.apache.org", "add", "ns1"), args.toArray());
    assertEquals(Integer.parseInt(response.getFirstElement().getText()), 300);
}
Also used : Options(org.apache.axis2.client.Options) AxisOperation(org.apache.axis2.description.AxisOperation) QName(javax.xml.namespace.QName) AxisService(org.apache.axis2.description.AxisService) RPCServiceClient(org.apache.axis2.rpc.client.RPCServiceClient) ArrayList(java.util.ArrayList) OMElement(org.apache.axiom.om.OMElement) AxisMessage(org.apache.axis2.description.AxisMessage) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 87 with EndpointReference

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

the class ServiceFaultTest method setUp.

protected void setUp() throws Exception {
    service = Utils.createSimpleService(serviceName, FaultThrowingService.class.getName(), operationName);
    UtilServer.deployService(service);
    targetEPR = new EndpointReference("http://127.0.0.1:" + (UtilServer.TESTING_PORT) + // "http://127.0.0.1:5556"
    "/axis2/services/" + serviceName.getLocalPart() + "/" + operationName.getLocalPart());
}
Also used : EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 88 with EndpointReference

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

the class FastInfosetTest method suite.

public static Test suite() {
    return new TestSetup(new TestSuite(FastInfosetTest.class)) {

        public void setUp() throws Exception {
            System.out.println("Setting up the Simple HTTP Server");
            int port = findAvailablePort();
            // Uncomment to test with tcpmon
            port = 5555;
            target = new EndpointReference("http://127.0.0.1:" + (port) + "/axis2/services/SimpleAddService");
            File configFile = new File(System.getProperty("basedir", ".") + "/test-resources/axis2.xml");
            configurationContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-classes", configFile.getAbsolutePath());
            server = new SimpleHTTPServer(configurationContext, port);
            server.start();
            service = AxisService.createService("org.apache.axis2.fastinfoset.SimpleAddService", server.getConfigurationContext().getAxisConfiguration());
            server.getConfigurationContext().getAxisConfiguration().addService(service);
            System.out.println("Simple HTTP Server is started");
        }

        public void tearDown() throws Exception {
            server.stop();
            System.out.println("Stopped the Simple HTTP Server");
        }
    };
}
Also used : TestSetup(junit.extensions.TestSetup) TestSuite(junit.framework.TestSuite) File(java.io.File) SimpleHTTPServer(org.apache.axis2.transport.http.SimpleHTTPServer) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 89 with EndpointReference

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

the class OneWayRawXMLTest method testOneWay.

public void testOneWay() throws Exception {
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(TestingUtils.prefixBaseDirectory(Constants.TESTING_PATH + "integrationRepo/"), null);
    ServiceClient sender = new ServiceClient(configContext, null);
    Options op = new Options();
    // op.setTo(new EndpointReference(
    // //               "http://127.0.0.1:" + (UtilServer.TESTING_PORT)
    // "http://127.0.0.1:" + 5556
    // + "/axis2/services/"+service.getName()+"/"+operationName.getLocalPart()));
    op.setTo(targetEPR);
    op.setAction("urn:SomeAction");
    sender.setOptions(op);
    sender.fireAndForget(TestingUtils.createDummyOMElement());
    int index = 0;
    while (!received) {
        Thread.sleep(1000);
        index++;
        if (index == 20) {
            throw new AxisFault("error Occured");
        }
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Options(org.apache.axis2.client.Options) ServiceClient(org.apache.axis2.client.ServiceClient)

Example 90 with EndpointReference

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

the class MapServiceTest method testStringGenericsTreeMapService.

/**
 * Test string generics tree map service.
 *
 * @throws XMLStreamException
 *             the xML stream exception
 * @throws AxisFault
 *             the axis fault
 */
@Test
public void testStringGenericsTreeMapService() throws XMLStreamException, AxisFault {
    String epr = server.getEndpoint("MapService") + "/stringGenericsTreeMapService";
    Options options = new Options();
    options.setTo(new EndpointReference(epr));
    ServiceClient sender = new ServiceClient();
    sender.setOptions(options);
    OMElement msg = createMessageBody("stringGenericsTreeMapService");
    OMElement ret = sender.sendReceive(msg);
    assertNotNull("Response can not be null", ret);
    assertEquals("Not the expeacted value", "stringGenericsTreeMapServiceResponse", ret.getLocalName());
    assertNotNull("Element can not be null", ret.getFirstElement().getFirstElement());
    assertEquals("Not the expeacted value", msg.getFirstElement().getFirstElement().toString(), ret.getFirstElement().getFirstElement().toString());
}
Also used : Options(org.apache.axis2.client.Options) ServiceClient(org.apache.axis2.client.ServiceClient) OMElement(org.apache.axiom.om.OMElement) EndpointReference(org.apache.axis2.addressing.EndpointReference) Test(org.junit.Test)

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