use of jakarta.xml.ws.soap.SOAPBinding in project metro-jax-ws by eclipse-ee4j.
the class DispatchTest method testMtom.
public void testMtom() throws Exception {
service = new HelloService();
JAXBContext context = createJAXBContext();
Dispatch dispatch = service.createDispatch(portQName, context, Service.Mode.PAYLOAD);
SOAPBinding binding = (SOAPBinding) ((BindingProvider) dispatch).getBinding();
binding.setMTOMEnabled(true);
((BindingProvider) dispatch).getRequestContext().put(JAXWSProperties.MTOM_THRESHOLOD_VALUE, 0);
String name = "Duke";
DetailType detailType = new DetailType();
detailType.setPhoto(name.getBytes());
detailType.setImage(getImage("java.jpg"));
ObjectFactory of = new ObjectFactory();
JAXBElement<DetailType> jaxbe = of.createDetail(detailType);
JAXBElement<DetailType> response = (JAXBElement<DetailType>) dispatch.invoke(jaxbe);
DetailType result = response.getValue();
assertTrue(result != null);
byte[] photo = result.getPhoto();
Image image = result.getImage();
assertTrue(new String(photo).equals(name));
assertTrue(AttachmentHelper.compareImages(getImage("java.jpg"), image));
}
use of jakarta.xml.ws.soap.SOAPBinding in project metro-jax-ws by eclipse-ee4j.
the class BindingTester 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");
}
}
use of jakarta.xml.ws.soap.SOAPBinding in project metro-jax-ws by eclipse-ee4j.
the class BindingTester method testSoapBinding2.
/*
* test the roles of the binding
*/
public void testSoapBinding2() throws Exception {
TestService_Service service = getService();
TestService stub = getTestStub(service);
SOAPBinding binding = (SOAPBinding) ((BindingProvider) stub).getBinding();
Set<String> roles = binding.getRoles();
System.out.println("roles: " + roles);
String uri1 = "http://sun.com/client/role1";
String uri2 = "http://sun.com/client/role2";
assertTrue("test \"role1\" is not included in roles", roles.contains(uri1));
assertTrue("test \"role2\" is not included in roles", roles.contains(uri2));
}
use of jakarta.xml.ws.soap.SOAPBinding in project metro-jax-ws by eclipse-ee4j.
the class ClientTubeAssemblerContext method createHandlerTube.
/**
* Creates a {@link Tube} that invokes protocol and logical handlers.
*/
public Tube createHandlerTube(Tube next) {
HandlerTube cousinHandlerTube = null;
// XML/HTTP Binding can have only LogicalHandlerPipe
if (binding instanceof SOAPBinding) {
// Add MessageHandlerTube
HandlerTube messageHandlerTube = new ClientMessageHandlerTube(seiModel, binding, wsdlModel, next);
next = cousinHandlerTube = messageHandlerTube;
// Add SOAPHandlerTuber
HandlerTube soapHandlerTube = new ClientSOAPHandlerTube(binding, next, cousinHandlerTube);
next = cousinHandlerTube = soapHandlerTube;
}
return new ClientLogicalHandlerTube(binding, seiModel, next, cousinHandlerTube);
}
use of jakarta.xml.ws.soap.SOAPBinding in project metro-jax-ws by eclipse-ee4j.
the class DeploymentDescriptorParser method setHandlersAndRoles.
/**
* Parses the handler and role information and sets it
* on the {@link WSBinding}.
*
* @return true if <handler-chains> element present in DD
* false otherwise.
*/
protected boolean setHandlersAndRoles(WSBinding binding, XMLStreamReader reader, QName serviceName, QName portName) {
if (reader.getEventType() == XMLStreamConstants.END_ELEMENT || !reader.getName().equals(HandlerChainsModel.QNAME_HANDLER_CHAINS)) {
return false;
}
HandlerAnnotationInfo handlerInfo = HandlerChainsModel.parseHandlerFile(reader, classLoader, serviceName, portName, binding);
binding.setHandlerChain(handlerInfo.getHandlers());
if (binding instanceof SOAPBinding) {
((SOAPBinding) binding).setRoles(handlerInfo.getRoles());
}
// move past </handler-chains>
XMLStreamReaderUtil.nextContent(reader);
return true;
}
Aggregations