Search in sources :

Example 1 with SOAPServiceBogusAddressTest

use of org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest 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)

Aggregations

BindingProvider (javax.xml.ws.BindingProvider)1 WebServiceException (javax.xml.ws.WebServiceException)1 Greeter (org.apache.hello_world_soap_http.Greeter)1 SOAPServiceBogusAddressTest (org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest)1 SOAPServiceMultiPortTypeTest (org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest)1 Test (org.junit.Test)1