Search in sources :

Example 16 with Binding

use of javax.xml.ws.Binding in project cxf by apache.

the class JMSTestMtom method testMTOM.

@Test
public void testMTOM() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org/jms_mtom", "JMSMTOMService");
    QName portName = new QName("http://cxf.apache.org/jms_mtom", "MTOMPort");
    URL wsdl = getWSDLURL("/wsdl/jms_test_mtom.wsdl");
    JMSMTOMService service = new JMSMTOMService(wsdl, serviceName);
    JMSMTOMPortType mtom = service.getPort(portName, JMSMTOMPortType.class);
    Binding binding = ((BindingProvider) mtom).getBinding();
    ((SOAPBinding) binding).setMTOMEnabled(true);
    Holder<String> name = new Holder<>("Sam");
    URL fileURL = this.getClass().getResource("/org/apache/cxf/systest/jms/JMSClientServerTest.class");
    Holder<DataHandler> handler1 = new Holder<>();
    handler1.value = new DataHandler(fileURL);
    int size = handler1.value.getInputStream().available();
    mtom.testDataHandler(name, handler1);
    byte[] bytes = IOUtils.readBytesFromStream(handler1.value.getInputStream());
    Assert.assertEquals("The response file is not same with the sent file.", size, bytes.length);
    ((Closeable) mtom).close();
}
Also used : Binding(javax.xml.ws.Binding) SOAPBinding(javax.xml.ws.soap.SOAPBinding) QName(javax.xml.namespace.QName) Holder(javax.xml.ws.Holder) Closeable(java.io.Closeable) SOAPBinding(javax.xml.ws.soap.SOAPBinding) JMSMTOMPortType(org.apache.cxf.jms_mtom.JMSMTOMPortType) BindingProvider(javax.xml.ws.BindingProvider) DataHandler(javax.activation.DataHandler) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) JMSMTOMService(org.apache.cxf.jms_mtom.JMSMTOMService) Test(org.junit.Test)

Example 17 with Binding

use of javax.xml.ws.Binding in project Payara by payara.

the class PortCreationCallbackImpl method postCreateProxy.

public void postCreateProxy(WSBindingProvider bp, Class<?> serviceEndpointInterface) {
    ServiceRefPortInfo portInfo = ref.getPortInfoBySEI(serviceEndpointInterface.getName());
    if (portInfo != null) {
        // Set MTOM for this port
        boolean mtomEnabled = false;
        if (portInfo.getMtomEnabled() != null && Boolean.valueOf(portInfo.getMtomEnabled())) {
            mtomEnabled = true;
        }
        if (mtomEnabled) {
            Binding bType = bp.getBinding();
            // enable mtom valid only for SOAPBindings
            if (SOAPBinding.class.isAssignableFrom(bType.getClass())) {
                ((SOAPBinding) bType).setMTOMEnabled(true);
            } else {
                logger.log(Level.SEVERE, LogUtils.INVALID_MTOM, portInfo.getName());
            }
        }
        // Set stub properties
        Set properties = portInfo.getStubProperties();
        for (Iterator iter = properties.iterator(); iter.hasNext(); ) {
            NameValuePairDescriptor next = (NameValuePairDescriptor) iter.next();
            bp.getRequestContext().put(next.getName(), next.getValue());
        }
    }
}
Also used : Binding(javax.xml.ws.Binding) SOAPBinding(javax.xml.ws.soap.SOAPBinding) Set(java.util.Set) NameValuePairDescriptor(com.sun.enterprise.deployment.NameValuePairDescriptor) Iterator(java.util.Iterator) SOAPBinding(javax.xml.ws.soap.SOAPBinding) ServiceRefPortInfo(com.sun.enterprise.deployment.ServiceRefPortInfo)

Example 18 with Binding

use of javax.xml.ws.Binding in project uavstack by uavorg.

the class JaxWSHookIT method createDispatch.

@SuppressWarnings("rawtypes")
public Dispatch createDispatch(Dispatch d, Service s, Object[] args) {
    Binding binding = ((BindingProvider) d).getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(this.handler);
    binding.setHandlerChain(handlerChain);
    final String wsdlLocation = getServiceURL(s);
    Dispatch tProxy = JDKProxyInvokeUtil.newProxyInstance(this.getClass().getClassLoader(), new Class[] { Dispatch.class }, new JDKProxyInvokeHandler<Dispatch>(d, new DispatchProcessor(wsdlLocation.toString(), this.handler)));
    return tProxy;
}
Also used : Binding(javax.xml.ws.Binding) SOAPHandler(javax.xml.ws.handler.soap.SOAPHandler) Handler(javax.xml.ws.handler.Handler) JDKProxyInvokeHandler(com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler) Dispatch(javax.xml.ws.Dispatch) BindingProvider(javax.xml.ws.BindingProvider)

Example 19 with Binding

use of javax.xml.ws.Binding in project nimbus by nimbus-org.

the class WsPortFactoryService method getPort.

public Object getPort(String portAlias) throws PortException {
    String portNameClassName = portAliasProp.getProperty(portAlias);
    String[] names = portNameClassName.split(SEPARATOR);
    if (names.length < 2) {
        return new PortException("port name or endpoint interface name is illegal : " + portNameClassName);
    }
    try {
        Class endpointInterface = Class.forName(names[ENDPOINT_INTERFACE_NAME]);
        QName portQN = new QName(nameSpace, names[PORT_NAME]);
        Object port = wsService.getPort(portQN, endpointInterface);
        if ((handlerList != null && handlerList.size() > 0) && (port instanceof BindingProvider)) {
            BindingProvider bindingProvider = ((BindingProvider) port);
            bindingProvider.getRequestContext().putAll(requestContext);
            Binding binding = bindingProvider.getBinding();
            List list = binding.getHandlerChain();
            for (int i = 0; i < handlerList.size(); i++) {
                Handler handler = (Handler) handlerList.get(i);
                list.add(handler);
            }
            binding.setHandlerChain(list);
        }
        return endpointInterface.cast(port);
    } catch (Exception e) {
        throw new PortException(e);
    }
}
Also used : Binding(javax.xml.ws.Binding) QName(javax.xml.namespace.QName) Handler(javax.xml.ws.handler.Handler) ArrayList(java.util.ArrayList) List(java.util.List) BindingProvider(javax.xml.ws.BindingProvider)

Aggregations

Binding (javax.xml.ws.Binding)19 Handler (javax.xml.ws.handler.Handler)12 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)8 BindingProvider (javax.xml.ws.BindingProvider)8 QName (javax.xml.namespace.QName)7 SOAPHandler (javax.xml.ws.handler.soap.SOAPHandler)7 Set (java.util.Set)6 MessageContext (javax.xml.ws.handler.MessageContext)6 SOAPBinding (javax.xml.ws.soap.SOAPBinding)6 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)6 Exchange (org.apache.cxf.message.Exchange)6 HashSet (java.util.HashSet)5 SOAPMessage (javax.xml.soap.SOAPMessage)5 SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)5 HandlerChainInvoker (org.apache.cxf.jaxws.handler.HandlerChainInvoker)5 MessageImpl (org.apache.cxf.message.MessageImpl)5 IMocksControl (org.easymock.IMocksControl)5 IOException (java.io.IOException)4 SOAPBodyElement (javax.xml.soap.SOAPBodyElement)4