use of javax.xml.ws.BindingProvider in project cxf by apache.
the class ClientServerXMLTest method testAddPort.
@Test
public void testAddPort() throws Exception {
URL url = getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl");
Service service = Service.create(url, wrapServiceName);
assertNotNull(service);
service.addPort(wrapFakePortName, "http://cxf.apache.org/bindings/xformat", "http://localhost:" + WRAP_PORT + "/XMLService/XMLPort");
String response1 = new String("Hello ");
String response2 = new String("Bonjour");
org.apache.hello_world_xml_http.wrapped.Greeter greeter = service.getPort(wrapPortName, org.apache.hello_world_xml_http.wrapped.Greeter.class);
updateAddressPort(greeter, WRAP_PORT);
try {
String username = System.getProperty("user.name");
String reply = greeter.greetMe(username);
assertNotNull("no response received from service", reply);
assertEquals(response1 + username, reply);
reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response2, reply);
BindingProvider bp = (BindingProvider) greeter;
Map<String, Object> responseContext = bp.getResponseContext();
Integer responseCode = (Integer) responseContext.get(Message.RESPONSE_CODE);
assertEquals(200, responseCode.intValue());
greeter.greetMeOneWay(System.getProperty("user.name"));
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
}
use of javax.xml.ws.BindingProvider in project cxf by apache.
the class MultiplexHttpAddressClientServerTest method testWithManualMultiplexEprCreation.
@Test
public void testWithManualMultiplexEprCreation() throws Exception {
Service numService = Service.create(NumberFactoryImpl.NUMBER_SERVICE_QNAME);
Number num = numService.getPort(Number.class);
InvocationHandler handler = Proxy.getInvocationHandler(num);
BindingProvider bp = (BindingProvider) handler;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, NUMBER_SERVANT_ADDRESS_ROOT + "103");
IsEvenResponse numResp = num.isEven();
assertTrue("103 is not even", Boolean.FALSE.equals(numResp.isEven()));
}
use of javax.xml.ws.BindingProvider in project cxf by apache.
the class IntFaultClientServerTest method testBasicConnection.
@Test
public void testBasicConnection() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world_fault.wsdl");
assertNotNull("WSDL is null", wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull("Service is null", service);
Greeter greeter = service.getSoapPort();
ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor());
ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor());
updateAddressPort(greeter, PORT);
try {
greeter.testDocLitFault("fault");
} catch (BadRecordLitFault e) {
assertEquals(5, e.getFaultInfo());
assertSoapHeader((BindingProvider) greeter);
}
}
use of javax.xml.ws.BindingProvider in project cxf by apache.
the class ClientMtomXopWithJMSTest method createPort.
private static <T> T createPort(QName serviceName, QName portName, Class<T> serviceEndpointInterface, boolean enableMTOM) throws Exception {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setBus(bus);
factory.setServiceName(serviceName);
factory.setServiceClass(serviceEndpointInterface);
factory.setWsdlURL(ClientMtomXopTest.class.getResource("/wsdl/mtom_xop.wsdl").toExternalForm());
factory.setFeatures(Collections.singletonList(cff));
factory.getInInterceptors().add(new TestMultipartMessageInterceptor());
factory.getOutInterceptors().add(new TestAttachmentOutInterceptor());
@SuppressWarnings("unchecked") T proxy = (T) factory.create();
BindingProvider bp = (BindingProvider) proxy;
SOAPBinding binding = (SOAPBinding) bp.getBinding();
binding.setMTOMEnabled(true);
return proxy;
}
use of javax.xml.ws.BindingProvider in project cxf by apache.
the class PolicyHandlerFaultResponseTest method testFaultResponse.
@Test
public void testFaultResponse() throws Exception {
String address = "http://localhost:" + PORT + "/policytest";
URL wsdlURL = new URL(address + "?wsdl");
Service service = Service.create(wsdlURL, serviceName);
service.addPort(new QName("http://handler.policy.ws.systest.cxf.apache.org/", "HelloPolicyServicePort"), SOAPBinding.SOAP11HTTP_BINDING, address);
HelloService port = service.getPort(new QName("http://handler.policy.ws.systest.cxf.apache.org/", "HelloPolicyServicePort"), HelloService.class);
Map<String, Object> context = ((BindingProvider) port).getRequestContext();
context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
context.put(SecurityConstants.CALLBACK_HANDLER, new CommonPasswordCallback());
context.put(SecurityConstants.SIGNATURE_PROPERTIES, "alice.properties");
context.put(SecurityConstants.SIGNATURE_USERNAME, "alice");
try {
port.checkHello("input");
fail("Exception is expected");
} catch (MyFault e) {
assertEquals("Fault is not expected", "myMessage", e.getMessage());
}
}
Aggregations