I have seen quite a bit of post here on interoperability and problems
with Axis not generation WSDL as expected.
I have been trying for some time to deploy a quite large service, using
Axis 1.1, with about a hundred functions and very deep complex data
structures, including Arrays.
Just want to share a few things that I have found out on my journey to
success and to ask a few thing that don't work as I want them to.
We are building our service from WSDL that we create in XML-spy, in out
first attempt we tried to generate a Doc/Literal Service. WSDL2Java
successfully generated java classes for us but when we tried to generate
WSDL from the running service (using ?WSDL) Axis kept on giving us
errors like this:
---8<----
Fault - WSDLException: faultCode=PARSER_ERROR: Problem parsing '- WSDL
Document -'.: The value of the attribute
"prefix="xmlns",localpart="tns1",rawname="xmlns:tns1"" is invalid.
Prefixed namespace bindings may not be empty.:
org.xml.sax.SAXParseException: The value of the attribute
"prefix="xmlns",localpart="tns1",rawname="xmlns:tns1"" is invalid.
Prefixed namespace bindings may not be empty.
---8<-----
After searching, reading and experimenting quite a bit we found out that
Axis doesn't really like Doc/Literal so we tried RPC/Encoded instead.
(Note that .NET only likes Doc/Literal or RPC/Encoded and no other
combinations.) Now Axis could generate the WSDL and we started to build
clients. Using Axis as client was no problem but the .NET client gave us
this error:
---8<-----
System.InvalidOperationException: There is an error in XML document
(114, 4). ---> System.InvalidCastException: Cannot assign object of type
SOAPTest.WebReference1.DataType to an object of type
SOAPTest.WebReference1.DataType[].
---8<-----
Again after some amount of testing we found that you must declare the
Arrays in WSDL like this:
----8<-----
<xsd:complexType name="DataTypeArray">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<xsd:sequence>
<xsd:element
name="DataList"
type="DataListType"
maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute
ref="soapenc:arrayType"
wsdl:arrayType="tns:DataListTyp[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
---8<----
(I.e. using ComplexType + ComplexContent)
No other syntax seemes to satisfy both Axis and .NET when using encoded.
So finally we got it all up and running and so far it seems that we have
interoperability with many different SOAP toolkits.
And a few questions:
How to you get Axis to return SoapFaults? I have declared faults in the
WSDL, the Fault classes are generated and I throw the generated Faults.
Still the only fault that Axis seems to return back to the client is the
"General Fault". Is it possibly, and in that case how, to make Axis to
return the correct SoapFault?
Can axis handle <choice>? If I crate a WSDL with a <choice>, Axis keeps
on generating the same code as for <sequence>. Even worse is that ?wsdl
generates a <sequence> in the wsdl and not a <choice>.
Thanks,
/Magnus Sandberg