use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class SOAPAction1Test method testSOAPActionWithDispatch_WithUse_true.
// use is set to true, so action property is effective
public void testSOAPActionWithDispatch_WithUse_true() throws JAXBException {
TestEndpoint1 port = new TestEndpointService1().getTestEndpointPort1();
String address = (String) ((BindingProvider) port).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
Service s = Service.create(new QName("http://client.soapaction_use.server/", "TestEndpointService1"));
s.addPort(new QName("http://client.soapaction_use.server/", "TestEndpointPort1"), SOAPBinding.SOAP11HTTP_BINDING, address);
Dispatch<Object> d = s.createDispatch(new QName("http://client.soapaction_use.server/", "TestEndpointPort1"), JAXBContext.newInstance(ObjectFactory.class), Service.Mode.PAYLOAD);
((BindingProvider) d).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, action);
((BindingProvider) d).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
JAXBElement<String> r = (JAXBElement<String>) d.invoke(new ObjectFactory().createEchoSOAPAction("dummy"));
assertEquals(action, r.getValue());
}
use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class SOAPAction1Test method testSOAPActionWithDispatch_WithoutUse.
// since use property is default (false), action property is ineffective
public void testSOAPActionWithDispatch_WithoutUse() throws JAXBException {
TestEndpoint1 port = new TestEndpointService1().getTestEndpointPort1();
String address = (String) ((BindingProvider) port).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
Service s = Service.create(new QName("http://client.soapaction_use.server/", "TestEndpointService1"));
s.addPort(new QName("http://client.soapaction_use.server/", "TestEndpointPort1"), SOAPBinding.SOAP11HTTP_BINDING, address);
Dispatch<Object> d = s.createDispatch(new QName("http://client.soapaction_use.server/", "TestEndpointPort1"), JAXBContext.newInstance(ObjectFactory.class), Service.Mode.PAYLOAD);
((BindingProvider) d).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, action);
JAXBElement<String> r = (JAXBElement<String>) d.invoke(new ObjectFactory().createEchoSOAPAction("dummy"));
assertEquals(empty_action, r.getValue());
}
use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class Util method addHandler.
// utility methods to be made available to the test clients
/**
* Method used to add a Handler to a stub or dispatch object.
*/
public static void addHandler(Handler handler, Object provider) {
BindingProvider bindingProvider = (BindingProvider) provider;
Binding binding = bindingProvider.getBinding();
List<Handler> handlers = binding.getHandlerChain();
handlers.add(handler);
binding.setHandlerChain(handlers);
}
use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class Util method clearHandlers.
/**
* Method used to clear any handlers from a stub or dispatch object.
*/
public static void clearHandlers(Object provider) {
BindingProvider bindingProvider = (BindingProvider) provider;
Binding binding = bindingProvider.getBinding();
binding.setHandlerChain(new java.util.ArrayList());
}
use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class BindingTest method testSoapBinding1.
/*
* tests for SOAPBinding.
*
*/
public void testSoapBinding1() throws Exception {
TestService_Service service = getService();
TestService stub = getTestStub(service);
Binding binding = ((BindingProvider) stub).getBinding();
if (binding instanceof SOAPBinding) {
SOAPBinding sb = (SOAPBinding) binding;
assertNotNull("did not get SOAPBinding", sb);
Set<String> roles = sb.getRoles();
assertNotNull("roles cannot be null", roles);
assertFalse("found zero roles in SOAPBinding", roles.isEmpty());
assertTrue("soap 1.1 \"next\" role is not included in roles", roles.contains(NEXT_1_1));
assertFalse("soap 1.2 \"none\" role cannot be included in roles", roles.contains(NONE));
// try setting new roles
Set<String> newSet = new HashSet<String>();
String testURI = "http://java.sun.com/justanexample";
newSet.add(testURI);
sb.setRoles(newSet);
try {
newSet.add(NONE);
sb.setRoles(newSet);
throw new RuntimeException("did not get jaxrpc exception for setting \"none\" role");
} catch (WebServiceException e) {
// pass
}
newSet.addAll(roles);
newSet.remove(NONE);
sb.setRoles(newSet);
// add empty set and check for next/ultimate
newSet = new HashSet<String>();
sb.setRoles(newSet);
Set<String> newSet2 = sb.getRoles();
assertTrue("soap 1.1 \"next\" role is not included in roles", newSet2.contains(NEXT_1_1));
assertFalse("soap 1.2 \"none\" role cannot be included in roles", newSet2.contains(NONE));
} else {
throw new Exception("binding is not a SOAPBinding");
}
}
Aggregations