Author: jim.ma
Date: 2011-10-27 03:29:53 -0400 (Thu, 27 Oct 2011)
New Revision: 15170
Added:
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf2193/
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf2193/hello_world_extension_wrapped.wsdl
Modified:
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
Log:
[JBPAPP-7441]:Allow for WRAPPED style code generation for elements with xsd:extension
Modified:
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java 2011-10-27
06:17:57 UTC (rev 15169)
+++
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java 2011-10-27
07:29:53 UTC (rev 15170)
@@ -83,6 +83,7 @@
import org.apache.ws.commons.schema.XmlSchemaObject;
import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaType;
import static org.apache.cxf.helpers.CastUtils.cast;
@@ -740,56 +741,76 @@
MessageInfo wrapper, boolean allowRefs) {
if (type.getParticle() instanceof XmlSchemaSequence) {
XmlSchemaSequence seq = (XmlSchemaSequence)type.getParticle();
- XmlSchemaObjectCollection items = seq.getItems();
- boolean ret = true;
- for (int x = 0; x < items.getCount(); x++) {
- XmlSchemaObject o = items.getItem(x);
- if (!(o instanceof XmlSchemaElement)) {
+ return buildMessageParts(seq, namespaceURI, wrapper, allowRefs);
+ } else if (type.getParticle() == null) {
+ if (type.getContentModel() == null) {
+ return true;
+ }
+ if (type.getContentModel().getContent() instanceof
XmlSchemaComplexContentExtension) {
+ XmlSchemaComplexContentExtension extension =
(XmlSchemaComplexContentExtension)type
+ .getContentModel().getContent();
+ QName baseTypeName = extension.getBaseTypeName();
+ ServiceInfo serviceInfo =
wrapper.getOperation().getInterface().getService();
+ XmlSchemaType schemaType =
serviceInfo.getXmlSchemaCollection().getTypeByQName(baseTypeName);
+ if (!(schemaType instanceof XmlSchemaComplexType)
+ || !isWrappableSequence((XmlSchemaComplexType)schemaType,
namespaceURI, wrapper,
+ allowRefs)) {
return false;
}
- XmlSchemaElement el = (XmlSchemaElement)o;
- if (el.getSchemaTypeName() != null) {
- MessagePartInfo mpi = wrapper.addMessagePart(new QName(namespaceURI,
el.getName()));
- mpi.setTypeQName(el.getSchemaTypeName());
- mpi.setConcreteName(el.getQName());
- mpi.setElement(true);
- mpi.setElementQName(el.getQName());
- mpi.setXmlSchema(el);
- } else if (el.getRefName() != null) {
- MessagePartInfo mpi = wrapper.addMessagePart(el.getRefName());
- mpi.setTypeQName(el.getRefName());
- mpi.setElementQName(el.getRefName());
- mpi.setElement(true);
- mpi.setXmlSchema(el);
- mpi.setProperty("isRefElement", true);
- // element reference is not permitted for wrapper element
- if (!allowRefs) {
- ret = false;
- }
- } else {
- // anonymous type
- MessagePartInfo mpi = wrapper.addMessagePart(new QName(namespaceURI,
el.getName()));
- mpi.setConcreteName(el.getQName());
- mpi.setElementQName(mpi.getName());
- mpi.setElement(true);
- mpi.setXmlSchema(el);
+ if (extension.getParticle() instanceof XmlSchemaSequence) {
+ XmlSchemaSequence seq = (XmlSchemaSequence)extension.getParticle();
+ return buildMessageParts(seq, namespaceURI, wrapper, allowRefs);
}
- }
- return ret;
- } else if (type.getParticle() == null) {
- if (type.getContentModel() == null) {
- return true;
}
- if (type.getContentModel().getContent() instanceof
XmlSchemaComplexContentExtension) {
- return false;
- }
return true;
}
return false;
}
+ private static boolean buildMessageParts(XmlSchemaSequence seq, String namespaceURI,
MessageInfo wrapper,
+ boolean allowRefs) {
+ XmlSchemaObjectCollection items = seq.getItems();
+ boolean ret = true;
+
+ for (int i = 0; i < items.getCount(); i++) {
+ XmlSchemaObject seqItem = items.getItem(i);
+ if (!(seqItem instanceof XmlSchemaElement)) {
+ return false;
+ }
+ XmlSchemaElement el = (XmlSchemaElement)seqItem;
+
+ if (el.getSchemaTypeName() != null) {
+ MessagePartInfo mpi = wrapper.addMessagePart(new QName(namespaceURI,
el.getName()));
+ mpi.setTypeQName(el.getSchemaTypeName());
+ mpi.setElement(true);
+ mpi.setElementQName(el.getQName());
+ mpi.setConcreteName(el.getQName());
+ mpi.setXmlSchema(el);
+ } else if (el.getRefName() != null) {
+ MessagePartInfo mpi = wrapper.addMessagePart(el.getRefName());
+ mpi.setTypeQName(el.getRefName());
+ mpi.setElementQName(el.getRefName());
+ mpi.setElement(true);
+ mpi.setXmlSchema(el);
+ mpi.setProperty("isRefElement", true);
+ // element reference is not permitted for wrapper element
+ if (!allowRefs) {
+ ret = false;
+ }
+ } else {
+ // anonymous type
+ MessagePartInfo mpi = wrapper.addMessagePart(new QName(namespaceURI,
el.getName()));
+ mpi.setElementQName(mpi.getName());
+ mpi.setConcreteName(el.getQName());
+ mpi.setElement(true);
+ mpi.setXmlSchema(el);
+ }
+ }
+ return ret;
+ }
+
private void buildMessage(AbstractMessageContainer minfo, Message msg) {
SchemaCollection schemas = minfo.getOperation().getInterface().getService()
.getXmlSchemaCollection();
Modified:
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java 2011-10-27
06:17:57 UTC (rev 15169)
+++
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java 2011-10-27
07:29:53 UTC (rev 15170)
@@ -49,11 +49,14 @@
import org.apache.cxf.tools.util.URIParserUtil;
import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaComplexContentExtension;
import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaContent;
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.XmlSchemaForm;
import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaType;
public final class ProcessorUtil {
private static final String KEYWORDS_PREFIX = "_";
@@ -373,25 +376,53 @@
public static List<WrapperElement> getWrappedElement(ToolContext context, QName
partElement) {
List<WrapperElement> qnames = new ArrayList<WrapperElement>();
-
+
ServiceInfo serviceInfo = (ServiceInfo)context.get(ServiceInfo.class);
SchemaCollection schema = serviceInfo.getXmlSchemaCollection();
-
+
XmlSchemaElement elementByName = schema.getElementByQName(partElement);
-
+
XmlSchemaComplexType type = (XmlSchemaComplexType)elementByName.getSchemaType();
XmlSchemaSequence seq = (XmlSchemaSequence)type.getParticle();
-
+
+ qnames.addAll(createWrappedElements(seq));
+
+ // If it's extension
+ if (seq == null && type.getContentModel() != null) {
+
+ XmlSchemaContent xmlSchemaConent = type.getContentModel().getContent();
+ if (xmlSchemaConent instanceof XmlSchemaComplexContentExtension) {
+ XmlSchemaComplexContentExtension extension =
(XmlSchemaComplexContentExtension)type
+ .getContentModel().getContent();
+ QName baseTypeName = extension.getBaseTypeName();
+ XmlSchemaType schemaType = schema.getTypeByQName(baseTypeName);
+ if (schemaType instanceof XmlSchemaComplexType) {
+ XmlSchemaComplexType complexType = (XmlSchemaComplexType)schemaType;
+ if (complexType.getParticle() instanceof XmlSchemaSequence) {
+ seq = (XmlSchemaSequence)complexType.getParticle();
+ qnames.addAll(createWrappedElements(seq));
+ }
+ }
+
+ if (extension.getParticle() instanceof XmlSchemaSequence) {
+ XmlSchemaSequence xmlSchemaSeq =
(XmlSchemaSequence)extension.getParticle();
+ qnames.addAll(createWrappedElements(xmlSchemaSeq));
+ }
+ }
+
+ }
+ return qnames;
+ }
+
+ private static List<WrapperElement> createWrappedElements(XmlSchemaSequence
seq) {
+
+ List<WrapperElement> qnames = new ArrayList<WrapperElement>();
if (seq != null) {
-
XmlSchemaObjectCollection items = seq.getItems();
-
Iterator ite = items.getIterator();
-
while (ite.hasNext()) {
XmlSchemaElement subElement = (XmlSchemaElement)ite.next();
-
if (subElement.getQName() != null) {
qnames.add(new WrapperElement(subElement.getQName(),
subElement.getSchemaTypeName()));
} else {
Modified:
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java 2011-10-27
06:17:57 UTC (rev 15169)
+++
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java 2011-10-27
07:29:53 UTC (rev 15170)
@@ -1350,5 +1350,26 @@
fault =
classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.BadRecordLitFault");
assertEquals(fault.getName().hashCode(),
ObjectStreamClass.lookup(fault).getSerialVersionUID());
}
+
+
+ @Test
+ public void testExtensionWrapper() throws Exception {
+ env.put(ToolConstants.CFG_WSDLURL,
+
getLocation("/wsdl2java_wsdl/cxf2193/hello_world_extension_wrapped.wsdl"));
+ processor.setContext(env);
+ processor.execute();
+ File infFile = new File(output,
"org/apache/cxf/w2j/extension_wrapped/Greeter.java");
+ assertTrue(infFile.exists());
+
+ Class<?> interfaceClass =
classLoader.loadClass("org.apache.cxf.w2j.extension_wrapped.Greeter");
+
+ Method method = interfaceClass.getMethod("greetMe", new Class[] {
+ Holder.class, Holder.class, Holder.class, Holder.class, Holder.class
+ });
+ assertTrue("greetMe operation is NOT generated correctly as excepted",
method != null);
+ RequestWrapper reqWrapper = method.getAnnotation(RequestWrapper.class);
+ assertNotNull("@RequestWrapper is expected", reqWrapper);
+ }
+
}
Added:
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf2193/hello_world_extension_wrapped.wsdl
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf2193/hello_world_extension_wrapped.wsdl
(rev 0)
+++
thirdparty/cxf/branches/cxf-2.2.12-patch-01_JBPAPP-7441/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf2193/hello_world_extension_wrapped.wsdl 2011-10-27
07:29:53 UTC (rev 15170)
@@ -0,0 +1,184 @@
+<?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://cxf.apache.org/w2j/extension_wrapped"
+
xmlns:x1="http://cxf.apache.org/w2j/extension_wrapped/types"
+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+
targetNamespace="http://cxf.apache.org/w2j/extension_wrapped"
name="HelloWorld">
+ <wsdl:types>
+ <schema
targetNamespace="http://cxf.apache.org/w2j/extension_wrapped/types&q...
+
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:x1="http://cxf.apache.org/w2j/extension_wrapped/types"
+ elementFormDefault="qualified">
+ <element name="greetMe">
+ <complexType>
+ <sequence>
+ <element name="content" type="xsd:base64Binary"
minOccurs="0" />
+ <element name="id" type="xsd:string" minOccurs="0"
/>
+ <element name="name" type="xsd:string"
minOccurs="0" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="greetMeResponse" type="x1:ComplexContext" />
+
+ <complexType name="ComplexContext">
+ <complexContent>
+ <extension base="x1:ComplexContextType">
+ <sequence>
+ <element name="extraElement" type="xsd:string" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="ComplexContextType">
+ <sequence>
+ <element name="content" type="xsd:base64Binary"
minOccurs="0" />
+ <element name="id" type="xsd:string" minOccurs="0"
/>
+ <element name="name" type="xsd:string"
minOccurs="0" />
+ <element name="testlist" type="xsd:string"
minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+
+
+
+ </schema>
+ </wsdl:types>
+
+ <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:portType name="Greeter">
+ >
+ <wsdl:operation name="greetMe">
+ <wsdl:input name="greetMeRequest" message="tns:greetMeRequest"
/>
+ <wsdl:output name="greetMeResponse"
message="tns:greetMeResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+ <soap:binding style="document"
+
transport="http://schemas.xmlsoap.org/soap/http" />
+ <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:binding>
+ <wsdl:service name="SOAPService">
+ <wsdl:port name="SoapPort"
binding="tns:Greeter_SOAPBinding">
+ <soap:address location="http://localhost:9000/SoapContext/SoapPort"
/>
+ <wswa:UsingAddressing
xmlns:wswa="http://www.w3.org/2005/02/addressing/wsdl" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
+
+<?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://cxf.apache.org/w2j/extension_wrapped"
+
xmlns:x1="http://cxf.apache.org/w2j/extension_wrapped/types"
+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+
targetNamespace="http://cxf.apache.org/w2j/extension_wrapped"
name="HelloWorld">
+ <wsdl:types>
+ <schema
targetNamespace="http://cxf.apache.org/w2j/extension_wrapped/types&q...
+
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:x1="http://cxf.apache.org/w2j/extension_wrapped/types"
+ elementFormDefault="qualified">
+ <element name="greetMe">
+ <complexType>
+ <sequence>
+ <element name="content" type="xsd:base64Binary"
minOccurs="0" />
+ <element name="id" type="xsd:string" minOccurs="0"
/>
+ <element name="name" type="xsd:string"
minOccurs="0" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="greetMeResponse" type="x1:ComplexContext" />
+
+ <complexType name="ComplexContext">
+ <complexContent>
+ <extension base="x1:ComplexContextType">
+ <sequence>
+ <element name="extraElement" type="xsd:string" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="ComplexContextType">
+ <sequence>
+ <element name="content" type="xsd:base64Binary"
minOccurs="0" />
+ <element name="id" type="xsd:string" minOccurs="0"
/>
+ <element name="name" type="xsd:string"
minOccurs="0" />
+ <element name="testlist" type="xsd:string"
minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+
+
+
+ </schema>
+ </wsdl:types>
+
+ <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:portType name="Greeter">
+ >
+ <wsdl:operation name="greetMe">
+ <wsdl:input name="greetMeRequest" message="tns:greetMeRequest"
/>
+ <wsdl:output name="greetMeResponse"
message="tns:greetMeResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+ <soap:binding style="document"
+
transport="http://schemas.xmlsoap.org/soap/http" />
+ <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:binding>
+ <wsdl:service name="SOAPService">
+ <wsdl:port name="SoapPort"
binding="tns:Greeter_SOAPBinding">
+ <soap:address location="http://localhost:9000/SoapContext/SoapPort"
/>
+ <wswa:UsingAddressing
xmlns:wswa="http://www.w3.org/2005/02/addressing/wsdl" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
+