Search in sources :

Example 16 with ClientConfig

use of org.jboss.wsf.spi.metadata.config.ClientConfig in project jbossws-cxf by jbossws.

the class Helper method testDefaultClientConfigurationOnDispatch.

public boolean testDefaultClientConfigurationOnDispatch() 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 ClientConfig defaultClientConfig = TestUtils.getAndVerifyDefaultClientConfiguration();
    // -- modify default conf --
    try {
        TestUtils.changeDefaultClientConfiguration();
        // --
        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);
        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|UserOut|LogOut|endpoint|LogIn|UserIn".equals(resStr));
    } finally {
        // -- restore default conf --
        TestUtils.setClientConfigAndReload(defaultClientConfig);
    // --
    }
}
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) ClientConfig(org.jboss.wsf.spi.metadata.config.ClientConfig)

Example 17 with ClientConfig

use of org.jboss.wsf.spi.metadata.config.ClientConfig in project jbossws-cxf by jbossws.

the class TestUtils method addTestCaseClientConfiguration.

public static void addTestCaseClientConfiguration(String testConfigName) {
    UnifiedHandlerMetaData handler = new UnifiedHandlerMetaData("org.jboss.test.ws.jaxws.clientConfig.RoutingHandler", "Routing Handler", null, null, null, null);
    UnifiedHandlerChainMetaData uhcmd = new UnifiedHandlerChainMetaData(null, null, null, Collections.singletonList(handler), false, null);
    List<UnifiedHandlerChainMetaData> preHC = new LinkedList<UnifiedHandlerChainMetaData>();
    preHC.add(uhcmd);
    setClientConfigAndReload(new ClientConfig(testConfigName, preHC, null, null, null));
}
Also used : UnifiedHandlerMetaData(org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData) UnifiedHandlerChainMetaData(org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData) ClientConfig(org.jboss.wsf.spi.metadata.config.ClientConfig) LinkedList(java.util.LinkedList)

Example 18 with ClientConfig

use of org.jboss.wsf.spi.metadata.config.ClientConfig in project jbossws-cxf by jbossws.

the class Helper method testDefaultClientConfiguration.

/**
 * This test hacks the current ServerConfig temporarily adding a property into the AS default client configuration,
 * verifies the handler is picked up and finally restores the original default client configuration.
 *
 * @return
 * @throws Exception
 */
public boolean testDefaultClientConfiguration() throws Exception {
    final URL wsdlURL = new URL(address + "?wsdl");
    final ClientConfig defaultClientConfig = TestUtils.getAndVerifyDefaultClientConfiguration();
    // -- modify default conf --
    try {
        final Map<String, String> props = new HashMap<String, String>();
        props.put("propA", "valueA");
        TestUtils.registerClientConfigAndReload(new ClientConfig(defaultClientConfig.getConfigName(), null, null, props, null));
        // --
        Service service = Service.create(wsdlURL, serviceName);
        Endpoint port = (Endpoint) service.getPort(Endpoint.class);
        return (ClientProxy.getClient(port).getEndpoint().get("propA").equals("valueA"));
    } finally {
        // -- restore default conf --
        TestUtils.registerClientConfigAndReload(defaultClientConfig);
    // --
    }
}
Also used : HashMap(java.util.HashMap) Service(javax.xml.ws.Service) ClientConfig(org.jboss.wsf.spi.metadata.config.ClientConfig) URL(java.net.URL)

Example 19 with ClientConfig

use of org.jboss.wsf.spi.metadata.config.ClientConfig in project jbossws-cxf by jbossws.

the class TestUtils method addTestCaseClientConfiguration.

public static void addTestCaseClientConfiguration(String testConfigName) {
    ClientConfig config = new ClientConfig(testConfigName, null, null, Collections.singletonMap("propT", "valueT"), null);
    registerClientConfigAndReload(config);
}
Also used : ClientConfig(org.jboss.wsf.spi.metadata.config.ClientConfig)

Aggregations

ClientConfig (org.jboss.wsf.spi.metadata.config.ClientConfig)19 Service (javax.xml.ws.Service)7 HashMap (java.util.HashMap)6 UnifiedHandlerChainMetaData (org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData)6 URL (java.net.URL)5 QName (javax.xml.namespace.QName)5 ServerConfig (org.jboss.wsf.spi.management.ServerConfig)5 EndpointConfig (org.jboss.wsf.spi.metadata.config.EndpointConfig)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 BindingProvider (javax.xml.ws.BindingProvider)2 Handler (javax.xml.ws.handler.Handler)2 Bus (org.apache.cxf.Bus)2 Client (org.apache.cxf.endpoint.Client)2 UnifiedHandlerMetaData (org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData)2 LinkedList (java.util.LinkedList)1 SOAPMessage (javax.xml.soap.SOAPMessage)1 Source (javax.xml.transform.Source)1 DOMSource (javax.xml.transform.dom.DOMSource)1 Dispatch (javax.xml.ws.Dispatch)1