Search in sources :

Example 1 with XMLService

use of org.apache.hello_world_xml_http.bare.XMLService in project cxf by apache.

the class ClientServerXMLTest method testAddPort.

@Test
public void testAddPort() throws Exception {
    URL url = getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl");
    Service service = Service.create(url, wrapServiceName);
    assertNotNull(service);
    service.addPort(wrapFakePortName, "http://cxf.apache.org/bindings/xformat", "http://localhost:" + WRAP_PORT + "/XMLService/XMLPort");
    String response1 = new String("Hello ");
    String response2 = new String("Bonjour");
    org.apache.hello_world_xml_http.wrapped.Greeter greeter = service.getPort(wrapPortName, org.apache.hello_world_xml_http.wrapped.Greeter.class);
    updateAddressPort(greeter, WRAP_PORT);
    try {
        String username = System.getProperty("user.name");
        String reply = greeter.greetMe(username);
        assertNotNull("no response received from service", reply);
        assertEquals(response1 + username, reply);
        reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals(response2, reply);
        BindingProvider bp = (BindingProvider) greeter;
        Map<String, Object> responseContext = bp.getResponseContext();
        Integer responseCode = (Integer) responseContext.get(Message.RESPONSE_CODE);
        assertEquals(200, responseCode.intValue());
        greeter.greetMeOneWay(System.getProperty("user.name"));
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) Service(javax.xml.ws.Service) XMLHeaderService(org.apache.headers.XMLHeaderService) XMLService(org.apache.hello_world_xml_http.bare.XMLService) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Test(org.junit.Test)

Example 2 with XMLService

use of org.apache.hello_world_xml_http.bare.XMLService in project cxf by apache.

the class ClientServerXMLTest method testBareBasicConnection.

@Test
public void testBareBasicConnection() throws Exception {
    XMLService service = new XMLService();
    assertNotNull(service);
    String response1 = "Hello ";
    String response2 = "Bonjour";
    try {
        Greeter greeter = service.getPort(barePortName, Greeter.class);
        updateAddressPort(greeter, REG_PORT);
        String username = System.getProperty("user.name");
        String reply = greeter.greetMe(username);
        assertNotNull("no response received from service", reply);
        assertEquals(response1 + username, reply);
        reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals(response2, reply);
        MyComplexStructType argument = new MyComplexStructType();
        MyComplexStructType retVal = null;
        String str1 = "this is element 1";
        String str2 = "this is element 2";
        int int1 = 42;
        argument.setElem1(str1);
        argument.setElem2(str2);
        argument.setElem3(int1);
        retVal = greeter.sendReceiveData(argument);
        assertEquals(str1, retVal.getElem1());
        assertEquals(str2, retVal.getElem2());
        assertEquals(int1, retVal.getElem3());
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : XMLService(org.apache.hello_world_xml_http.bare.XMLService) Greeter(org.apache.hello_world_xml_http.bare.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) MyComplexStructType(org.apache.hello_world_xml_http.bare.types.MyComplexStructType) Test(org.junit.Test)

Aggregations

UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)2 XMLService (org.apache.hello_world_xml_http.bare.XMLService)2 Test (org.junit.Test)2 URL (java.net.URL)1 BindingProvider (javax.xml.ws.BindingProvider)1 Service (javax.xml.ws.Service)1 XMLHeaderService (org.apache.headers.XMLHeaderService)1 Greeter (org.apache.hello_world_xml_http.bare.Greeter)1 MyComplexStructType (org.apache.hello_world_xml_http.bare.types.MyComplexStructType)1