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();
}
}
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);
}
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());
}
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);
}
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());
}
}
}
Aggregations