You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2011/06/09 12:19:51 UTC

svn commit: r1133772 - in /servicemix/components/trunk/bindings/servicemix-http/src: main/java/org/apache/servicemix/http/endpoints/ test/resources/org/apache/servicemix/http/

Author: ffang
Date: Thu Jun  9 10:19:51 2011
New Revision: 1133772

URL: http://svn.apache.org/viewvc?rev=1133772&view=rev
Log:
[SMXCOMP-886]<http:soap-consumer> config may fail to import xsd or wsdl files

Added:
    servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/SpringWSDLLocator.java
    servicemix/components/trunk/bindings/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC-import.wsdl
Modified:
    servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java
    servicemix/components/trunk/bindings/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC.wsdl

Modified: servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java?rev=1133772&r1=1133771&r2=1133772&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java Thu Jun  9 10:19:51 2011
@@ -175,7 +175,7 @@ public class HttpSoapConsumerEndpoint ex
         description = DomUtil.parse(wsdl.getInputStream());
         javax.wsdl.xml.WSDLReader reader = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLReader();
         reader.setFeature("javax.wsdl.verbose", false);
-        definition = reader.readWSDL(null, description);
+        definition = reader.readWSDL(new SpringWSDLLocator(wsdl));
     }
 
     /**

Added: servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/SpringWSDLLocator.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/SpringWSDLLocator.java?rev=1133772&view=auto
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/SpringWSDLLocator.java (added)
+++ servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/SpringWSDLLocator.java Thu Jun  9 10:19:51 2011
@@ -0,0 +1,84 @@
+package org.apache.servicemix.http.endpoints;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.core.io.Resource;
+import org.xml.sax.InputSource;
+
+public class SpringWSDLLocator implements javax.wsdl.xml.WSDLLocator {
+    
+    private Resource base;
+    private Resource latest;
+    private Map<String, Resource> history;
+    
+    public SpringWSDLLocator(Resource main) {
+        this.base = main;
+        
+        //Init the history.
+        history = new HashMap<String, Resource>();
+        history.put(getBaseURI(), main);
+    }
+    
+
+    @Override
+    public InputSource getBaseInputSource() {
+        try {
+            return new InputSource(base.getInputStream());
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+
+    @Override
+    public InputSource getImportInputSource(String parentLocation, String importLocation) {
+        try {
+            Resource parent = history.get(parentLocation);
+            if (parent != null) {
+                latest = parent.createRelative(importLocation);
+                history.put(getLatestImportURI(), latest);
+                return new InputSource(latest.getInputStream());
+            } else {
+                throw new UnsupportedOperationException();
+            }
+        } catch (UnsupportedOperationException nie) {
+            throw nie;
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+
+    @Override
+    public String getBaseURI() {
+        try {
+            return base.getURI().toString();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+
+    @Override
+    public String getLatestImportURI() {
+        try {
+            if (latest != null) {
+                return latest.getURI().toString();
+            } else {
+                return null;
+            }
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+
+    @Override
+    public void close() {
+        latest = null;
+        history.clear();
+    }
+    
+}

Added: servicemix/components/trunk/bindings/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC-import.wsdl
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC-import.wsdl?rev=1133772&view=auto
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC-import.wsdl (added)
+++ servicemix/components/trunk/bindings/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC-import.wsdl Thu Jun  9 10:19:51 2011
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<!--
+
+    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.
+
+-->
+<definitions name="Hello"
+        targetNamespace="uri:HelloWorld"
+        xmlns:tns="uri:HelloWorld"
+        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+        xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+        xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+    <types>
+        <schema targetNamespace="uri:HelloWorld"
+                xmlns="http://www.w3.org/2000/10/XMLSchema">
+            <element name="HelloRequest">
+                <complexType>
+                    <all>
+                        <element name="text" type="string"/>
+                    </all>
+                </complexType>
+            </element>
+            <element name="HelloResponse">
+                <complexType>
+                    <all>
+                        <element name="text" type="string"/>
+                    </all>
+                </complexType>
+            </element>
+            <element name="HelloHeader">
+                <complexType>
+                    <all>
+                        <element name="id" type="string"/>
+                    </all>
+                </complexType>
+            </element>
+            <element name="HelloFault">
+                <complexType>
+                    <all>
+                        <element name="id" type="string"/>
+                    </all>
+                </complexType>
+            </element>
+        </schema>
+    </types>
+
+    <message name="HelloRequest">
+        <part name="body" element="tns:HelloRequest"/>
+        <part name="header1" element="tns:HelloHeader"/>
+    </message>
+
+    <message name="HelloResponse">
+        <part name="body" element="tns:HelloResponse"/>
+    </message>
+
+    <message name="HelloFault">
+        <part name="body" element="tns:HelloFault"/>
+    </message>
+
+    <portType name="HelloPortType">
+        <operation name="Hello">
+            <input message="tns:HelloRequest"/>
+            <output message="tns:HelloResponse"/>
+            <fault name="fault" message="tns:HelloFault" />
+        </operation>
+    </portType>
+
+</definitions>

Modified: servicemix/components/trunk/bindings/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC.wsdl
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC.wsdl?rev=1133772&r1=1133771&r2=1133772&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC.wsdl (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC.wsdl Thu Jun  9 10:19:51 2011
@@ -24,60 +24,7 @@
         xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
         xmlns="http://schemas.xmlsoap.org/wsdl/">
 
-    <types>
-        <schema targetNamespace="uri:HelloWorld"
-                xmlns="http://www.w3.org/2000/10/XMLSchema">
-            <element name="HelloRequest">
-                <complexType>
-                    <all>
-                        <element name="text" type="string"/>
-                    </all>
-                </complexType>
-            </element>
-            <element name="HelloResponse">
-                <complexType>
-                    <all>
-                        <element name="text" type="string"/>
-                    </all>
-                </complexType>
-            </element>
-            <element name="HelloHeader">
-                <complexType>
-                    <all>
-                        <element name="id" type="string"/>
-                    </all>
-                </complexType>
-            </element>
-            <element name="HelloFault">
-                <complexType>
-                    <all>
-                        <element name="id" type="string"/>
-                    </all>
-                </complexType>
-            </element>
-        </schema>
-    </types>
-
-    <message name="HelloRequest">
-        <part name="body" element="tns:HelloRequest"/>
-        <part name="header1" element="tns:HelloHeader"/>
-    </message>
-
-    <message name="HelloResponse">
-        <part name="body" element="tns:HelloResponse"/>
-    </message>
-
-    <message name="HelloFault">
-        <part name="body" element="tns:HelloFault"/>
-    </message>
-
-    <portType name="HelloPortType">
-        <operation name="Hello">
-            <input message="tns:HelloRequest"/>
-            <output message="tns:HelloResponse"/>
-            <fault name="fault" message="tns:HelloFault" />
-        </operation>
-    </portType>
+    <import location="HelloWorld-DOC-import.wsdl" namespace="uri:HelloWorld" />
 
     <binding name="HelloSoap11Binding" type="tns:HelloPortType">
         <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>