Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
Java-SCA-1.5.1
-
None
-
All
Description
Discussed here - http://www.mail-archive.com/dev%40tuscany.apache.org/msg09543.html
For an interface such as..
package service;
import org.osoa.sca.annotations.Service;
@Service(SomeService.class)
public class SomeServiceImpl implements SomeService {
public AnObject getUsingString(String stringParam)
{ System.out.println("Param value:" + stringParam); return getAnObject(stringParam); }private AnObject getAnObject(String stringParam)
{ return new AnObject(stringParam + "123", 123); } public AnObject getUsingMoreComplexObject(MoreComplexObject
moreComplexParam)
}
Tuscany generates the WSDL types...
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="SomeServiceService"
targetNamespace="http://service/" xmlns:tns="http://service/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:SOAP11="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="anObject">
<xs:sequence>
<xs:element minOccurs="0" name="someOtherRetValue" type="xs:int" />
<xs:element minOccurs="0" name="someRetValue" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="moreComplexObject">
<xs:sequence>
<xs:element minOccurs="0" name="intParam" type="xs:int" />
<xs:element minOccurs="0" name="stringParam" type="xs:string" />
<xs:element minOccurs="0" name="stringParam2" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema attributeFormDefault="qualified"
elementFormDefault="unqualified" targetNamespace="http://service/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import />
<xs:element name="getUsingString">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="arg0" nillable="true"
type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getUsingMoreComplexObjectResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true"
type="anObject" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getUsingMoreComplexObject">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="arg0" nillable="true"
type="moreComplexObject" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getUsingStringResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true"
type="anObject" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
However the wsgen JAXWS tooling generates the following schema for the WSDL...
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" targetNamespace="http://service/"
xmlns:tns="http://service/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="getUsingMoreComplexObject"
type="tns:getUsingMoreComplexObject"/>
<xs:element name="getUsingMoreComplexObjectResponse"
type="tns:getUsingMoreComplexObjectResponse"/>
<xs:element name="getUsingString" type="tns:getUsingString"/>
<xs:element name="getUsingStringResponse" type="tns:getUsingStringResponse"/>
<xs:complexType name="getUsingMoreComplexObject">
<xs:sequence>
<xs:element name="arg0" type="tns:moreComplexObject" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="moreComplexObject">
<xs:sequence>
<xs:element name="intParam" type="xs:int" minOccurs="0"/>
<xs:element name="stringParam" type="xs:string" minOccurs="0"/>
<xs:element name="stringParam2" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getUsingMoreComplexObjectResponse">
<xs:sequence>
<xs:element name="return" type="tns:anObject" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="anObject">
<xs:sequence>
<xs:element name="someOtherRetValue" type="xs:int" minOccurs="0"/>
<xs:element name="someRetValue" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getUsingString">
<xs:sequence>
<xs:element name="arg0" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getUsingStringResponse">
<xs:sequence>
<xs:element name="return" type="tns:anObject" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Note that difference is that the schema types anObject and
moreComplexObject are generated into a namespace for wsgen and not
for Tuscany.
Now looking back at various related specs...
WS-I [1] says...
R2105 All xsd:schema elements contained in a wsdl:types element of a
DESCRIPTION MUST have a targetNamespace attribute with a valid and
non-null value, UNLESS the xsd:schema element has xsd:import and/or
xsd:annotation as its only child element(s)
And JAX-WS 2.1 I believe is intended to be WS-I compliant.
The wrinkle then seems to be that the JAXB spec defines a default Java
to XSD mapping where types are not placed in a namespace unless you
configure the Java class with annotations. The spec does talk of
"customizations" and I guess this is what the wsgen tool is doing but
I can't find any explicit statement about what these customizations
might be other than those provided by code annotations. This page [3]
suggests that it's sneaking behind the public JAXB API to make this
happen.
I found that the subject of the JAXB mapping had been discussed
before, e.g. [2], and I do remember testing that the no namespace
schema inclusion was actually valid. However I can't put my finger on
anything to do with customizing the mapping that has been discussed
here and why we aren't doing it.
Anyone know how to get JAXB to generate schema that are WS-I compliant
in this case?
I note that Axis have witten their own generator but I remember a long
time ago we used the Axis code and the stopped using it in favour of
the JAXB code for some reason. Anyone remember why (am searching the
ML also of course).