Search in sources :

Example 71 with Handler

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

the class Helper method testCustomClientConfiguration.

/**
 * This test hacks the current ServerConfig temporarily adding a test client configuration, uses that
 * for the test client and finally removes it from the ServerConfig.
 *
 * @return
 * @throws Exception
 */
public boolean testCustomClientConfiguration() throws Exception {
    QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
    URL wsdlURL = new URL(address + "?wsdl");
    final String testConfigName = "MyTestConfig";
    try {
        // -- add test client configuration
        TestUtils.addTestCaseClientConfiguration(testConfigName);
        // --
        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, null, testConfigName);
        String resStr = port.echo("Kermit");
        resStr = port.echo("Kermit");
        resStr = port.echo("Kermit");
        return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
    } finally {
        // -- remove test client configuration --
        TestUtils.removeTestCaseClientConfiguration(testConfigName);
    // --
    }
}
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 72 with Handler

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

the class JBWS1283TestCase method testAttachmentResponse.

@Test
@RunAsClient
public void testAttachmentResponse() throws Exception {
    QName serviceName = new QName("http://org.jboss.test.ws/jbws1283", "JBWS1283Service");
    URL wsdlURL = new URL(baseURL + "/jaxws-jbws1283/JBWS1283Service/JBWS1283EndpointImpl?wsdl");
    Service service = Service.create(wsdlURL, serviceName);
    JBWS1283Endpoint port = service.getPort(JBWS1283Endpoint.class);
    // Add a client-side handler that verifes existence of the attachment
    BindingProvider bindingProvider = (BindingProvider) port;
    @SuppressWarnings("rawtypes") List<Handler> handlerChain = new ArrayList<Handler>();
    handlerChain.add(new VerifyAttachmentHandler());
    bindingProvider.getBinding().setHandlerChain(handlerChain);
    port.requestAttachmentData();
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Service(javax.xml.ws.Service) GenericSOAPHandler(org.jboss.ws.api.handler.GenericSOAPHandler) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 73 with Handler

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

the class JBWS2419TestCase method testSOAP11ClientAccess.

@Test
@RunAsClient
public void testSOAP11ClientAccess() throws Exception {
    URL wsdlURL = new URL(baseURL + "/soap11?wsdl");
    QName qname = new QName("http://org.jboss.ws/jaxws/jbws2419", "SOAP11EndpointBeanService");
    Service service = Service.create(wsdlURL, qname);
    SOAP11Endpoint port = service.getPort(SOAP11Endpoint.class);
    BindingProvider provider = (BindingProvider) port;
    @SuppressWarnings("rawtypes") List<Handler> handlerChain = new ArrayList<Handler>();
    handlerChain.addAll(provider.getBinding().getHandlerChain());
    handlerChain.add(new SOAP11ClientHandler());
    provider.getBinding().setHandlerChain(handlerChain);
    ((SOAPBinding) provider.getBinding()).setMTOMEnabled(true);
    DataHandler response = port.namespace(new DataHandler("Jimbo", "text/plain"));
    Object messg = getContent(response);
    assertEquals("Hello Jimbo", messg);
}
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) SOAPBinding(javax.xml.ws.soap.SOAPBinding) BindingProvider(javax.xml.ws.BindingProvider) DataHandler(javax.activation.DataHandler) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 74 with Handler

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

the class JBWS2419TestCase method testSOAP12ClientAccess.

@Test
@RunAsClient
public void testSOAP12ClientAccess() throws Exception {
    URL wsdlURL = new URL(baseURL + "/soap12?wsdl");
    QName qname = new QName("http://org.jboss.ws/jaxws/jbws2419", "SOAP12EndpointBeanService");
    Service service = Service.create(wsdlURL, qname);
    SOAP12Endpoint port = service.getPort(SOAP12Endpoint.class);
    BindingProvider provider = (BindingProvider) port;
    @SuppressWarnings("rawtypes") List<Handler> handlerChain = new ArrayList<Handler>();
    handlerChain.addAll(provider.getBinding().getHandlerChain());
    handlerChain.add(new SOAP12ClientHandler());
    provider.getBinding().setHandlerChain(handlerChain);
    ((SOAPBinding) provider.getBinding()).setMTOMEnabled(true);
    DataHandler response = port.namespace(new DataHandler("Jimbo", "text/plain"));
    Object messg = getContent(response);
    assertEquals("Hello Jimbo", messg);
}
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) SOAPBinding(javax.xml.ws.soap.SOAPBinding) BindingProvider(javax.xml.ws.BindingProvider) DataHandler(javax.activation.DataHandler) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 75 with Handler

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

the class HandlerChainTestCase method testDynamicHandlerChain.

@Test
@RunAsClient
public void testDynamicHandlerChain() throws Exception {
    QName serviceName = new QName(targetNS, "EndpointImplService");
    URL wsdlURL = new URL(baseURL + "/TestService?wsdl");
    Service service = Service.create(wsdlURL, serviceName);
    Endpoint port = service.getPort(Endpoint.class);
    BindingProvider bindingProvider = (BindingProvider) port;
    @SuppressWarnings("rawtypes") List<Handler> handlerChain = new ArrayList<Handler>();
    handlerChain.add(new LogHandler());
    handlerChain.add(new AuthorizationHandler());
    handlerChain.add(new RoutingHandler());
    handlerChain.add(new ClientMimeHandler());
    bindingProvider.getBinding().setHandlerChain(handlerChain);
    String resStr = port.echo("Kermit");
    assertEquals("Kermit|LogOut|AuthOut|RoutOut|RoutIn|AuthIn|LogIn|endpoint|LogOut|AuthOut|RoutOut|RoutIn|AuthIn|LogIn", resStr);
    assertCookies();
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Service(javax.xml.ws.Service) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

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