Search in sources :

Example 6 with SOAPBinding

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));
}
Also used : Dispatch(jakarta.xml.ws.Dispatch) SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) JAXBContext(jakarta.xml.bind.JAXBContext) JAXBElement(jakarta.xml.bind.JAXBElement)

Example 7 with SOAPBinding

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");
    }
}
Also used : SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) Binding(jakarta.xml.ws.Binding) WebServiceException(jakarta.xml.ws.WebServiceException) SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) BindingProvider(jakarta.xml.ws.BindingProvider) WebServiceException(jakarta.xml.ws.WebServiceException) HashSet(java.util.HashSet)

Example 8 with 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));
}
Also used : SOAPBinding(jakarta.xml.ws.soap.SOAPBinding)

Example 9 with SOAPBinding

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);
}
Also used : ClientMessageHandlerTube(com.sun.xml.ws.handler.ClientMessageHandlerTube) HandlerTube(com.sun.xml.ws.handler.HandlerTube) ClientSOAPHandlerTube(com.sun.xml.ws.handler.ClientSOAPHandlerTube) ClientLogicalHandlerTube(com.sun.xml.ws.handler.ClientLogicalHandlerTube) ClientLogicalHandlerTube(com.sun.xml.ws.handler.ClientLogicalHandlerTube) ClientMessageHandlerTube(com.sun.xml.ws.handler.ClientMessageHandlerTube) ClientSOAPHandlerTube(com.sun.xml.ws.handler.ClientSOAPHandlerTube) SOAPBinding(jakarta.xml.ws.soap.SOAPBinding)

Example 10 with SOAPBinding

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 &lt;handler-chains&gt; 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;
}
Also used : HandlerAnnotationInfo(com.sun.xml.ws.util.HandlerAnnotationInfo) SOAPBinding(jakarta.xml.ws.soap.SOAPBinding)

Aggregations

SOAPBinding (jakarta.xml.ws.soap.SOAPBinding)14 WebServiceException (jakarta.xml.ws.WebServiceException)3 ClientTransportException (com.sun.xml.ws.client.ClientTransportException)2 HandlerTube (com.sun.xml.ws.handler.HandlerTube)2 ByteArrayBuffer (com.sun.xml.ws.util.ByteArrayBuffer)2 Binding (jakarta.xml.ws.Binding)2 BindingProvider (jakarta.xml.ws.BindingProvider)2 HashSet (java.util.HashSet)2 NotNull (com.sun.istack.NotNull)1 Packet (com.sun.xml.ws.api.message.Packet)1 ClientLogicalHandlerTube (com.sun.xml.ws.handler.ClientLogicalHandlerTube)1 ClientMessageHandlerTube (com.sun.xml.ws.handler.ClientMessageHandlerTube)1 ClientSOAPHandlerTube (com.sun.xml.ws.handler.ClientSOAPHandlerTube)1 ServerLogicalHandlerTube (com.sun.xml.ws.handler.ServerLogicalHandlerTube)1 ServerMessageHandlerTube (com.sun.xml.ws.handler.ServerMessageHandlerTube)1 ServerSOAPHandlerTube (com.sun.xml.ws.handler.ServerSOAPHandlerTube)1 Headers (com.sun.xml.ws.transport.Headers)1 HandlerAnnotationInfo (com.sun.xml.ws.util.HandlerAnnotationInfo)1 HandlerTracker (fromwsdl.handler.common.HandlerTracker)1 HandlerTracker (handler.handler_processing.common.HandlerTracker)1