Search in sources :

Example 1 with ClientConfigFeature

use of org.jboss.ws.api.configuration.ClientConfigFeature 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 2 with ClientConfigFeature

use of org.jboss.ws.api.configuration.ClientConfigFeature in project jbossws-cxf by jbossws.

the class Helper method testCustomClientConfigurationOnDispatchUsingFeature.

public boolean testCustomClientConfigurationOnDispatchUsingFeature() 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, new ClientConfigFeature(null, testConfigName));
        BindingProvider bp = (BindingProvider) dispatch;
        @SuppressWarnings("rawtypes") List<Handler> hc = bp.getBinding().getHandlerChain();
        hc.add(new UserHandler());
        bp.getBinding().setHandlerChain(hc);
        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) 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) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source)

Example 3 with ClientConfigFeature

use of org.jboss.ws.api.configuration.ClientConfigFeature in project jbossws-cxf by jbossws.

the class Helper method testCustomClientConfigurationUsingFeature.

public boolean testCustomClientConfigurationUsingFeature() 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, new ClientConfigFeature(null, testConfigName));
        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");
        return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
    } finally {
        // -- remove test client configuration --
        TestUtils.removeTestCaseClientConfiguration(testConfigName);
    // --
    }
}
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 4 with ClientConfigFeature

use of org.jboss.ws.api.configuration.ClientConfigFeature in project jbossws-cxf by jbossws.

the class Helper method testCustomClientConfigurationFromFileUsingFeatureOnDispatch.

public boolean testCustomClientConfigurationFromFileUsingFeatureOnDispatch() 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");
    Service service = Service.create(wsdlURL, serviceName);
    Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD, new ClientConfigFeature("META-INF/jaxws-client-config.xml", "Custom Client Config"));
    BindingProvider bp = (BindingProvider) dispatch;
    @SuppressWarnings("rawtypes") List<Handler> hc = bp.getBinding().getHandlerChain();
    hc.add(new UserHandler());
    bp.getBinding().setHandlerChain(hc);
    Source 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|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) 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) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source)

Example 5 with ClientConfigFeature

use of org.jboss.ws.api.configuration.ClientConfigFeature in project jbossws-cxf by jbossws.

the class Helper method testCustomClientConfigurationOnDispatchUsingFeature.

public boolean testCustomClientConfigurationOnDispatchUsingFeature() throws Exception {
    final 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<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE, new ClientConfigFeature(null, testConfigName, true));
        org.apache.cxf.endpoint.Endpoint ep = ((DispatchImpl<SOAPMessage>) dispatch).getClient().getEndpoint();
        ep.put("propZ", "valueZ");
        return (ep.get("propT").equals("valueT") && ep.get("propZ").equals("valueZ"));
    } finally {
        // -- remove test client configuration --
        TestUtils.removeTestCaseClientConfiguration(testConfigName);
    // --
    }
}
Also used : ClientConfigFeature(org.jboss.ws.api.configuration.ClientConfigFeature) Service(javax.xml.ws.Service) SOAPMessage(javax.xml.soap.SOAPMessage) URL(java.net.URL)

Aggregations

URL (java.net.URL)8 Service (javax.xml.ws.Service)8 ClientConfigFeature (org.jboss.ws.api.configuration.ClientConfigFeature)8 QName (javax.xml.namespace.QName)4 BindingProvider (javax.xml.ws.BindingProvider)4 Handler (javax.xml.ws.handler.Handler)4 SOAPMessage (javax.xml.soap.SOAPMessage)2 Source (javax.xml.transform.Source)2 DOMSource (javax.xml.transform.dom.DOMSource)2