You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by en...@apache.org on 2007/05/18 16:20:11 UTC
svn commit: r539511 - in /incubator/yoko/trunk/tools/src:
main/java/org/apache/yoko/tools/processors/wsdl/WSDLParameter.java
test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTypeTest.java
test/resources/wsdl/factory_pattern.wsdl
Author: enolan
Date: Fri May 18 09:20:10 2007
New Revision: 539511
URL: http://svn.apache.org/viewvc?view=rev&rev=539511
Log:
Yoko-362 - wsdltoidl fails with anonymous return param.
Added:
incubator/yoko/trunk/tools/src/test/resources/wsdl/factory_pattern.wsdl
Modified:
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLParameter.java
incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTypeTest.java
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLParameter.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLParameter.java?view=diff&rev=539511&r1=539510&r2=539511
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLParameter.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLParameter.java Fri May 18 09:20:10 2007
@@ -465,9 +465,7 @@
}
private static QName getIdlType(WSDLToCorbaBinding wsdlToCorbaBinding,
- XmlSchemaType schemaType,
- QName typeName,
- boolean nill)
+ XmlSchemaType schemaType, QName typeName, boolean nill)
throws Exception {
QName idltype = null;
CorbaTypeImpl corbaTypeImpl = null;
@@ -475,48 +473,75 @@
corbaTypeImpl = (CorbaTypeImpl) WSDLToCorbaHelper.CORBAPRIMITIVEMAP.get(typeName);
if (nill) {
QName qname = corbaTypeImpl.getQName();
- idltype =
+ idltype =
wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart() + "_nil");
} else {
- idltype = corbaTypeImpl.getQName();
+ if (corbaTypeImpl == null) {
+ XmlSchemaObject schemaObj = getSchemaObject(
+ wsdlToCorbaBinding, typeName);
+ XmlSchemaAnnotation annotation = null;
+ if (schemaObj instanceof XmlSchemaType) {
+ schemaType = (XmlSchemaType) schemaObj;
+ } else if (schemaObj instanceof XmlSchemaElement) {
+ XmlSchemaElement el = (XmlSchemaElement) schemaObj;
+ schemaType = el.getSchemaType();
+ annotation = ((XmlSchemaElement) schemaObj).getAnnotation();
+ }
+ idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType,
+ annotation, typeName, nill);
+ } else {
+ idltype = corbaTypeImpl.getQName();
+ }
}
} else {
- // We need to get annotation information for the schema type we are about to pass in.
+ // We need to get annotation information for the schema type we are
+ // about to pass in.
// This is used to produce the correct object reference type.
- List<XmlSchema> schemaList = wsdlToCorbaBinding.getHelper().getXMLSchemaList();
- Iterator<XmlSchema> schemaIterator = schemaList.iterator();
- XmlSchemaObject schemaObj = null;
- while (schemaIterator.hasNext()) {
- XmlSchema s = schemaIterator.next();
- XmlSchemaObjectTable schemaTable = s.getElements();
- schemaObj = schemaTable.getItem(typeName);
- if (schemaObj != null) {
- break;
- }
- }
-
+ XmlSchemaObject schemaObj = getSchemaObject(wsdlToCorbaBinding, typeName);
XmlSchemaAnnotation annotation = null;
if (schemaObj != null && schemaObj instanceof XmlSchemaElement) {
- annotation = ((XmlSchemaElement)schemaObj).getAnnotation();
+ annotation = ((XmlSchemaElement) schemaObj).getAnnotation();
+ }
+ idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType,
+ annotation, typeName, nill);
+ }
+ return idltype;
+ }
+
+ private static XmlSchemaObject getSchemaObject(
+ WSDLToCorbaBinding wsdlToCorbaBinding, QName typeName) {
+
+ List<XmlSchema> schemaList = wsdlToCorbaBinding.getHelper().getXMLSchemaList();
+ Iterator<XmlSchema> schemaIterator = schemaList.iterator();
+ XmlSchemaObject schemaObj = null;
+ while (schemaIterator.hasNext()) {
+ XmlSchema s = schemaIterator.next();
+ XmlSchemaObjectTable schemaTable = s.getElements();
+ schemaObj = schemaTable.getItem(typeName);
+ if (schemaObj != null) {
+ break;
}
-
- corbaTypeImpl =
- wsdlToCorbaBinding.getHelper().convertSchemaToCorbaType(schemaType,
- typeName,
- null,
- annotation,
- false);
- if (corbaTypeImpl == null) {
- throw new Exception("Couldn't convert schema type to corba type : " + typeName);
+ }
+ return schemaObj;
+ }
+
+ private static QName getSchemaTypeName(WSDLToCorbaBinding wsdlToCorbaBinding,
+ XmlSchemaType schemaType, XmlSchemaAnnotation annotation, QName typeName,
+ boolean nill) throws Exception {
+ QName idltype = null;
+ CorbaTypeImpl corbaTypeImpl = null;
+
+ corbaTypeImpl = wsdlToCorbaBinding.getHelper().convertSchemaToCorbaType(schemaType,
+ typeName, null, annotation, false);
+ if (corbaTypeImpl == null) {
+ throw new Exception("Couldn't convert schema type to corba type : " + typeName);
+ } else {
+ if (nill) {
+ QName qname = corbaTypeImpl.getQName();
+ idltype =
+ wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart() + "_nil");
} else {
- if (nill) {
- QName qname = corbaTypeImpl.getQName();
- idltype =
- wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart()
- + "_nil");
- } else {
- idltype = corbaTypeImpl.getQName();
- }
+ idltype = corbaTypeImpl.getQName();
}
}
return idltype;
Modified: incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTypeTest.java?view=diff&rev=539511&r1=539510&r2=539511
==============================================================================
--- incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTypeTest.java (original)
+++ incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTypeTest.java Fri May 18 09:20:10 2007
@@ -593,5 +593,21 @@
}
+ public void testAnonymousReturnParam() throws Exception {
+
+ try {
+ String fileName = getClass().getResource("/wsdl/factory_pattern.wsdl").toString();
+ generator.setWsdlFile(fileName);
+ generator.addInterfaceName("Number");
+
+ Definition model = generator.generateCORBABinding();
+ Document document = writer.getDocument(model);
+ Element typemap = getElementNode(document, "corba:typeMapping");
+ assertNotNull(typemap);
+ assertEquals(3, typemap.getElementsByTagName("corba:struct").getLength());
+ } finally {
+ new File("factory_pattern-corba.wsdl").deleteOnExit();
+ }
+ }
}
Added: incubator/yoko/trunk/tools/src/test/resources/wsdl/factory_pattern.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/wsdl/factory_pattern.wsdl?view=auto&rev=539511
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/wsdl/factory_pattern.wsdl (added)
+++ incubator/yoko/trunk/tools/src/test/resources/wsdl/factory_pattern.wsdl Fri May 18 09:20:10 2007
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<wsdl:definitions name="NumberFactoryService"
+ targetNamespace="http://cxf.apache.org/factory_pattern"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsa="http://www.w3.org/2005/08/addressing"
+ xmlns:jms="http://cxf.apache.org/transports/jms"
+ xmlns:ns1="http://factory_pattern.cxf.apache.org/"
+ xmlns:tns="http://cxf.apache.org/factory_pattern"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <wsdl:types>
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ attributeFormDefault="unqualified" elementFormDefault="qualified"
+ targetNamespace="http://factory_pattern.cxf.apache.org/">
+ <xsd:import namespace="http://www.w3.org/2005/08/addressing" schemaLocation="wsaddressing.xsd"/>
+ <xsd:element name="create">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="id" nillable="false"
+ type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="createResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="return" nillable="false"
+ type="wsa:EndpointReferenceType" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="isEvenResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="even" type="xsd:boolean" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ </wsdl:types>
+
+ <wsdl:message name="create">
+ <wsdl:part name="create" element="ns1:create" />
+ </wsdl:message>
+ <wsdl:message name="createResponse">
+ <wsdl:part name="createResponse" element="ns1:createResponse" />
+ </wsdl:message>
+ <wsdl:message name="isEven" />
+ <wsdl:message name="isEvenResponse">
+ <wsdl:part name="isEvenResponse" element="ns1:isEvenResponse" />
+ </wsdl:message>
+
+ <wsdl:portType name="NumberFactory">
+ <wsdl:operation name="create">
+ <wsdl:input message="tns:create" />
+ <wsdl:output message="tns:createResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:portType name="Number">
+ <wsdl:operation name="isEven">
+ <wsdl:input message="tns:isEven" />
+ <wsdl:output message="tns:isEvenResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+</wsdl:definitions>
+