Details
Description
java2wsdl does not honour elementFormDefault="qualified" attribute. Generated package-info.java does not have set attribute elementFormDefault=XmlNsForn.QUALIFIED.
See below example:
here is sample wsdl:
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/loanap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:loanapp="http://www.example.org/loanap/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="loanap" targetNamespace="http://www.example.org/loanap/"> <wsdl:types> <xsd:schema targetNamespace="http://www.example.org/loanap/types" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xsd:element name="aplication"> <xsd:complexType> <xsd:sequence> <xsd:element name="salary" type="xsd:decimal" /> <xsd:element name="loan" type="xsd:decimal" /> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="result"> <xsd:complexType> <xsd:sequence> <xsd:element name="commited" type="xsd:boolean" /> <xsd:element name="amount" type="xsd:decimal" /> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> </wsdl:types> <wsdl:message name="applyRequest"> <wsdl:part element="loanapp:aplication" name="parameters" /> </wsdl:message> <wsdl:message name="applyResponse"> <wsdl:part element="loanapp:result" name="parameters" /> </wsdl:message> <wsdl:portType name="LoanService"> <wsdl:operation name="apply"> <wsdl:input message="tns:applyRequest" /> <wsdl:output message="tns:applyResponse" /> </wsdl:operation> </wsdl:portType> <wsdl:binding name="loanapSOAP" type="tns:LoanService"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="apply"> <soap:operation soapAction="http://www.example.org/loanap/NewOperation" /> <wsdl:input> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="loanap"> <wsdl:port binding="tns:loanapSOAP" name="LoanService"> <soap:address location="http://www.somebank.com/services/loanservice" /> </wsdl:port> </wsdl:service> </wsdl:definitions>
I use
wsdl2java loanapp.wsdl
to generate Java artefacts and got package-info.java as below:
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.example.org/loanap/types") package org.example.loanap.types;
Note that, in above embedded XML Schema I have
elementFormDefault="qualified
but in above
package-info it is not reflected.
When Metro stack is used I got what expected:
wsimport -Xnocompile loanap.wsdl
gives:
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.example.org/loanap/types", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package org.example.loanap.types;
What's interesting. When I use jaxb 2.0.5 (which seems to be used in CXF 2.0.4) and xjc I got exactly the same code as wsimport.
It seems that's CXF bug, rather than JAXB RI. Also I consider this as a serius show stopper, since CXF will produce XML instances which are not valid against above schema (i.e. unqualified).