Search in sources :

Example 26 with SOAPService

use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.

the class ProviderClientServerTest method testSOAPMessageModeDocLit.

@Test
public void testSOAPMessageModeDocLit() throws Exception {
    QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPProviderService");
    QName portName = new QName("http://apache.org/hello_world_soap_http", "SoapProviderPort");
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    SOAPService service = new SOAPService(wsdl, serviceName);
    assertNotNull(service);
    String response1 = new String("TestSOAPOutputPMessage");
    String response2 = new String("Bonjour");
    try {
        Greeter greeter = service.getPort(portName, Greeter.class);
        setAddress(greeter, ADDRESS);
        try {
            greeter.greetMe("Return sayHi");
            fail("Should have thrown an exception");
        } catch (Exception ex) {
            // expected
            assertTrue(ex.getMessage().contains("sayHiResponse"));
        }
        for (int idx = 0; idx < 2; idx++) {
            String greeting = greeter.greetMe("Milestone-" + idx);
            assertNotNull("no response received from service", greeting);
            assertEquals(response1, greeting);
            String reply = greeter.sayHi();
            assertNotNull("no response received from service", reply);
            assertEquals(response2, reply);
        }
        try {
            greeter.greetMe("throwFault");
            fail("Expected a fault");
        } catch (SOAPFaultException ex) {
            assertTrue(ex.getMessage().contains("Test Fault String"));
        }
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) QName(javax.xml.namespace.QName) Greeter(org.apache.hello_world_soap_http.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) URL(java.net.URL) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test)

Example 27 with SOAPService

use of org.apache.hello_world_soap_http.SOAPService 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 28 with SOAPService

use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.

the class WSAFaultToClientServerTest method testOneWayFaultTo.

@Test
public void testOneWayFaultTo() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPServiceAddressing");
    Greeter greeter = new SOAPService(wsdl, serviceName).getPort(Greeter.class, new AddressingFeature());
    EndpointReferenceType faultTo = new EndpointReferenceType();
    AddressingProperties addrProperties = new AddressingProperties();
    AttributedURIType epr = new AttributedURIType();
    String faultToAddress = "http://localhost:" + FaultToEndpointServer.FAULT_PORT + "/faultTo";
    epr.setValue(faultToAddress);
    faultTo.setAddress(epr);
    addrProperties.setFaultTo(faultTo);
    BindingProvider provider = (BindingProvider) greeter;
    Map<String, Object> requestContext = provider.getRequestContext();
    requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + FaultToEndpointServer.PORT + "/jaxws/greeter");
    requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addrProperties);
    greeter.greetMeOneWay("test");
    // wait for the fault request
    int i = 2;
    while (HelloHandler.getFaultRequestPath() == null && i > 0) {
        Thread.sleep(500);
        i--;
    }
    assertTrue("FaultTo request fpath isn't expected", "/faultTo".equals(HelloHandler.getFaultRequestPath()));
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) AddressingFeature(javax.xml.ws.soap.AddressingFeature) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) QName(javax.xml.namespace.QName) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Greeter(org.apache.hello_world_soap_http.Greeter) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) Test(org.junit.Test)

Example 29 with SOAPService

use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.

the class MAPTestBase method createGreeter.

public Greeter createGreeter(EndpointReferenceType target) throws Exception {
    ServiceImpl serviceImpl = ServiceDelegateAccessor.get(new SOAPService(getWSDLURL(), SERVICE_NAME));
    Greeter g = serviceImpl.getPort(target, Greeter.class);
    updateAddressPort(g, getPort());
    return g;
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) Greeter(org.apache.hello_world_soap_http.Greeter)

Example 30 with SOAPService

use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.

the class NoSpringServletClientTest method testBasicConnection.

@Test
public void testBasicConnection() throws Exception {
    SOAPService service = new SOAPService(new URL(serviceURL + "Greeter?wsdl"));
    Greeter greeter = service.getPort(portName, Greeter.class);
    try {
        String reply = greeter.greetMe("test");
        assertNotNull("no response received from service", reply);
        assertEquals("Hello test", reply);
        reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals("Bonjour", reply);
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Greeter(org.apache.hello_world_soap_http.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) URL(java.net.URL) Test(org.junit.Test)

Aggregations

SOAPService (org.apache.hello_world_soap_http.SOAPService)84 URL (java.net.URL)67 Test (org.junit.Test)56 Greeter (org.apache.hello_world_soap_http.Greeter)49 InputStream (java.io.InputStream)20 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)18 SOAPMessage (javax.xml.soap.SOAPMessage)14 Bus (org.apache.cxf.Bus)14 BindingProvider (javax.xml.ws.BindingProvider)13 Endpoint (javax.xml.ws.Endpoint)13 SOAPServiceBogusAddressTest (org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest)13 SOAPServiceMultiPortTypeTest (org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest)13 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)12 TimeoutException (java.util.concurrent.TimeoutException)8 WebServiceException (javax.xml.ws.WebServiceException)8 File (java.io.File)7 ExecutionException (java.util.concurrent.ExecutionException)7 QName (javax.xml.namespace.QName)7 BeforeClass (org.junit.BeforeClass)7 GreetMeLaterResponse (org.apache.hello_world_soap_http.types.GreetMeLaterResponse)6