You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Simon Laws <si...@googlemail.com> on 2009/10/09 10:13:37 UTC

[1.x] WSDL gen fun and games

I've been working on TUSCANY-3283 which, on the face of it, looks
fairly straightforward. We need to move types generated into a no
namespace schema into the schema bearing the namespace of the WSDL
being generated. This turns out to be a little tricky because schema
information is, IFAICT, stored in at least four places in memory. A
simplistic view is as follows

WSDLDefinition - the Tuscany collection of all things WSDL
   Definition  - the javax.wsdl definition of the WSDL
   XSDefinition - one of these for each schema in the WSDL
         Document - the DOM version of the schema
         XmlSchema - the o.a.ws.commons version of the schema
         XmlSchemaCollection - the collection of schema use to turn
the DOM verision into the XmlSchema version

Information gets moved backwards and forwards at various points in the
processing and working out what is valid when is not straightforward.
It is worth noting that I discovered that the JAXB generated schema
turn up in DOM format in the first instance and the SDO generated
schema turn up in XmlSchema format. How I laughed. After several
rewrites of the Interface2WSDLGenerator.generate() method I seem to
have a sequence that hangs together.  I think the changes I've made to
date fix TUSCANY-3283.

However looking at the result of the wrapper generation (which I
haven't changed in substance b.t.w), it doesn't look 100% right to me.
There is a flag in the logic which allows JAXB to generate the
wrappers rather than the manual code that is in
Interface2WSDLGenerator.generate(). This appears more satisfactory.
Turing this flag on does, IMO, lead to better schema. However it also
cause several test cases in the build to fail.

1/ binding-ws / FileTransferMTOMTestCase

Calls the FileTransferService operation with the following signature..

    //This method uses an user defined interface MyException as parameter type.
    public String
sendMyException(@XmlJavaTypeAdapter(MyExceptionAdapter.class)
MyException attachment)
    																				throws Exception;
Which fails in WSDL gen complaining about the fact we are passing an
exception (neither it nor it's base classes have a default
constructor). Interestingly I get an NPE when I run wsgen against this
class so it may be that we can discount this as being non-compliant
w.r.t JAXWS. Interestingly I don't think this has every worked. Even
with the manual wrapper generation turned on you just get the same
error, but at runtime.

2/ databinding-jaxb-bottom-up

One out of the 180 tests fails here when JAXB wrapper generation is
turned on. The databinding layer is unable to find some HashMap type.
There are significant differences between the manually generated and
JAXB generated wrapper schema in this case (see schema attached
below). However I'm getting out of my depth in terms of the operation
of the databinding layer and how we might fix these problems assuming
that we decide to go with JAXB generated wrappers rather than Tuscany
generated wrappers.

3/ databinding-top-down

There are failures here also which I'm yet to investigate.

I'm going to fix up the 1.x (and 1.5.2) with the current state of the
fixes and close TUSCANY 3283. However I'd like some help to futher
look through these databinding issues when JAXB wrapper generation is
enabled. Currently my thinking is that I would like to turn on JAXB
generation on as it seems like a more well rounded solution to me but
I'm open to thoughts though here. If someone is up for going through
this maybe we can get on IRC or something and try and understand the
details.

Regards

Simon

JAXB generated
=============

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:tns="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
	targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
	version="1.0">
	<xs:element name="getGreetings" type="tns:getGreetings" />
	<xs:element name="getGreetingsArray" type="tns:getGreetingsArray" />
	<xs:element name="getGreetingsArrayList" type="tns:getGreetingsArrayList" />
	<xs:element name="getGreetingsArrayListResponse"
type="tns:getGreetingsArrayListResponse" />
	<xs:element name="getGreetingsArrayResponse"
type="tns:getGreetingsArrayResponse" />
	<xs:element name="getGreetingsHashMap" type="tns:getGreetingsHashMap" />
	<xs:element name="getGreetingsHashMapResponse"
type="tns:getGreetingsHashMapResponse" />
	<xs:element name="getGreetingsList" type="tns:getGreetingsList" />
	<xs:element name="getGreetingsListResponse"
type="tns:getGreetingsListResponse" />
	<xs:element name="getGreetingsMap" type="tns:getGreetingsMap" />
	<xs:element name="getGreetingsMapResponse"
type="tns:getGreetingsMapResponse" />
	<xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse" />
	<xs:element name="getGreetingsVarArgs" type="tns:getGreetingsVarArgs" />
	<xs:element name="getGreetingsVarArgsResponse"
type="tns:getGreetingsVarArgsResponse" />
	<xs:complexType name="getGreetingsMapResponse">
		<xs:sequence>
			<xs:element name="_return">
				<xs:complexType>
					<xs:sequence>
						<xs:element maxOccurs="unbounded" minOccurs="0" name="entry">
							<xs:complexType>
								<xs:sequence>
									<xs:element minOccurs="0" name="key" type="xs:string" />
									<xs:element minOccurs="0" name="value" type="xs:string" />
								</xs:sequence>
							</xs:complexType>
						</xs:element>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="getGreetingsArrayList">
		<xs:sequence>
			<xs:element maxOccurs="unbounded" minOccurs="0" name="arg0"
				type="xs:string" />
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="getGreetings">
		<xs:sequence>
			<xs:element minOccurs="0" name="arg0" type="xs:string" />
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="getGreetingsArray">
		<xs:sequence>
			<xs:element maxOccurs="unbounded" minOccurs="0" name="arg0"
				nillable="true" type="xs:string" />
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="getGreetingsList">
		<xs:sequence>
			<xs:element maxOccurs="unbounded" minOccurs="0" name="arg0"
				type="xs:string" />
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="getGreetingsListResponse">
		<xs:sequence>
			<xs:element maxOccurs="unbounded" minOccurs="0" name="return"
				type="xs:string" />
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="getGreetingsVarArgs">
		<xs:sequence>
			<xs:element maxOccurs="unbounded" minOccurs="0" name="arg0"
				nillable="true" type="xs:string" />
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="getGreetingsArrayListResponse">
		<xs:sequence>
			<xs:element maxOccurs="unbounded" minOccurs="0" name="return"
				type="xs:string" />
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="getGreetingsMap">
		<xs:sequence>
			<xs:element name="arg0">
				<xs:complexType>
					<xs:sequence>
						<xs:element maxOccurs="unbounded" minOccurs="0" name="entry">
							<xs:complexType>
								<xs:sequence>
									<xs:element minOccurs="0" name="key" type="xs:string" />
									<xs:element minOccurs="0" name="value" type="xs:string" />
								</xs:sequence>
							</xs:complexType>
						</xs:element>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="getGreetingsHashMap">
		<xs:sequence>
			<xs:element name="arg0">
				<xs:complexType>
					<xs:sequence>
						<xs:element maxOccurs="unbounded" minOccurs="0" name="entry">
							<xs:complexType>
								<xs:sequence>
									<xs:element minOccurs="0" name="key" type="xs:string" />
									<xs:element minOccurs="0" name="value" type="xs:string" />
								</xs:sequence>
							</xs:complexType>
						</xs:element>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="getGreetingsArrayResponse">
		<xs:sequence>
			<xs:element maxOccurs="unbounded" minOccurs="0" name="return"
				nillable="true" type="xs:string" />
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="getGreetingsHashMapResponse">
		<xs:sequence>
			<xs:element name="_return">
				<xs:complexType>
					<xs:sequence>
						<xs:element maxOccurs="unbounded" minOccurs="0" name="entry">
							<xs:complexType>
								<xs:sequence>
									<xs:element minOccurs="0" name="key" type="xs:string" />
									<xs:element minOccurs="0" name="value" type="xs:string" />
								</xs:sequence>
							</xs:complexType>
						</xs:element>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="getGreetingsResponse">
		<xs:sequence>
			<xs:element minOccurs="0" name="return" type="xs:string" />
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="getGreetingsVarArgsResponse">
		<xs:sequence>
			<xs:element minOccurs="0" name="return" type="xs:string" />
		</xs:sequence>
	</xs:complexType>
</xs:schema>


Tuscany Generated
===============

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://jaxb.dev.java.net/array" version="1.0">
	<xs:complexType final="#all" name="stringArray">
		<xs:sequence>
			<xs:element maxOccurs="unbounded" minOccurs="0" name="item"
				nillable="true" type="xs:string" />
		</xs:sequence>
	</xs:complexType>
</xs:schema><?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:tns="http://jaxb.databindings.itest.sca.tuscany.apache.org/"
	attributeFormDefault="qualified" elementFormDefault="unqualified"
	targetNamespace="http://jaxb.databindings.itest.sca.tuscany.apache.org/">
	<xs:element name="getGreetingsHashMap">
		<xs:complexType>
			<xs:sequence>
				<xs:element minOccurs="0" name="arg0" nillable="true"
					type="tns:hashMap" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="getGreetingsListResponse">
		<xs:complexType>
			<xs:sequence>
				<xs:element minOccurs="0" name="return" nillable="true"
					type="xs:anyType" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="getGreetingsResponse">
		<xs:complexType>
			<xs:sequence>
				<xs:element minOccurs="0" name="return" nillable="true"
					type="xs:string" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="getGreetingsMap">
		<xs:complexType>
			<xs:sequence>
				<xs:element minOccurs="0" name="arg0" nillable="true"
					type="xs:anyType" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="getGreetingsArrayResponse">
		<xs:complexType>
			<xs:sequence>
				<xs:element maxOccurs="unbounded" minOccurs="0" name="return"
					nillable="true" type="xs:string" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="getGreetingsMapResponse">
		<xs:complexType>
			<xs:sequence>
				<xs:element minOccurs="0" name="return" nillable="true"
					type="xs:anyType" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="getGreetingsHashMapResponse">
		<xs:complexType>
			<xs:sequence>
				<xs:element minOccurs="0" name="return" nillable="true"
					type="tns:hashMap" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="getGreetingsList">
		<xs:complexType>
			<xs:sequence>
				<xs:element minOccurs="0" name="arg0" nillable="true"
					type="xs:anyType" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="getGreetingsArrayListResponse">
		<xs:complexType>
			<xs:sequence>
				<xs:element minOccurs="0" name="return" nillable="true"
					type="tns:arrayList" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="getGreetingsVarArgs">
		<xs:complexType>
			<xs:sequence>
				<xs:element maxOccurs="unbounded" minOccurs="0" name="arg0"
					nillable="true" type="xs:string" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="getGreetingsArrayList">
		<xs:complexType>
			<xs:sequence>
				<xs:element minOccurs="0" name="arg0" nillable="true"
					type="tns:arrayList" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="getGreetingsArray">
		<xs:complexType>
			<xs:sequence>
				<xs:element maxOccurs="unbounded" minOccurs="0" name="arg0"
					nillable="true" type="xs:string" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="getGreetingsVarArgsResponse">
		<xs:complexType>
			<xs:sequence>
				<xs:element minOccurs="0" name="return" nillable="true"
					type="xs:string" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="getGreetings">
		<xs:complexType>
			<xs:sequence>
				<xs:element minOccurs="0" name="arg0" nillable="true"
					type="xs:string" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:complexType name="hashMap">
		<xs:complexContent>
			<xs:extension base="abstractMap">
				<xs:sequence />
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType abstract="true" name="abstractMap">
		<xs:sequence />
	</xs:complexType>
	<xs:complexType name="arrayList">
		<xs:complexContent>
			<xs:extension base="abstractList">
				<xs:sequence />
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType abstract="true" name="abstractList">
		<xs:complexContent>
			<xs:extension base="abstractCollection">
				<xs:sequence />
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType abstract="true" name="abstractCollection">
		<xs:sequence />
	</xs:complexType>
</xs:schema>