Search in sources :

Example 6 with GreeterRPCLit

use of org.apache.hello_world_rpclit.GreeterRPCLit in project cxf by apache.

the class ProviderRPCClientServerTest method testSOAPMessageModeRPC.

@Test
public void testSOAPMessageModeRPC() throws Exception {
    QName serviceName = new QName("http://apache.org/hello_world_rpclit", "SOAPServiceProviderRPCLit");
    QName portName = new QName("http://apache.org/hello_world_rpclit", "SoapPortProviderRPCLit1");
    URL wsdl = getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl");
    assertNotNull(wsdl);
    SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName);
    assertNotNull(service);
    String response1 = new String("TestGreetMeResponseServerLogicalHandlerServerSOAPHandler");
    String response2 = new String("TestSayHiResponse");
    GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class);
    updateAddressPort(greeter, PORT);
    try {
        String greeting = greeter.greetMe("Milestone-0");
        assertNotNull("no response received from service", greeting);
        assertEquals(response1, greeting);
    } catch (Exception e) {
        e.printStackTrace();
    }
    String reply = greeter.sayHi();
    assertNotNull("no response received from service", reply);
    assertEquals(response2, reply);
}
Also used : SOAPServiceRPCLit(org.apache.hello_world_rpclit.SOAPServiceRPCLit) GreeterRPCLit(org.apache.hello_world_rpclit.GreeterRPCLit) QName(javax.xml.namespace.QName) URL(java.net.URL) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Example 7 with GreeterRPCLit

use of org.apache.hello_world_rpclit.GreeterRPCLit in project cxf by apache.

the class ClientServerRPCLitTest method testComplexType.

@Test
public void testComplexType() throws Exception {
    SOAPServiceRPCLit service = new SOAPServiceRPCLit();
    assertNotNull(service);
    GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class);
    updateAddressPort(greeter, PORT);
    MyComplexStruct in = new MyComplexStruct();
    in.setElem1("elem1");
    in.setElem2("elem2");
    in.setElem3(45);
    try {
        ((BindingProvider) greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
        MyComplexStruct out = greeter.sendReceiveData(in);
        assertNotNull("no response received from service", out);
        assertEquals(in.getElem1(), out.getElem1());
        assertEquals(in.getElem2(), out.getElem2());
        assertEquals(in.getElem3(), out.getElem3());
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
    try {
        in.setElem2("invalid");
        greeter.sendReceiveData(in);
    } catch (SOAPFaultException f) {
        assertTrue(f.getCause() instanceof UnmarshalException);
    }
}
Also used : SOAPServiceRPCLit(org.apache.hello_world_rpclit.SOAPServiceRPCLit) GreeterRPCLit(org.apache.hello_world_rpclit.GreeterRPCLit) UnmarshalException(javax.xml.bind.UnmarshalException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) MyComplexStruct(org.apache.hello_world_rpclit.types.MyComplexStruct) Test(org.junit.Test)

Example 8 with GreeterRPCLit

use of org.apache.hello_world_rpclit.GreeterRPCLit in project cxf by apache.

the class RespectBindingFeatureClientServerTest method testRespectBindingFeatureFalse.

@Test
public void testRespectBindingFeatureFalse() throws Exception {
    startServers("/wsdl_systest/cxf2006.wsdl");
    GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class, new RespectBindingFeature(false));
    updateAddressPort(greeter, PORT);
    assertEquals("Bonjour", greeter.sayHi());
}
Also used : GreeterRPCLit(org.apache.hello_world_rpclit.GreeterRPCLit) RespectBindingFeature(javax.xml.ws.RespectBindingFeature) Test(org.junit.Test)

Example 9 with GreeterRPCLit

use of org.apache.hello_world_rpclit.GreeterRPCLit in project cxf by apache.

the class RespectBindingFeatureClientServerTest method testOperationRespectBindingFeature.

@Test
public void testOperationRespectBindingFeature() throws Exception {
    startServers("/wsdl_systest/cxf_operation_respectbing.wsdl");
    try {
        GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class, new RespectBindingFeature(true));
        updateAddressPort(greeter, PORT);
        greeter.greetMe("hello");
        fail("WebServiceException is expected");
    } catch (Exception ex) {
        assertTrue("WebServiceException is expected", ex instanceof javax.xml.ws.WebServiceException);
        assertTrue("RespectBindingFeature message is expected: " + ex.getMessage(), ex.getMessage().indexOf("extension with required=true attribute") > -1);
    }
}
Also used : GreeterRPCLit(org.apache.hello_world_rpclit.GreeterRPCLit) RespectBindingFeature(javax.xml.ws.RespectBindingFeature) Test(org.junit.Test)

Example 10 with GreeterRPCLit

use of org.apache.hello_world_rpclit.GreeterRPCLit in project cxf by apache.

the class RespectBindingFeatureClientServerTest method testOperationOutputRespectBindingFeature.

@Test
public void testOperationOutputRespectBindingFeature() throws Exception {
    startServers("/wsdl_systest/cxf_operation_output_respectbing.wsdl");
    try {
        GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class, new RespectBindingFeature(true));
        updateAddressPort(greeter, PORT);
        greeter.greetMe("hello");
        fail("WebServiceException is expected");
    } catch (Exception ex) {
        assertTrue("WebServiceException is expected", ex instanceof javax.xml.ws.WebServiceException);
        assertTrue("RespectBindingFeature message is expected: " + ex.getMessage(), ex.getMessage().indexOf("extension with required=true attribute") > -1);
    }
}
Also used : GreeterRPCLit(org.apache.hello_world_rpclit.GreeterRPCLit) RespectBindingFeature(javax.xml.ws.RespectBindingFeature) Test(org.junit.Test)

Aggregations

GreeterRPCLit (org.apache.hello_world_rpclit.GreeterRPCLit)11 Test (org.junit.Test)9 RespectBindingFeature (javax.xml.ws.RespectBindingFeature)5 SOAPServiceRPCLit (org.apache.hello_world_rpclit.SOAPServiceRPCLit)5 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)4 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)4 URL (java.net.URL)3 UnmarshalException (javax.xml.bind.UnmarshalException)2 QName (javax.xml.namespace.QName)2 MyComplexStruct (org.apache.hello_world_rpclit.types.MyComplexStruct)2 File (java.io.File)1 Endpoint (javax.xml.ws.Endpoint)1 WebServiceException (javax.xml.ws.WebServiceException)1 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)1