Hi,
I've developed a web service using Apache Axis 1.4 (WSDL shown at the bottom
of this post) which is deployed to Apache Tomcat 5.5. Using VisualStudio.NET
2003 I've created a small .NET (1.1) based test client to invoke one of the
methods. I get the following exception thrown by the client when I invoke
the loginUser method on the web service:
An unhandled exception of type 'System.InvalidOperationException' occurred
in system.xml.dll
Additional information: There is an error in XML document (1, 2457).
Unhandled Exception: System.InvalidOperationException: There is an error in
XML document (1, 2457). ---> System.InvalidCastException: Cannot assign
object of type
VIPerProvisionTest.provision.ServiceDescriptor to an object of type
VIPerProvisionTest.provision.ServiceDescriptor[].
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.fixup_Read4_ServiceList(Object
objFixup)
at System.Xml.Serialization.XmlSerializationReader.DoFixups()
at
System.Xml.Serialization.XmlSerializationReader.ReadReferencedElements()
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read10_loginUserResponse()
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
xmlReader, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
xmlReader)
at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
at VIPerProvisionTest.provision.ProvisionCommandsService.loginUser(String
userName, String password, AuthenticationToken& authtoken, Organisation&
organisation, Boolean& loginUserReturn) in
d:\projects\c++\viperprovisiontest\web
references\provision\reference.cs:line 37
at VIPerProvisionTest.Form1..ctor() in
d:\projects\c++\viperprovisiontest\form1.cs:line 35
at VIPerProvisionTest.Form1.Main() in
d:\projects\c++\viperprovisiontest\form1.cs:line 90
The program '[1908] VIPerProvisionTest.exe' has exited with code 0 (0x0).
The problem seems to be with the ServiceList element. I've tried just
defining a ServiceDescriptor array in the WSDL (without the ServiceList
wrapper) but I get the same exception thrown. If I remove the ServiceList
from the definition of Organisation, or I change ServiceList for just a
single ServiceDescriptor, then the method invocation is successful. As far
as I can tell the SOAP response (shown below) emitted by Axis looks ok.
Am I defining the array incorrectly in the WSDL ? Does anyone have any idea
why the .NET SOAP implementation is having a problem handling this response
message ?
Thanks,
Tony
------------------------------------------------------------------------------------------------------------------
SOAP response to loginUser request generated by Apache Axis 1.4:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:loginUserResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="urn:soap.provision.viper.bt.com">
<authtoken xsi:type="ns1:AuthenticationToken">
<SessionID
xsi:type="xsd:string">509171851819014720v1pEr357ws1</SessionID>
</authtoken>
<organisation xsi:type="ns1:Organisation">
<ID xsi:type="xsd:int">1</ID>
<Name xsi:type="xsd:string">An Organisation</Name>
<ServiceList xsi:type="ns1:ServiceList">
<ServiceDescriptor xsi:type="ns1:ServiceDescriptor">
<Name xsi:type="xsd:string">A service</Name>
</ServiceDescriptor>
<ServiceDescriptor xsi:type="ns1:ServiceDescriptor">
<Name xsi:type="xsd:string">Another service</Name>
</ServiceDescriptor>
<ServiceDescriptor xsi:type="ns1:ServiceDescriptor">
<Name xsi:type="xsd:string">Yet another
service</Name>
</ServiceDescriptor>
</ServiceList>
</organisation>
<loginUserReturn xsi:type="xsd:boolean">true</loginUserReturn>
</ns1:loginUserResponse>
</soapenv:Body>
</soapenv:Envelope>
------------------------------------------------------------------------------------------------------------------
The WSDL for the web service (trimmed for the method and types of interest):
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="urn:soap.provision.viper.bt.com"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="urn:soap.provision.viper.bt.com"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:soap.provision.viper.bt.com">
<xs:complexType name="AuthenticationToken">
<xs:sequence>
<xs:element name="SessionID"
type="xs:string"
nillable="false"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ServiceDescriptor">
<xs:sequence>
<xs:element name="Name"
type="xs:string"
nillable="false"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ServiceList">
<xs:sequence>
<xs:element name="ServiceDescriptor"
type="impl:ServiceDescriptor"
minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Organisation">
<xs:sequence>
<xs:element name="ID"
type="xs:int"
nillable="false"/>
<xs:element name="Name"
type="xs:string"
nillable="false"/>
<xs:element name="ServiceList"
type="impl:ServiceList"
minOccurs="1"
maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<!-- Requests -->
<wsdl:message name="loginUserRequest">
<wsdl:part name="userName" type="soapenc:string"/>
<wsdl:part name="password" type="soapenc:string"/>
</wsdl:message>
<!-- Responses -->
<wsdl:message name="loginUserResponse">
<wsdl:part name="authtoken" type="impl:AuthenticationToken"/>
<wsdl:part name="organisation" type="impl:Organisation"/>
<wsdl:part name="loginUserReturn" type="soapenc:boolean" />
</wsdl:message>
<!-- Operations -->
<wsdl:portType name="provisionCommands">
<wsdl:operation name="loginUser" parameterOrder="userName password">
<wsdl:input message="impl:loginUserRequest"
name="loginUserRequest"/>
<wsdl:output message="impl:loginUserResponse"
name="loginUserResponse" />
</wsdl:operation>
</wsdl:portType>
<!-- Bindings -->
<wsdl:binding name="provisionSoapBinding" type="impl:provisionCommands">
<wsdlsoap:binding style="RPC"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="loginUser">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="loginUserRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:soap.provision.viper.bt.com"
use="encoded"/>
</wsdl:input>
<wsdl:output name="loginUserResponse" >
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace=":urn:soap.provision.viper.bt.com"
use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ProvisionCommandsService">
<wsdl:port binding="impl:provisionSoapBinding" name="provision">
<wsdlsoap:address
location="http://localhost:8080/axis/services/provision"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
John Saunders [MVP] - 02 Aug 2007 00:07 GMT
> Hi,
>
[quoted text clipped - 14 lines]
> VIPerProvisionTest.provision.ServiceDescriptor to an object of type
> VIPerProvisionTest.provision.ServiceDescriptor[].
This means that it thinks it has encountered a single ServiceDescriptor in
the input, but needs to cast it to an array (which makes sense given the
maxOccurs).
...
> The problem seems to be with the ServiceList element. I've tried just
> defining a ServiceDescriptor array in the WSDL (without the ServiceList
> wrapper) but I get the same exception thrown. If I remove the ServiceList
> from the definition of Organisation, or I change ServiceList for just a
> single ServiceDescriptor, then the method invocation is successful. As far
> as I can tell the SOAP response (shown below) emitted by Axis looks ok.
Actually, it doesn't look like a SOAP-encoded response at all. It looks
literal. I never use RPC/Encoded, so I can't tell you for sure, but I think
the XML is supposed to say "there's an array here". Instead, it says there's
a ServiceDescriptor.
Does a Java client consume this service ok?

Signature
John Saunders [MVP]
Tony Stephens - 02 Aug 2007 13:56 GMT
> > Hi,
> >
[quoted text clipped - 33 lines]
>
> Does a Java client consume this service ok?
Hi John,
Thanks for your response. I'm aware of what the exception is stating. My
implied question is given that the WSDL specifies that there is an array in
the response why is the .NET proxy unable to interpret the list of service
descriptors as an array (why does there need to be an explicit indicator of
an array) ? Is there some means of tweaking the proxy behaviour ? I haven't
been able to find a way to force apache axis to wrap this list (i.e. have a
<serviceDescriptors> container which presumably is why .NET is complaining ?)
I would have thought that this is a common problem (getting a .NET client
working to an apache axis service) and so someone somewhere must have gone
down this path before, discovered the same problem, and possibly been able to
resolve this either by tweaking the .NET proxy generated code, the WSDL, or
the java tool that generates the web service.
I have a java based client that is able to communicate correctly with the
web service.
Thanks,
Tony
Nishant - 02 Aug 2007 09:32 GMT
> Hi,
>
[quoted text clipped - 234 lines]
> </wsdl:definitions>
>
Hi,
I want to implement a web service notification in java. Can anyone help me with a working example?
Thanks,
Nishant
BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
Tony Stephens - 02 Aug 2007 14:04 GMT
> Hi,
>
[quoted text clipped - 5 lines]
> BizTalk Utilities - Frustration free BizTalk Adapters
> http://www.topxml.com/biztalkutilities
Hi Nishant,
There are a number of Java based webservice tools available. The two I know
of are:
Apache Axis : http://ws.apache.org/axis/
XFire (CrossFire): http://xfire.codehaus.org/
The Apache Axis download includes a number of sample applications.
Regards,
Tony
Tony Stephens - 02 Aug 2007 17:08 GMT
I've managed to sort out the problem by changing the encoding to
wrapped/literal when invoking the axis tools to generate the service stub and
skeleton code. The .NET soap proxy seems to be happy now.
Regards,
Tony