Search in sources :

Example 6 with ClientConfigurer

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

the class Helper method testConfigurationChangeOnDispatch.

public boolean testConfigurationChangeOnDispatch() 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);
    BindingProvider bp = (BindingProvider) dispatch;
    @SuppressWarnings("rawtypes") List<Handler> hc = bp.getBinding().getHandlerChain();
    hc.add(new UserHandler());
    bp.getBinding().setHandlerChain(hc);
    ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
    configurer.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Custom Client Config");
    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));
    if (!"Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr)) {
        return false;
    }
    configurer.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Another Client Config");
    resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
    resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
    resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
    resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
    return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
}
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) ClientConfigurer(org.jboss.ws.api.configuration.ClientConfigurer)

Example 7 with ClientConfigurer

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

the class Helper method testConfigurationChangeOnDispatch.

public boolean testConfigurationChangeOnDispatch() throws Exception {
    Service service = Service.create(new URL(address + "?wsdl"), serviceName);
    Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
    org.apache.cxf.endpoint.Endpoint ep = ((DispatchImpl<SOAPMessage>) dispatch).getClient().getEndpoint();
    assert (ep.get("propA") == null);
    assert (ep.get("propB") == null);
    ep.put("propZ", "valueZ");
    ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
    configurer.setConfigProperties(dispatch, "META-INF/jaxws-client-config.xml", "Custom Client Config");
    if (!ep.get("propA").equals("fileValueA") || !ep.get("propB").equals("fileValueB") || !ep.get("propZ").equals("valueZ")) {
        return false;
    }
    configurer.setConfigProperties(dispatch, "META-INF/jaxws-client-config.xml", "Another Client Config");
    return (ep.get("propA") == null && ep.get("propB") == null && ep.get("propC").equals("fileValueC") && ep.get("propZ").equals("valueZ"));
}
Also used : Service(javax.xml.ws.Service) ClientConfigurer(org.jboss.ws.api.configuration.ClientConfigurer) SOAPMessage(javax.xml.soap.SOAPMessage) URL(java.net.URL)

Example 8 with ClientConfigurer

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

the class Helper method testGZIPUsingFeatureOnClient.

public boolean testGZIPUsingFeatureOnClient() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    try {
        BusFactory.setThreadDefaultBus(bus);
        HelloWorld port = getPort();
        ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
        configurer.setConfigProperties(port, "jaxws-client-config.xml", "Feature Client Config");
        return "foo".equals(port.echo("foo"));
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) ClientConfigurer(org.jboss.ws.api.configuration.ClientConfigurer)

Aggregations

ClientConfigurer (org.jboss.ws.api.configuration.ClientConfigurer)8 Service (javax.xml.ws.Service)6 URL (java.net.URL)5 Bus (org.apache.cxf.Bus)4 QName (javax.xml.namespace.QName)3 BindingProvider (javax.xml.ws.BindingProvider)2 Handler (javax.xml.ws.handler.Handler)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintWriter (java.io.PrintWriter)1 SOAPMessage (javax.xml.soap.SOAPMessage)1 Source (javax.xml.transform.Source)1 DOMSource (javax.xml.transform.dom.DOMSource)1 Client (org.apache.cxf.endpoint.Client)1 LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)1 LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)1 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)1 SimpleService (org.jboss.test.ws.jaxws.samples.wsrm.generated.SimpleService)1 UseThreadBusFeature (org.jboss.wsf.stack.cxf.client.UseThreadBusFeature)1