Search in sources :

Example 31 with Definition

use of javax.wsdl.Definition in project jbossws-cxf by jbossws.

the class JBWS2150TestCase method testRewriteWithPathRuleAndForcedHttps.

/**
 * Test soap:address rewrite when a path rewrite rule is specified and https scheme is forced.
 *
 * @throws Exception
 */
@Test
@RunAsClient
public void testRewriteWithPathRuleAndForcedHttps() throws Exception {
    setModifySOAPAddress(true);
    final String expectedContext = "xx/jaxws-jbws2150";
    final String sedCmd = "s/jaxws-jbws2150/xx\\/jaxws-jbws2150/g";
    setWebServicePathRewriteRule(sedCmd);
    setWebServiceUriScheme("https");
    deployer.deploy(DEP);
    try {
        final String serverHost = getServerHost();
        final int serverPort = getServerPort();
        // 8080 + 363 = 8443
        final int serverSecurePort = serverPort + 363;
        final Map<String, String> wsdlLocationsMap = new HashMap<String, String>();
        final Map<String, String> importMap = new HashMap<String, String>();
        wsdlLocationsMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/ValidURL?wsdl", getWebServiceHost());
        wsdlLocationsMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/InvalidURL?wsdl", getWebServiceHost());
        wsdlLocationsMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/ValidSecureURL?wsdl", getWebServiceHost());
        wsdlLocationsMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/InvalidSecureURL?wsdl", getWebServiceHost());
        importMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/ValidURL?wsdl", "https://" + getWebServiceHost() + ":" + serverSecurePort + "/" + expectedContext + "/ValidURL?wsdl=inner.wsdl");
        importMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/InvalidURL?wsdl", "https://" + getWebServiceHost() + ":" + serverSecurePort + "/" + expectedContext + "/InvalidURL?wsdl=inner.wsdl");
        importMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/ValidSecureURL?wsdl", "https://" + getWebServiceHost() + ":" + serverSecurePort + "/" + expectedContext + "/ValidSecureURL?wsdl=inner.wsdl");
        importMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/InvalidSecureURL?wsdl", "https://" + getWebServiceHost() + ":" + serverSecurePort + "/" + expectedContext + "/InvalidSecureURL?wsdl=inner.wsdl");
        for (Entry<String, String> entry : wsdlLocationsMap.entrySet()) {
            String wsdlLocation = entry.getKey();
            String host = entry.getValue();
            Definition definition = getWSDLDefinition(wsdlLocation);
            String address = getPortAddress(definition, "ValidURLService", "ValidURLPort");
            assertEquals("https://" + host + ":" + serverSecurePort + "/" + expectedContext + "/ValidURL", address);
            address = getPortAddress(definition, "InvalidURLService", "InvalidURLPort");
            assertEquals("https://" + host + ":" + serverSecurePort + "/" + expectedContext + "/InvalidURL", address);
            address = getPortAddress(definition, "ValidSecureURLService", "ValidSecureURLPort");
            assertEquals("https://" + host + ":" + serverSecurePort + "/" + expectedContext + "/ValidSecureURL", address);
            address = getPortAddress(definition, "InvalidSecureURLService", "InvalidSecureURLPort");
            assertEquals("https://" + host + ":" + serverSecurePort + "/" + expectedContext + "/InvalidSecureURL", address);
            // check wsdl import address rewrite (we expect a rewritten version of the same base address used to fetch the wsdl)
            assertEquals(importMap.get(wsdlLocation), getWsdlImportAddress(definition));
        }
    } finally {
        deployer.undeploy(DEP);
    }
}
Also used : HashMap(java.util.HashMap) Definition(javax.wsdl.Definition) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 32 with Definition

use of javax.wsdl.Definition in project jbossws-cxf by jbossws.

the class JBWS2150TestCase method testSecureRewriteLoadBalancer.

/**
 * [JBWS-454] Test soap:address URL rewrite according to transport guarantee
 *
 * @throws Exception
 */
@Test
@RunAsClient
public void testSecureRewriteLoadBalancer() throws Exception {
    setModifySOAPAddress(true);
    final String testWebServiceHost = "myloadbalancer.com";
    setWebServiceHost(testWebServiceHost);
    deployer.deploy(DEP_SEC);
    try {
        final Map<String, String> wsdlLocationsSecMap = new HashMap<String, String>();
        final Map<String, String> importMap = new HashMap<String, String>();
        final String serverHost = getServerHost();
        final int serverPort = getServerPort();
        // 8443 = 8080 + 363
        final int serverSecurePort = serverPort + 363;
        wsdlLocationsSecMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150-sec/ValidURL?wsdl", testWebServiceHost);
        wsdlLocationsSecMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150-sec/InvalidURL?wsdl", testWebServiceHost);
        wsdlLocationsSecMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150-sec/ValidSecureURL?wsdl", testWebServiceHost);
        wsdlLocationsSecMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150-sec/InvalidSecureURL?wsdl", testWebServiceHost);
        importMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150-sec/ValidURL?wsdl", "https://" + testWebServiceHost + ":" + serverSecurePort + "/jaxws-jbws2150-sec/ValidURL?wsdl=inner.wsdl");
        importMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150-sec/InvalidURL?wsdl", "https://" + testWebServiceHost + ":" + serverSecurePort + "/jaxws-jbws2150-sec/InvalidURL?wsdl=inner.wsdl");
        importMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150-sec/ValidSecureURL?wsdl", "https://" + testWebServiceHost + ":" + serverSecurePort + "/jaxws-jbws2150-sec/ValidSecureURL?wsdl=inner.wsdl");
        importMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150-sec/InvalidSecureURL?wsdl", "https://" + testWebServiceHost + ":" + serverSecurePort + "/jaxws-jbws2150-sec/InvalidSecureURL?wsdl=inner.wsdl");
        if (isTestsuiteServerHostLocalhost()) {
            wsdlLocationsSecMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150-sec/ValidURL?wsdl", testWebServiceHost);
            wsdlLocationsSecMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150-sec/InvalidURL?wsdl", testWebServiceHost);
            wsdlLocationsSecMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150-sec/ValidSecureURL?wsdl", testWebServiceHost);
            wsdlLocationsSecMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150-sec/InvalidSecureURL?wsdl", testWebServiceHost);
            importMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150-sec/ValidURL?wsdl", "https://" + testWebServiceHost + ":" + serverSecurePort + "/jaxws-jbws2150-sec/ValidURL?wsdl=inner.wsdl");
            importMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150-sec/InvalidURL?wsdl", "https://" + testWebServiceHost + ":" + serverSecurePort + "/jaxws-jbws2150-sec/InvalidURL?wsdl=inner.wsdl");
            importMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150-sec/ValidSecureURL?wsdl", "https://" + testWebServiceHost + ":" + serverSecurePort + "/jaxws-jbws2150-sec/ValidSecureURL?wsdl=inner.wsdl");
            importMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150-sec/InvalidSecureURL?wsdl", "https://" + testWebServiceHost + ":" + serverSecurePort + "/jaxws-jbws2150-sec/InvalidSecureURL?wsdl=inner.wsdl");
        }
        for (Entry<String, String> entry : wsdlLocationsSecMap.entrySet()) {
            String wsdlLocationSec = entry.getKey();
            String host = entry.getValue();
            Definition definition = getWSDLDefinition(wsdlLocationSec);
            String address = getPortAddress(definition, "ValidURLService", "ValidURLPort");
            assertEquals("https://" + host + ":" + serverSecurePort + "/jaxws-jbws2150-sec/ValidURL", address);
            address = getPortAddress(definition, "InvalidURLService", "InvalidURLPort");
            assertEquals("https://" + host + ":" + serverSecurePort + "/jaxws-jbws2150-sec/InvalidURL", address);
            address = getPortAddress(definition, "ValidSecureURLService", "ValidSecureURLPort");
            assertEquals("https://" + host + ":" + serverSecurePort + "/jaxws-jbws2150-sec/ValidSecureURL", address);
            address = getPortAddress(definition, "InvalidSecureURLService", "InvalidSecureURLPort");
            assertEquals("https://" + host + ":" + serverSecurePort + "/jaxws-jbws2150-sec/InvalidSecureURL", address);
            // check wsdl import address rewrite (we expect a rewritten version of the same base address used to fetch the wsdl)
            assertEquals(importMap.get(wsdlLocationSec), getWsdlImportAddress(definition));
        }
    } finally {
        deployer.undeploy(DEP_SEC);
    }
}
Also used : HashMap(java.util.HashMap) Definition(javax.wsdl.Definition) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 33 with Definition

use of javax.wsdl.Definition in project jbossws-cxf by jbossws.

the class JBWS2150TestCase method testAutoRewriteForceHttp.

/**
 * Test soap:address rewrite with rewrite engine on, the webServiceHost set to jbossws.undefined.host and forced http uri scheme
 *
 * @throws Exception
 */
@Test
@RunAsClient
public void testAutoRewriteForceHttp() throws Exception {
    setModifySOAPAddress(true);
    setWebServiceHost(ServerConfig.UNDEFINED_HOSTNAME);
    deployer.deploy(DEP);
    try {
        final Map<String, String> wsdlLocationsMap = new HashMap<String, String>();
        final Map<String, String> importMap = new HashMap<String, String>();
        final String serverHost = getServerHost();
        final int serverPort = getServerPort();
        wsdlLocationsMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/ValidURL?wsdl", serverHost);
        wsdlLocationsMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/InvalidURL?wsdl", serverHost);
        wsdlLocationsMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/ValidSecureURL?wsdl", serverHost);
        wsdlLocationsMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/InvalidSecureURL?wsdl", serverHost);
        importMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/ValidURL?wsdl", "http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/ValidURL?wsdl=inner.wsdl");
        importMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/InvalidURL?wsdl", "http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/InvalidURL?wsdl=inner.wsdl");
        importMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/ValidSecureURL?wsdl", "http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/ValidSecureURL?wsdl=inner.wsdl");
        importMap.put("http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/InvalidSecureURL?wsdl", "http://" + serverHost + ":" + serverPort + "/jaxws-jbws2150/InvalidSecureURL?wsdl=inner.wsdl");
        if (isTestsuiteServerHostLocalhost()) {
            wsdlLocationsMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150/ValidURL?wsdl", "127.0.0.1");
            wsdlLocationsMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150/InvalidURL?wsdl", "127.0.0.1");
            wsdlLocationsMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150/ValidSecureURL?wsdl", "127.0.0.1");
            wsdlLocationsMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150/InvalidSecureURL?wsdl", "127.0.0.1");
            importMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150/ValidURL?wsdl", "http://127.0.0.1:" + serverPort + "/jaxws-jbws2150/ValidURL?wsdl=inner.wsdl");
            importMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150/InvalidURL?wsdl", "http://127.0.0.1:" + serverPort + "/jaxws-jbws2150/InvalidURL?wsdl=inner.wsdl");
            importMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150/ValidSecureURL?wsdl", "http://127.0.0.1:" + serverPort + "/jaxws-jbws2150/ValidSecureURL?wsdl=inner.wsdl");
            importMap.put("http://127.0.0.1:" + serverPort + "/jaxws-jbws2150/InvalidSecureURL?wsdl", "http://127.0.0.1:" + serverPort + "/jaxws-jbws2150/InvalidSecureURL?wsdl=inner.wsdl");
        }
        for (Entry<String, String> entry : wsdlLocationsMap.entrySet()) {
            String wsdlLocation = entry.getKey();
            String host = entry.getValue();
            Definition definition = getWSDLDefinition(wsdlLocation);
            String address = getPortAddress(definition, "ValidURLService", "ValidURLPort");
            assertEquals("http://" + host + ":" + serverPort + "/jaxws-jbws2150/ValidURL", address);
            address = getPortAddress(definition, "InvalidURLService", "InvalidURLPort");
            assertEquals("http://" + host + ":" + serverPort + "/jaxws-jbws2150/InvalidURL", address);
            address = getPortAddress(definition, "ValidSecureURLService", "ValidSecureURLPort");
            assertEquals("http://" + host + ":" + serverPort + "/jaxws-jbws2150/ValidSecureURL", address);
            address = getPortAddress(definition, "InvalidSecureURLService", "InvalidSecureURLPort");
            assertEquals("http://" + host + ":" + serverPort + "/jaxws-jbws2150/InvalidSecureURL", address);
            assertEquals(importMap.get(wsdlLocation), getWsdlImportAddress(definition));
        }
    } finally {
        deployer.undeploy(DEP);
    }
}
Also used : HashMap(java.util.HashMap) Definition(javax.wsdl.Definition) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 34 with Definition

use of javax.wsdl.Definition in project jbossws-cxf by jbossws.

the class JBWS2183TestCase method testWsdl.

@Test
@RunAsClient
public void testWsdl() throws Exception {
    URL wsdlURL = new URL(baseURL + "/jaxws-jbws2183/TestServiceImpl?wsdl");
    WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
    Definition wsdlDefinition = wsdlReader.readWSDL(wsdlURL.toString());
    assertNotNull(wsdlDefinition);
    for (Iterator<?> it = wsdlDefinition.getAllBindings().values().iterator(); it.hasNext(); ) {
        List<?> extElements = ((Binding) it.next()).getExtensibilityElements();
        boolean found = false;
        for (int i = 0; i < extElements.size(); i++) {
            ExtensibilityElement extElement = (ExtensibilityElement) extElements.get(i);
            if (extElement instanceof SOAP12Binding)
                found = true;
            else if (extElement instanceof SOAPBinding)
                fail("SOAP 1.1 Binding found!");
        }
        assertTrue("SOAP 1.2 Binding not found!", found);
    }
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Definition(javax.wsdl.Definition) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) URL(java.net.URL) WSDLReader(javax.wsdl.xml.WSDLReader) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 35 with Definition

use of javax.wsdl.Definition in project jbossws-cxf by jbossws.

the class JBWS1969TestCase method testSubDirectory.

@Test
@RunAsClient
public void testSubDirectory() throws Exception {
    // WSDL and Schema files are loaded in META-INF/wsdl/echo directory
    URL wsdlURL = new URL(baseURL + "/jaxws-jbws1969?wsdl");
    WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
    Definition wsdlDefinition = wsdlReader.readWSDL(wsdlURL.toString());
    assertNotNull(wsdlDefinition);
}
Also used : Definition(javax.wsdl.Definition) URL(java.net.URL) WSDLReader(javax.wsdl.xml.WSDLReader) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Aggregations

Definition (javax.wsdl.Definition)226 Test (org.junit.Test)113 QName (javax.xml.namespace.QName)61 File (java.io.File)52 Document (org.w3c.dom.Document)44 Element (org.w3c.dom.Element)40 HashMap (java.util.HashMap)36 WSDLReader (javax.wsdl.xml.WSDLReader)35 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)31 JBossWSTest (org.jboss.wsf.test.JBossWSTest)31 Service (javax.wsdl.Service)24 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)23 URL (java.net.URL)21 ArrayList (java.util.ArrayList)21 Port (javax.wsdl.Port)21 WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)21 Bus (org.apache.cxf.Bus)20 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)20 WSDLManager (org.apache.cxf.wsdl.WSDLManager)20 IOException (java.io.IOException)18