Search in sources :

Example 11 with Handler

use of javax.xml.ws.handler.Handler in project jbossws-cxf by jbossws.

the class HandlerChainClient method testService1.

public String testService1(String reqStr) throws Exception {
    PortInfo info = new PortInfo() {

        @Override
        public String getBindingID() {
            return "http://schemas.xmlsoap.org/wsdl/soap/http";
        }

        @Override
        public QName getPortName() {
            return null;
        }

        @Override
        public QName getServiceName() {
            return null;
        }
    };
    HandlerResolver resolver = service1.getHandlerResolver();
    @SuppressWarnings("rawtypes") List<Handler> handlerChain = resolver.getHandlerChain(info);
    if ("[LogHandler, AuthorizationHandler, RoutingHandler, MimeHandler]".equals(handlerChain.toString()) == false)
        throw new IllegalStateException("Unexpected resolver handlers: " + handlerChain);
    Endpoint port = service1.getPort(Endpoint.class);
    return port.echo(reqStr);
}
Also used : PortInfo(javax.xml.ws.handler.PortInfo) HandlerResolver(javax.xml.ws.handler.HandlerResolver) Handler(javax.xml.ws.handler.Handler)

Example 12 with Handler

use of javax.xml.ws.handler.Handler in project jbossws-cxf by jbossws.

the class XOPHandlerTestCase method setup.

@Before
public void setup() throws Exception {
    QName serviceName = new QName("http://doclit.xop.samples.jaxws.ws.test.jboss.org/", "MTOMService");
    URL wsdlURL = new URL(baseURL + "bare?wsdl");
    Service service = Service.create(wsdlURL, serviceName);
    port = service.getPort(MTOMEndpoint.class);
    binding = (SOAPBinding) ((BindingProvider) port).getBinding();
    @SuppressWarnings("rawtypes") List<Handler> handlerChain = new ArrayList<Handler>();
    handlerChain.addAll(binding.getHandlerChain());
    handlerChain.add(new MTOMProtocolHandler());
    binding.setHandlerChain(handlerChain);
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Service(javax.xml.ws.Service) DataHandler(javax.activation.DataHandler) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Before(org.junit.Before)

Example 13 with Handler

use of javax.xml.ws.handler.Handler in project jbossws-cxf by jbossws.

the class Helper method testCustomClientConfigurationFromFile.

public boolean testCustomClientConfigurationFromFile() throws Exception {
    QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
    URL wsdlURL = new URL(address + "?wsdl");
    Service service = Service.create(wsdlURL, serviceName);
    Endpoint port = (Endpoint) service.getPort(Endpoint.class);
    BindingProvider bp = (BindingProvider) port;
    @SuppressWarnings("rawtypes") List<Handler> hc = bp.getBinding().getHandlerChain();
    hc.add(new UserHandler());
    bp.getBinding().setHandlerChain(hc);
    ClientConfigUtil.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Custom Client Config");
    String resStr = port.echo("Kermit");
    resStr = port.echo("Kermit");
    resStr = port.echo("Kermit");
    return ("Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL)

Example 14 with Handler

use of javax.xml.ws.handler.Handler in project jbossws-cxf by jbossws.

the class Helper method testCustomClientConfigurationFromFileUsingFeature.

public boolean testCustomClientConfigurationFromFileUsingFeature() throws Exception {
    QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
    URL wsdlURL = new URL(address + "?wsdl");
    Service service = Service.create(wsdlURL, serviceName);
    Endpoint port = (Endpoint) service.getPort(Endpoint.class, new ClientConfigFeature("META-INF/jaxws-client-config.xml", "Custom Client Config"));
    BindingProvider bp = (BindingProvider) port;
    @SuppressWarnings("rawtypes") List<Handler> hc = bp.getBinding().getHandlerChain();
    hc.add(new UserHandler());
    bp.getBinding().setHandlerChain(hc);
    String resStr = port.echo("Kermit");
    resStr = port.echo("Kermit");
    resStr = port.echo("Kermit");
    if (!"Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr)) {
        return false;
    }
    Endpoint port3 = (Endpoint) service.getPort(Endpoint.class, new ClientConfigFeature("META-INF/jaxws-client-config.xml", null));
    bp = (BindingProvider) port3;
    hc = bp.getBinding().getHandlerChain();
    hc.add(new UserHandler());
    bp.getBinding().setHandlerChain(hc);
    resStr = port3.echo("Kermit");
    resStr = port3.echo("Kermit");
    resStr = port3.echo("Kermit");
    if (!"Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr)) {
        return false;
    }
    Endpoint2 port2 = (Endpoint2) service.getPort(Endpoint2.class, new ClientConfigFeature(null, "My Custom Client Config"));
    bp = (BindingProvider) port2;
    hc = bp.getBinding().getHandlerChain();
    hc.add(new UserHandler());
    bp.getBinding().setHandlerChain(hc);
    resStr = port2.echo("Kermit");
    resStr = port2.echo("Kermit");
    resStr = port2.echo("Kermit");
    return ("Kermit|CustomOut|UserOut|endpoint|UserIn|CustomIn".equals(resStr));
}
Also used : QName(javax.xml.namespace.QName) ClientConfigFeature(org.jboss.ws.api.configuration.ClientConfigFeature) Service(javax.xml.ws.Service) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL)

Example 15 with Handler

use of javax.xml.ws.handler.Handler in project jbossws-cxf by jbossws.

the class Helper method testCustomClientConfigurationOnDispatch.

public boolean testCustomClientConfigurationOnDispatch() throws Exception {
    final String reqString = "<ns1:echo xmlns:ns1=\"http://clientConfig.jaxws.ws.test.jboss.org/\"><arg0>Kermit</arg0></ns1:echo>";
    QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
    QName portName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointPort");
    URL wsdlURL = new URL(address + "?wsdl");
    final String testConfigName = "MyTestConfig";
    try {
        // -- add test client configuration
        TestUtils.addTestCaseClientConfiguration(testConfigName);
        // --
        Service service = Service.create(wsdlURL, serviceName);
        Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
        BindingProvider bp = (BindingProvider) dispatch;
        @SuppressWarnings("rawtypes") List<Handler> hc = bp.getBinding().getHandlerChain();
        hc.add(new UserHandler());
        bp.getBinding().setHandlerChain(hc);
        ClientConfigUtil.setConfigHandlers(bp, null, testConfigName);
        Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
        resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
        resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
        String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
        return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
    } finally {
        // -- remove test client configuration --
        TestUtils.removeTestCaseClientConfiguration(testConfigName);
    // --
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source)

Aggregations

Handler (javax.xml.ws.handler.Handler)100 QName (javax.xml.namespace.QName)47 ArrayList (java.util.ArrayList)46 BindingProvider (javax.xml.ws.BindingProvider)36 URL (java.net.URL)32 Service (javax.xml.ws.Service)29 Test (org.junit.Test)29 LogicalHandler (javax.xml.ws.handler.LogicalHandler)24 Binding (javax.xml.ws.Binding)11 WebServiceException (javax.xml.ws.WebServiceException)11 MessageContext (javax.xml.ws.handler.MessageContext)9 SOAPHandler (javax.xml.ws.handler.soap.SOAPHandler)9 Exchange (org.apache.cxf.message.Exchange)9 IOException (java.io.IOException)8 SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)7 HandlerChainInvoker (org.apache.cxf.jaxws.handler.HandlerChainInvoker)7 DataHandler (javax.activation.DataHandler)6 InitialContext (javax.naming.InitialContext)6 Source (javax.xml.transform.Source)6 DOMSource (javax.xml.transform.dom.DOMSource)6