You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2008/12/01 09:31:24 UTC

svn commit: r721997 - in /servicemix/components/bindings/servicemix-http/trunk/src: main/java/org/apache/servicemix/http/processors/ test/java/org/apache/servicemix/http/ test/resources/org/apache/servicemix/http/wsdl/ test/resources/org/apache/service...

Author: gnodet
Date: Mon Dec  1 00:31:23 2008
New Revision: 721997

URL: http://svn.apache.org/viewvc?rev=721997&view=rev
Log:
SM-1036: SoapEndpoint loadWsdl() does not support importing from relative paths

Added:
    servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpEndpointLoadWsdlTest.java
    servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/
    servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/
    servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/Requests.xsd
    servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/Responses.xsd
    servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/subschema/
    servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/subschema/SubSchema.xsd
    servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/
    servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/DataType.xsd
    servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/Fault.xsd
    servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/TestEnum.xsd
    servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/relative.wsdl
Modified:
    servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java

Modified: servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java?rev=721997&r1=721996&r2=721997&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java Mon Dec  1 00:31:23 2008
@@ -277,8 +277,8 @@
             return;
         }
         String path = request.getPathInfo();
-        if (path.lastIndexOf('/') >= 0) {
-            path = path.substring(path.lastIndexOf('/') + 1);
+        if (path.charAt(0) == '/') {
+            path = path.substring(1);
         }
 
         // Set protocol, host, and port in the component

Added: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpEndpointLoadWsdlTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpEndpointLoadWsdlTest.java?rev=721997&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpEndpointLoadWsdlTest.java (added)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpEndpointLoadWsdlTest.java Mon Dec  1 00:31:23 2008
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.http;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.common.DefaultServiceUnit;
+import org.springframework.core.io.ClassPathResource;
+
+public class HttpEndpointLoadWsdlTest extends TestCase {
+
+    /*
+     * Test method for 'org.apache.servicemix.soap.SoapEndpoint.loadWsdl()'
+     */
+    public void testLoadWsdl() throws Exception {
+        MyHttpEndpoint endpoint = new MyHttpEndpoint();
+        endpoint.setWsdlResource(new ClassPathResource("org/apache/servicemix/http/wsdl/relative.wsdl"));
+        endpoint.setTargetEndpoint("TestPort");
+        endpoint.setTargetService(new QName("http://test.namespace/wsdl", "TestService"));
+        endpoint.setLocationURI("http://0.0.0.0:1234/services/service1/");
+        endpoint.setSoap(true);
+        endpoint.setService(new QName("http://test.namespace/wsdl", "Service"));
+
+        endpoint.loadWsdl();
+
+        assertFalse(endpoint.getWsdls().isEmpty());
+
+        assertEquals(7, endpoint.getWsdls().size());
+        assertTrue(endpoint.getWsdls().containsKey("Service1/Requests.xsd"));
+        assertTrue(endpoint.getWsdls().containsKey("Service1/subschema/SubSchema.xsd"));
+        assertTrue(endpoint.getWsdls().containsKey("common/DataType.xsd"));
+        assertTrue(endpoint.getWsdls().containsKey("common/TestEnum.xsd"));
+        assertTrue(endpoint.getWsdls().containsKey("Service1/Responses.xsd"));
+        assertTrue(endpoint.getWsdls().containsKey("common/Fault.xsd"));
+        assertTrue(endpoint.getWsdls().containsKey("main.wsdl"));
+    }
+
+    public class MyHttpEndpoint extends HttpEndpoint {
+        public MyHttpEndpoint() {
+            super();
+            setServiceUnit(new MyServiceUnit());
+        }
+        // make the protected method public so I can call it.
+        public void loadWsdl() {
+            logger = LogFactory.getLog(getClass());
+            super.loadWsdl();
+        }
+        // this needs to work:
+        // getServiceUnit().getComponent().getLifeCycle().getConfiguration().isManaged()
+    }
+
+    public class MyServiceUnit extends DefaultServiceUnit {
+        public MyServiceUnit() {
+            super(new HttpComponent());
+        }
+    }
+}

Added: servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/Requests.xsd
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/Requests.xsd?rev=721997&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/Requests.xsd (added)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/Requests.xsd Mon Dec  1 00:31:23 2008
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsd:schema elementFormDefault="qualified" targetNamespace="http://test.namespace/schemas/service1"
+	xmlns="http://test.namespace/schemas/service1" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:test="http://test.namespace/schemas/subschema">
+
+	<xsd:import namespace="http://test.namespace/schemas/subschema"
+		schemaLocation="subschema/SubSchema.xsd"/>
+
+	<xsd:element name="Request1" type="Request1Type"/>
+	<xsd:element name="Request2" type="test:Request2Type"/>
+	
+	<xsd:complexType name="Request1Type">
+		<xsd:sequence>
+			<xsd:element name="element1" type="xsd:integer" maxOccurs="1" minOccurs="1"/>
+		</xsd:sequence>
+	</xsd:complexType>
+
+</xsd:schema>

Added: servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/Responses.xsd
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/Responses.xsd?rev=721997&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/Responses.xsd (added)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/Responses.xsd Mon Dec  1 00:31:23 2008
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsd:schema elementFormDefault="qualified"
+	targetNamespace="http://test.namespace/schemas/service1"
+	xmlns="http://test.namespace/schemas/service1"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+	<xsd:element name="Response1" type="Response1Type"/>
+	<xsd:element name="Response2">
+		<xsd:complexType>
+			<xsd:sequence>
+				<xsd:element name="element1" type="xsd:integer" minOccurs="1" maxOccurs="1"/>
+				<xsd:element name="element2" type="xsd:string" minOccurs="0" maxOccurs="3"/>
+			</xsd:sequence>
+		</xsd:complexType>
+	</xsd:element>
+
+	<xsd:complexType name="Response1Type">
+		<xsd:sequence>
+			<xsd:element name="succeeded" type="xsd:boolean" maxOccurs="1" minOccurs="1"/>
+		</xsd:sequence>
+	</xsd:complexType>
+</xsd:schema>

Added: servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/subschema/SubSchema.xsd
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/subschema/SubSchema.xsd?rev=721997&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/subschema/SubSchema.xsd (added)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/Service1/subschema/SubSchema.xsd Mon Dec  1 00:31:23 2008
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsd:schema elementFormDefault="qualified" targetNamespace="http://test.namespace/schemas/subschema"
+	xmlns="http://test.namespace/schemas/subschema"
+	xmlns:common="http://test.namespace/schemas/common" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+	<xsd:import namespace="http://test.namespace/schemas/common"
+		schemaLocation="../../common/DataType.xsd"/>
+
+	<xsd:complexType name="Request2Type">
+		<xsd:all>
+			<xsd:element maxOccurs="1" minOccurs="1" name="element1" type="common:Char7"/>
+			<xsd:element maxOccurs="1" minOccurs="0" name="element2" type="common:TestEnum"/>
+		</xsd:all>
+	</xsd:complexType>
+</xsd:schema>

Added: servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/DataType.xsd
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/DataType.xsd?rev=721997&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/DataType.xsd (added)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/DataType.xsd Mon Dec  1 00:31:23 2008
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsd:schema elementFormDefault="qualified"
+	targetNamespace="http://test.namespace/schemas/common"
+	xmlns="http://test.namespace/schemas/common"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+	<xsd:include schemaLocation="./TestEnum.xsd"/>
+
+	<xsd:simpleType name="Char7">
+		<xsd:restriction base="xsd:string">
+			<xsd:maxLength value="7"/>
+		</xsd:restriction>
+	</xsd:simpleType>
+</xsd:schema>

Added: servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/Fault.xsd
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/Fault.xsd?rev=721997&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/Fault.xsd (added)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/Fault.xsd Mon Dec  1 00:31:23 2008
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	targetNamespace="http://test.namespace/schemas/fault"
+	xmlns:tns="http://test.namespace/schemas/fault"
+	xmlns:common="http://test.namespace/schemas/common" elementFormDefault="qualified">
+
+	<xs:import namespace="http://test.namespace/schemas/common"
+		schemaLocation="../common/DataType.xsd"/>
+
+	<xs:element name="TestFault" type="tns:TestFaultType"/>
+
+	<xs:complexType name="TestFaultType" final="extension">
+		<xs:sequence>
+			<xs:element name="faultCode" type="common:Char7" maxOccurs="1" minOccurs="1"/>
+			<xs:element name="faultMessage" type="xs:string" maxOccurs="1" minOccurs="1"/>
+			<xs:element name="faultDetail" type="xs:anyType" maxOccurs="1" minOccurs="0"/>
+		</xs:sequence>
+	</xs:complexType>
+</xs:schema>

Added: servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/TestEnum.xsd
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/TestEnum.xsd?rev=721997&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/TestEnum.xsd (added)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/common/TestEnum.xsd Mon Dec  1 00:31:23 2008
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsd:schema elementFormDefault="qualified" targetNamespace="http://test.namespace/schemas/common"
+	xmlns="http://test.namespace/schemas/common" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+	<xsd:simpleType name="TestEnum">
+		<xsd:restriction base="xsd:string">
+			<xsd:enumeration value="A"/>
+			<xsd:enumeration value="B"/>
+			<xsd:enumeration value="C"/>
+			<xsd:enumeration value="Z"/>
+		</xsd:restriction>
+	</xsd:simpleType>
+</xsd:schema>

Added: servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/relative.wsdl
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/relative.wsdl?rev=721997&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/relative.wsdl (added)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/resources/org/apache/servicemix/http/wsdl/relative.wsdl Mon Dec  1 00:31:23 2008
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions targetNamespace="http://test.namespace/wsdl"
+	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:tns="http://test.namespace/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+	xmlns:fault="http://test.namespace/schemas/fault">
+	<wsdl:types>
+		<xsd:schema targetNamespace="http://test.namespace/schemas/service1">
+			<xsd:include schemaLocation="Service1/Requests.xsd"/>
+			<xsd:include schemaLocation="Service1/Responses.xsd"/>
+		</xsd:schema>
+		<xsd:schema targetNamespace="http://test.namespace/schemas/fault">
+			<xsd:include schemaLocation="common/Fault.xsd"/>
+		</xsd:schema>
+	</wsdl:types>
+	<wsdl:message xmlns:s1="http://test.namespace/schemas/service1" name="Request1Message">
+		<wsdl:part name="body" element="s1:Request1"/>
+	</wsdl:message>
+	<wsdl:message xmlns:s1="http://test.namespace/schemas/service1" name="Response1Message">
+		<wsdl:part name="body" element="s1:Response1"/>
+	</wsdl:message>
+	<wsdl:message xmlns:s1="http://test.namespace/schemas/service1" name="Request2Message">
+		<wsdl:part name="body" element="s1:Request2"/>
+	</wsdl:message>
+	<wsdl:message xmlns:s1="http://test.namespace/schemas/service1" name="Response2Message">
+		<wsdl:part name="body" element="s1:Response2"/>
+	</wsdl:message>
+	<wsdl:message name="FaultMessage">
+		<wsdl:part name="body" element="fault:TestFault"/>
+	</wsdl:message>
+	<wsdl:portType name="TestPortType">
+		<wsdl:operation name="Request1">
+			<wsdl:input message="tns:Request1Message"/>
+			<wsdl:output message="tns:Response1Message"/>
+			<wsdl:fault message="tns:FaultMessage" name="TestFault"/>
+		</wsdl:operation>
+		<wsdl:operation name="Request2">
+			<wsdl:input message="tns:Request2Message"/>
+			<wsdl:output message="tns:Response2Message"/>
+			<wsdl:fault message="tns:FaultMessage" name="TestFault"/>
+		</wsdl:operation>
+	</wsdl:portType>
+	<wsdl:binding name="TestBinding" type="tns:TestPortType">
+		<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+		<wsdl:operation name="Request1">
+			<soap:operation soapAction="http://test.namespace/services/service1"/>
+			<wsdl:input>
+				<soap:body use="literal"/>
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal"/>
+			</wsdl:output>
+			<wsdl:fault name="TestFault">
+				<soap:body use="literal"/>
+			</wsdl:fault>
+		</wsdl:operation>
+		<wsdl:operation name="Request2">
+			<soap:operation soapAction="http://test.namespace/services/service2"/>
+			<wsdl:input>
+				<soap:body use="literal"/>
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal"/>
+			</wsdl:output>
+			<wsdl:fault name="TestFault">
+				<soap:body use="literal"/>
+			</wsdl:fault>
+		</wsdl:operation>
+	</wsdl:binding>
+	<wsdl:service name="TestService">
+		<wsdl:port name="TestPort" binding="tns:TestBinding">
+			<soap:address location="http://localhost:1234/services/service1"/>
+		</wsdl:port>
+	</wsdl:service>
+</wsdl:definitions>