Search in sources :

Example 46 with BindingProvider

use of javax.xml.ws.BindingProvider in project cxf by apache.

the class ClientServerSessionTest method testOnewayInvocationWithSession.

@Test
public void testOnewayInvocationWithSession() throws Exception {
    GreeterService service = new GreeterService();
    assertNotNull(service);
    try {
        Greeter greeter = service.getGreeterPort();
        BindingProvider bp = (BindingProvider) greeter;
        updateAddressPort(bp, PORT);
        bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
        greeter.greetMeOneWay("Bonjour");
        String greeting = greeter.greetMe("Hello");
        if (greeting.indexOf(';') != -1) {
            greeting = greeting.substring(0, greeting.indexOf(';'));
        }
        assertNotNull("no response received from service", greeting);
        assertEquals("Hello Bonjour", greeting);
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : Greeter(org.apache.cxf.greeter_control.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) GreeterService(org.apache.cxf.greeter_control.GreeterService) BindingProvider(javax.xml.ws.BindingProvider) Test(org.junit.Test)

Example 47 with BindingProvider

use of javax.xml.ws.BindingProvider in project cxf by apache.

the class ThreadPoolTest method setUp.

@Before
public void setUp() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    greeter = new SOAPService(wsdl, SERVICE_NAME).getPort(Greeter.class);
    BindingProvider bp = (BindingProvider) greeter;
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS);
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Greeter(org.apache.hello_world_soap_http.Greeter) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Before(org.junit.Before)

Example 48 with BindingProvider

use of javax.xml.ws.BindingProvider in project cxf by apache.

the class HandlerInvocationTest method testAddingUnusedHandlersThroughConfigFile.

@Test
public void testAddingUnusedHandlersThroughConfigFile() {
    HandlerTestServiceWithAnnotation service1 = new HandlerTestServiceWithAnnotation(wsdl, serviceName);
    HandlerTest handlerTest1 = service1.getPort(portName, HandlerTest.class);
    BindingProvider bp1 = (BindingProvider) handlerTest1;
    Binding binding1 = bp1.getBinding();
    @SuppressWarnings("rawtypes") List<Handler> port1HandlerChain = binding1.getHandlerChain();
    assertEquals(1, port1HandlerChain.size());
}
Also used : HandlerTest(org.apache.handler_test.HandlerTest) Binding(javax.xml.ws.Binding) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) HandlerTest(org.apache.handler_test.HandlerTest) Test(org.junit.Test)

Example 49 with BindingProvider

use of javax.xml.ws.BindingProvider in project cxf by apache.

the class ClientServerTest method testBogusAddress.

@Test
public void testBogusAddress() throws Exception {
    String realAddress = "http://localhost:" + BOGUS_REAL_PORT + "/SoapContext/SoapPort";
    SOAPServiceBogusAddressTest service = new SOAPServiceBogusAddressTest();
    Greeter greeter = service.getSoapPort();
    try {
        greeter.greetMe("test");
        fail("Should fail");
    } catch (WebServiceException f) {
    // expected
    }
    BindingProvider bp = (BindingProvider) greeter;
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, realAddress);
    greeter.greetMe("test");
    // should persist
    greeter.greetMe("test");
    bp.getRequestContext().remove(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
    try {
        greeter.greetMe("test");
        fail("Should fail");
    } catch (WebServiceException f) {
    // expected
    }
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, realAddress);
    String reply = greeter.sayHi();
    assertNotNull("no response received from service", reply);
    assertEquals("Bonjour", reply);
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Greeter(org.apache.hello_world_soap_http.Greeter) SOAPServiceBogusAddressTest(org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest) BindingProvider(javax.xml.ws.BindingProvider) SOAPServiceMultiPortTypeTest(org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest) SOAPServiceBogusAddressTest(org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest) Test(org.junit.Test)

Example 50 with BindingProvider

use of javax.xml.ws.BindingProvider in project cxf by apache.

the class ClientServerTest method testFaults.

@Test
public void testFaults() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    SOAPService service = new SOAPService(wsdl, serviceName);
    ExecutorService ex = Executors.newFixedThreadPool(1);
    service.setExecutor(ex);
    assertNotNull(service);
    String noSuchCodeFault = "NoSuchCodeLitFault";
    String badRecordFault = "BadRecordLitFault";
    Greeter greeter = service.getPort(portName, Greeter.class);
    updateAddressPort(greeter, PORT);
    for (int idx = 0; idx < 2; idx++) {
        try {
            greeter.testDocLitFault(noSuchCodeFault);
            fail("Should have thrown NoSuchCodeLitFault exception");
        } catch (NoSuchCodeLitFault nslf) {
            assertNotNull(nslf.getFaultInfo());
            assertNotNull(nslf.getFaultInfo().getCode());
        }
        try {
            greeter.testDocLitFault(badRecordFault);
            fail("Should have thrown BadRecordLitFault exception");
        } catch (BadRecordLitFault brlf) {
            BindingProvider bp = (BindingProvider) greeter;
            Map<String, Object> responseContext = bp.getResponseContext();
            String contentType = (String) responseContext.get(Message.CONTENT_TYPE);
            assertEquals("text/xml;charset=utf-8", stripSpaces(contentType.toLowerCase()));
            Integer responseCode = (Integer) responseContext.get(Message.RESPONSE_CODE);
            assertEquals(500, responseCode.intValue());
            assertNotNull(brlf.getFaultInfo());
            assertEquals("BadRecordLitFault", brlf.getFaultInfo());
        }
    }
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BadRecordLitFault(org.apache.hello_world_soap_http.BadRecordLitFault) NoSuchCodeLitFault(org.apache.hello_world_soap_http.NoSuchCodeLitFault) Greeter(org.apache.hello_world_soap_http.Greeter) ExecutorService(java.util.concurrent.ExecutorService) BindingProvider(javax.xml.ws.BindingProvider) Map(java.util.Map) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) SOAPServiceMultiPortTypeTest(org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest) SOAPServiceBogusAddressTest(org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest) Test(org.junit.Test)

Aggregations

BindingProvider (javax.xml.ws.BindingProvider)147 URL (java.net.URL)87 Test (org.junit.Test)74 Service (javax.xml.ws.Service)65 QName (javax.xml.namespace.QName)41 WebServiceException (javax.xml.ws.WebServiceException)24 Greeter (org.apache.hello_world_soap_http.Greeter)23 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)18 Bus (org.apache.cxf.Bus)17 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)15 InvocationHandler (java.lang.reflect.InvocationHandler)14 SOAPService (org.apache.hello_world_soap_http.SOAPService)14 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)12 STSClient (org.apache.cxf.ws.security.trust.STSClient)11 Greeter (org.apache.cxf.greeter_control.Greeter)10 GreeterService (org.apache.cxf.greeter_control.GreeterService)10 SOAPBinding (javax.xml.ws.soap.SOAPBinding)9 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)9 Client (org.apache.cxf.endpoint.Client)9 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)8