Author: ema
Date: Wed Jul 11 02:29:20 2007
New Revision: 555225
URL: http://svn.apache.org/viewvc?view=rev&rev=555225
Log:
[CXF-778]Fixed issue in WSDLServiceBuilder :given wsdl contains recursive
import will cause infinite loop
Added:
incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf778/
incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf778/hello_world_recursive.wsdl
incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf778/hello_world_recursive_import.wsdl
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java?view=diff&rev=555225&r1=555224&r2=555225
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java
Wed Jul 11 02:29:20 2007
@@ -91,6 +91,7 @@
wsdlReader = wsdlFactory.newWSDLReader();
// TODO enable the verbose if in verbose mode.
wsdlReader.setFeature("javax.wsdl.verbose", false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments", true);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -144,8 +145,10 @@
private void parseImports(Definition def) {
for (Import impt : getImports(def)) {
- parseImports(impt.getDefinition());
- importedDefinitions.add(impt.getDefinition());
+ if (!importedDefinitions.contains(impt.getDefinition())) {
+ importedDefinitions.add(impt.getDefinition());
+ parseImports(impt.getDefinition());
+ }
}
}
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?view=diff&rev=555225&r1=555224&r2=555225
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
Wed Jul 11 02:29:20 2007
@@ -231,7 +231,13 @@
for (Port port : cast(serv.getPorts().values(), Port.class)) {
Binding binding = port.getBinding();
- PortType pt = binding.getPortType();
+ PortType bindingPt = binding.getPortType();
+ //TODO: wsdl4j's bug. if there is recursive import,
+ //wsdl4j can not get operation input message
+ PortType pt = def.getPortType(bindingPt.getQName());
+ if (pt == null) {
+ pt = bindingPt;
+ }
ServiceInfo service = services.get(pt.getQName());
if (service == null) {
service = new ServiceInfo();
@@ -289,8 +295,10 @@
importList.addAll(list);
}
for (Import impt : importList) {
- parseImports(impt.getDefinition(), defList);
- defList.add(impt.getDefinition());
+ if (!defList.contains(impt.getDefinition())) {
+ defList.add(impt.getDefinition());
+ parseImports(impt.getDefinition(), defList);
+ }
}
}
@@ -375,6 +383,9 @@
for (SchemaImport schemaImport : schemaImports) {
Schema tempImport = schemaImport.getReferencedSchema();
+ if (importNamespace == null) {
+ importNamespace = tempImport.getDocumentBaseURI();
+ }
if (tempImport != null
&& !isSchemaParsed(tempImport.getDocumentBaseURI(),
importNamespace)
&& !schemaList.containsValue(tempImport.getElement()))
{
Modified:
incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java?view=diff&rev=555225&r1=555224&r2=555225
==============================================================================
---
incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
(original)
+++
incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
Wed Jul 11 02:29:20 2007
@@ -197,6 +197,10 @@
if (!isExist(wsdlDocs, vNode)) {
FailureLocation loc = getFailureLocation(wsdlDocs,
vNode.getFailurePoint());
+ if (loc == null) {
+ System.out.println("---vNode--- " + vNode);
+ }
+
vResults.addError(new Message("FAILED_AT_POINT",
LOG,
loc.getLocation().getLineNumber(),
Modified:
incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?view=diff&rev=555225&r1=555224&r2=555225
==============================================================================
---
incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
(original)
+++
incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Wed Jul 11 02:29:20 2007
@@ -556,4 +556,12 @@
file = new File(output,
"org/apache/hello_world_soap_http/Greeter_GreeterPort_Server.java");
assertTrue("Greeter_GreeterPort_Server is not found", file.exists());
}
+
+ @Test
+ public void testRecursiveImport() throws Exception {
+ env.put(ToolConstants.CFG_WSDLURL,
getLocation("/wsdl2java_wsdl/cxf778/hello_world_recursive.wsdl"));
+ processor.setContext(env);
+ processor.execute();
+ assertNotNull("Process message with no part wsdl error", output);
+ }
}
Added:
incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf778/hello_world_recursive.wsdl
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf778/hello_world_recursive.wsdl?view=auto&rev=555225
==============================================================================
---
incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf778/hello_world_recursive.wsdl
(added)
+++
incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf778/hello_world_recursive.wsdl
Wed Jul 11 02:29:20 2007
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://apache.org/hello_world_soap_http"
+ xmlns:import="http://apache.org/hello_world_soap_http/import"
+ xmlns:x1="http://apache.org/hello_world_soap_http/types"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://apache.org/hello_world_soap_http"
name="HelloWorld">
+ <wsdl:import namespace="http://apache.org/hello_world_soap_http/import"
location="hello_world_recursive_import.wsdl"/>
+ <wsdl:types>
+ <schema
targetNamespace="http://apache.org/hello_world_soap_http/types"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:x1="http://apache.org/hello_world_soap_http/types"
elementFormDefault="qualified">
+ <element name="sayHi">
+ <complexType/>
+ </element>
+ <element name="sayHiResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMe">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeSometime">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeSometimeResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeOneWay">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testDocLitFault">
+ <complexType>
+ <sequence>
+ <element name="faultType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testDocLitFaultResponse">
+ <complexType>
+ <sequence/>
+ </complexType>
+ </element>
+ <complexType name="ErrorCode">
+ <sequence>
+ <element name="minor" type="short"/>
+ <element name="major" type="short"/>
+ </sequence>
+ </complexType>
+ <element name="NoSuchCodeLit">
+ <complexType>
+ <sequence>
+ <element name="code" type="x1:ErrorCode"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="BadRecordLit" type="string"/>
+ <complexType name="BadRecord">
+ <sequence>
+ <element name="reason" type="string"/>
+ <element name="code" type="short"/>
+ </sequence>
+ </complexType>
+ <complexType name="addNumbers">
+ <sequence>
+ <element name="arg0" type="int"/>
+ <element name="arg1" type="int"/>
+ </sequence>
+ </complexType>
+ <element name="addNumbers" type="x1:addNumbers"/>
+ <complexType name="addNumbersResponse">
+ <sequence>
+ <element name="return" type="int"/>
+ </sequence>
+ </complexType>
+ <element name="addNumbersResponse" type="x1:addNumbersResponse"/>
+ <element name="BareDocument" type="string"/>
+ <element name="BareDocumentResponse">
+ <complexType>
+ <sequence>
+ <element name="company" type="string"/>
+ </sequence>
+ <attribute name="id" type="int"/>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+ <wsdl:message name="sayHiRequest">
+ <wsdl:part name="in" element="x1:sayHi"/>
+ </wsdl:message>
+ <wsdl:message name="sayHiResponse">
+ <wsdl:part name="out" element="x1:sayHiResponse"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeRequest">
+ <wsdl:part name="in" element="x1:greetMe"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeResponse">
+ <wsdl:part name="out" element="x1:greetMeResponse"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeSometimeRequest">
+ <wsdl:part name="in" element="x1:greetMeSometime"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeSometimeResponse">
+ <wsdl:part name="out" element="x1:greetMeSometimeResponse"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeOneWayRequest">
+ <wsdl:part name="in" element="x1:greetMeOneWay"/>
+ </wsdl:message>
+ <wsdl:message name="testDocLitFaultRequest">
+ <wsdl:part name="in" element="x1:testDocLitFault"/>
+ </wsdl:message>
+ <wsdl:message name="testDocLitFaultResponse">
+ <wsdl:part name="out" element="x1:testDocLitFaultResponse"/>
+ </wsdl:message>
+ <wsdl:message name="NoSuchCodeLitFault">
+ <wsdl:part name="NoSuchCodeLit" element="x1:NoSuchCodeLit"/>
+ </wsdl:message>
+ <wsdl:message name="BadRecordLitFault">
+ <wsdl:part name="BadRecordLit" element="x1:BadRecordLit"/>
+ </wsdl:message>
+ <wsdl:message name="testDocLitBareRequest">
+ <wsdl:part name="in" element="x1:BareDocument"/>
+ </wsdl:message>
+ <wsdl:message name="testDocLitBareResponse">
+ <wsdl:part name="out" element="x1:BareDocumentResponse"/>
+ </wsdl:message>
+ <wsdl:portType name="Greeter">
+ <wsdl:operation name="sayHi">
+ <wsdl:input name="sayHiRequest" message="tns:sayHiRequest"/>
+ <wsdl:output name="sayHiResponse" message="tns:sayHiResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="greetMe">
+ <wsdl:input name="greetMeRequest" message="tns:greetMeRequest"/>
+ <wsdl:output name="greetMeResponse" message="tns:greetMeResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="greetMeSometime">
+ <wsdl:input name="greetMeSometimeRequest"
message="tns:greetMeSometimeRequest"/>
+ <wsdl:output name="greetMeSometimeResponse"
message="tns:greetMeSometimeResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="greetMeOneWay">
+ <wsdl:input name="greetMeOneWayRequest"
message="tns:greetMeOneWayRequest"/>
+ </wsdl:operation>
+ <wsdl:operation name="testDocLitFault">
+ <wsdl:input name="testDocLitFaultRequest"
message="tns:testDocLitFaultRequest"/>
+ <wsdl:output name="testDocLitFaultResponse"
message="tns:testDocLitFaultResponse"/>
+ <wsdl:fault name="NoSuchCodeLitFault"
message="tns:NoSuchCodeLitFault"/>
+ <wsdl:fault name="BadRecordLitFault"
message="tns:BadRecordLitFault"/>
+ </wsdl:operation>
+ <wsdl:operation name="testDocLitBare">
+ <wsdl:input name="testDocLitBareRequest"
message="tns:testDocLitBareRequest"/>
+ <wsdl:output name="testDocLitBareResponse"
message="tns:testDocLitBareResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:service name="SOAPService">
+ <wsdl:port name="SoapPort" binding="import:Greeter_SOAPBinding">
+ <soap:address
location="http://localhost:9000/SoapContext/SoapPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
+
Added:
incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf778/hello_world_recursive_import.wsdl
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf778/hello_world_recursive_import.wsdl?view=auto&rev=555225
==============================================================================
---
incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf778/hello_world_recursive_import.wsdl
(added)
+++
incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf778/hello_world_recursive_import.wsdl
Wed Jul 11 02:29:20 2007
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://apache.org/hello_world_soap_http/import"
+ xmlns:x0="http://apache.org/hello_world_soap_http"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ targetNamespace="http://apache.org/hello_world_soap_http/import"
name="HelloWorldImport">
+
+ <wsdl:import namespace="http://apache.org/hello_world_soap_http"
location="hello_world_recursive.wsdl"/>
+
+ <wsdl:binding name="Greeter_SOAPBinding" type="x0:Greeter">
+ <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="sayHi">
+ <soap:operation style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="greetMe">
+ <soap:operation style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="greetMeSometime">
+ <soap:operation style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="greetMeOneWay">
+ <soap:operation style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+ <wsdl:operation name="testDocLitFault">
+ <soap:operation style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="NoSuchCodeLitFault">
+ <soap:fault name="NoSuchCodeLitFault" use="literal"/>
+ </wsdl:fault>
+ <wsdl:fault name="BadRecordLitFault">
+ <soap:fault name="BadRecordLitFault" use="literal"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ <wsdl:operation name="testDocLitBare">
+ <soap:operation style="document"
soapAction="http://apache.org/hello_world_soap_http/testDocLitBare"/>
+ <wsdl:input name="testDocLitBareRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="testDocLitBareResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+</wsdl:definitions>
+