I've writtin a very simple web service in axis which returns an array of
classes.
I consume it in a .net app. When receiving the response, my .net app
generates an error "Cannot assign object of type System.Object[] to an
object of type PersonWS.WorkGroupData[].".
I've included the wsdl of the consumed axis web service, the
request/responses of the web service by the .net app and the exception and
stack trace. Hoping someone can tell me what I'm doing wrong here.
**** Class I'm trying to serialize:
package ca.comp.openview;
public class WorkGroupData implements java.io.Serializable
{
static final long serialVersionUID = 1;
public String Name;
public String SearchCode;
public WorkGroupData()
{
}
public WorkGroupData(String strName, String strSearchCode)
{
Name = strName;
SearchCode = strSearchCode;
}
}
**** WSDL:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:tns1="http://openview.comp.ca"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:impl="http://dc1serv306:8080/axis/PersonWS.jws"
xmlns:intf="http://dc1serv306:8080/axis/PersonWS.jws"
targetNamespace="http://dc1serv306:8080/axis/PersonWS.jws"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://openview.comp.ca">
<xsd:import namespace="http://dc1serv306:8080/axis/PersonWS.jws" />
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xsd:lexType name="WorkGroupData">
<xsd:sequence>
<xsd:element name="Name" nillable="true" type="xsd:string" />
<xsd:element name="SearchCode" nillable="true" type="xsd:string"
/>
</xsd:sequence>
</xsd:lexType>
</xsd:schema>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://dc1serv306:8080/axis/PersonWS.jws">
<xsd:import namespace="http://openview.comp.ca" />
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xsd:lexType name="ArrayOf_tns1_WorkGroupData">
<xsd:lexContent mixed="false">
<xsd:restriction base="soapenc:Array">
<xsd:attribute wsdl:arrayType="tns1:WorkGroupData[]"
ref="soapenc:arrayType" />
</xsd:restriction>
</xsd:lexContent>
</xsd:lexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="ListWorkGroupsRequest">
<wsdl:part name="strPerson" type="xsd:string" />
</wsdl:message>
<wsdl:message name="ListWorkGroupsResponse">
<wsdl:part name="ListWorkGroupsReturn"
type="intf:ArrayOf_tns1_WorkGroupData" />
</wsdl:message>
<wsdl:portType name="PersonWS">
<wsdl:operation name="ListWorkGroups" parameterOrder="strPerson">
<wsdl:input name="ListWorkGroupsRequest"
message="intf:ListWorkGroupsRequest" />
<wsdl:output name="ListWorkGroupsResponse"
message="intf:ListWorkGroupsResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="PersonWSSoapBinding" type="intf:PersonWS">
<wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="rpc" />
<wsdl:operation name="ListWorkGroups">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="ListWorkGroupsRequest">
<wsdlsoap:body use="encoded" namespace="http://DefaultNamespace"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:input>
<wsdl:output name="ListWorkGroupsResponse">
<wsdlsoap:body use="encoded"
namespace="http://dc1serv306:8080/axis/PersonWS.jws"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="PersonWSService">
<wsdl:port name="PersonWS" binding="intf:PersonWSSoapBinding">
<wsdlsoap:address location="http://dc1serv306:8080/axis/PersonWS.jws"
/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
**** Web service request:
POST /axis/PersonWS.jws HTTP/1.1
User-Agent: Mozilla/4.0 (atible; MSIE 6.0; MS Web Services Client Protocol
2.0.50727.42)
VsDebuggerCausalityData:
uIDPo0CmVGk8IFRKtnoM+dd/g1UAAAAABhYLv0zewUCAHJEZp0AP92+xiiG8VKREqmQwwAAIXQ 0ACAAA
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Host: localhost:8080
Content-Length: 613
Expect: 100-continue
<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://dc1serv306:8080/axis/PersonWS.jws"
xmlns:types="http://dc1serv306:8080/axis/PersonWS.jws/encodedTypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><q1:ListWorkGroups
xmlns:q1="http://DefaultNamespace"><strPerson
xsi:type="xsd:string">chaj17</strPerson></q1:ListWorkGroups></soap:Body></soap:Envelope>
**** Web service response:
HTTP/1.1 100 Continue
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=EA7F4F1C1E1390AA0294E6B087F5D3EF; Path=/axis
Content-Type: text/xml;charset=utf-8
Transfer-Encoding: chunked
Date: Mon, 12 Mar 2007 20:24:28 GMT
Server: Apache-Coyote/1.1
231
<?xml version="1.0" encoding="utf-8"?><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:ListWorkGroupsRespons e
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://DefaultNamespace"><ListWorkGroupsReturn
soapenc:arrayType="xsd:anyType[0]" xsi:type="soapenc:Array"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"/></ns1:ListWorkGroupsResponse></soapenv:Body></soapenv:Envelope>
0
**** .Net Exception
Exception information:
Type : InvalidOperationException
Source : System.Xml
Link :
Message: There is an error in XML document (1, 501).
Trace :
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle)
at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
at PersonWS.PersonWSService.ListWorkGroups(String strPerson) in
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET
Files\quickservicecall\821bd8ec\e1741ba7\App_WebRe ferences.s_47-nlz.0.cs:line
48
at _Default.ListWorkGroups(String strMnemonic) in
e:\Develop\2.0\Projects\Service Desk\Quick Service Call\Web
Applications\QuickServiceCall\Default.aspx.cs:line 30
at _Default.Page_Load(Object sender, EventArgs e) in
e:\Develop\2.0\Projects\Service Desk\Quick Service Call\Web
Applications\QuickServiceCall\Default.aspx.cs:line 45
at System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object
o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender,
EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Inner exception (1):
Exception information:
Type : InvalidCastException
Source : xnnfxwfg
Link :
Message: Cannot assign object of type System.Object[] to an object of type
PersonWS.WorkGroupData[].
Trace :
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReaderPersonWSService.Read3_ListWorkGr oupsResponse()
at
Microsoft.Xml.Serialization.GeneratedAssembly.Arra yOfObjectSerializer1.Deserialize(XmlSerializationR eader
reader)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)