468,268 Members | 1,753 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,268 developers. It's quick & easy.

Error consuming a web service in axis

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)


Mar 12 '07 #1
3 5807
"Jeremy Chapman" <no****@please.comwrote in message
news:ul**************@TK2MSFTNGP04.phx.gbl...
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.
You should try a few things. First, please enclose the .NET proxy code that
is causing the error.

Second, try consuming an array of int to see if the problem is "array" or
"of class".

John
Mar 12 '07 #2
I added a method that returns an array of int and I can call that method
fine from my .net app.

As for the proxy code, this is an asp.net 2.0 app I'm consuming from, so
most proxy code is done somehow behind the scenes which I can't seem to get
to decided to consume it from a .net windows app, which generates the same
error, and does let me see the proxy code, so I included that below.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

//
// This source code was auto-generated by Microsoft.VSDesigner, Version
2.0.50727.42.
//
#pragma warning disable 1591

namespace WindowsApplication1.PersonWS {
using System.Diagnostics;
using System.Web.Services;
using System.ComponentModel;
using System.Web.Services.Protocols;
using System;
using System.Xml.Serialization;
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Web.Services",
"2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Web.Services.WebServiceBindingAttribute(Nam e="PersonWSSoapBinding",
Namespace="http://dc1serv306:8080/axis/PersonWS.jws")]
[System.Xml.Serialization.SoapIncludeAttribute(type of(WorkGroupData))]
public partial class PersonWSService :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {

private System.Threading.SendOrPostCallback TestOperationCompleted;

private System.Threading.SendOrPostCallback
ListWorkGroupsOperationCompleted;

private bool useDefaultCredentialsSetExplicitly;

/// <remarks/>
public PersonWSService() {
this.Url =
global::WindowsApplication1.Properties.Settings.De fault.WindowsApplication1_PersonWS_PersonWSService ;
if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
this.UseDefaultCredentials = true;
this.useDefaultCredentialsSetExplicitly = false;
}
else {
this.useDefaultCredentialsSetExplicitly = true;
}
}

public new string Url {
get {
return base.Url;
}
set {
if ((((this.IsLocalFileSystemWebService(base.Url) == true)
&& (this.useDefaultCredentialsSetExplicitly ==
false))
&& (this.IsLocalFileSystemWebService(value) ==
false))) {
base.UseDefaultCredentials = false;
}
base.Url = value;
}
}

public new bool UseDefaultCredentials {
get {
return base.UseDefaultCredentials;
}
set {
base.UseDefaultCredentials = value;
this.useDefaultCredentialsSetExplicitly = true;
}
}

/// <remarks/>
public event TestCompletedEventHandler TestCompleted;

/// <remarks/>
public event ListWorkGroupsCompletedEventHandler
ListWorkGroupsCompleted;

/// <remarks/>
[System.Web.Services.Protocols.SoapRpcMethodAttribu te("",
RequestNamespace="http://DefaultNamespace",
ResponseNamespace="http://dc1serv306:8080/axis/PersonWS.jws")]
[return:
System.Xml.Serialization.SoapElementAttribute("Tes tReturn")]
public int[] Test(string strPerson) {
object[] results = this.Invoke("Test", new object[] {
strPerson});
return ((int[])(results[0]));
}

/// <remarks/>
public void TestAsync(string strPerson) {
this.TestAsync(strPerson, null);
}

/// <remarks/>
public void TestAsync(string strPerson, object userState) {
if ((this.TestOperationCompleted == null)) {
this.TestOperationCompleted = new
System.Threading.SendOrPostCallback(this.OnTestOpe rationCompleted);
}
this.InvokeAsync("Test", new object[] {
strPerson}, this.TestOperationCompleted, userState);
}

private void OnTestOperationCompleted(object arg) {
if ((this.TestCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEvent Args
invokeArgs =
((System.Web.Services.Protocols.InvokeCompletedEve ntArgs)(arg));
this.TestCompleted(this, new
TestCompletedEventArgs(invokeArgs.Results, invokeArgs.Error,
invokeArgs.Cancelled, invokeArgs.UserState));
}
}

/// <remarks/>
[System.Web.Services.Protocols.SoapRpcMethodAttribu te("",
RequestNamespace="http://DefaultNamespace",
ResponseNamespace="http://dc1serv306:8080/axis/PersonWS.jws")]
[return:
System.Xml.Serialization.SoapElementAttribute("Lis tWorkGroupsReturn")]
public WorkGroupData[] ListWorkGroups(string strPerson) {
object[] results = this.Invoke("ListWorkGroups", new object[] {
strPerson});
return ((WorkGroupData[])(results[0]));
}

/// <remarks/>
public void ListWorkGroupsAsync(string strPerson) {
this.ListWorkGroupsAsync(strPerson, null);
}

/// <remarks/>
public void ListWorkGroupsAsync(string strPerson, object userState)
{
if ((this.ListWorkGroupsOperationCompleted == null)) {
this.ListWorkGroupsOperationCompleted = new
System.Threading.SendOrPostCallback(this.OnListWor kGroupsOperationCompleted);
}
this.InvokeAsync("ListWorkGroups", new object[] {
strPerson}, this.ListWorkGroupsOperationCompleted,
userState);
}

private void OnListWorkGroupsOperationCompleted(object arg) {
if ((this.ListWorkGroupsCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEvent Args
invokeArgs =
((System.Web.Services.Protocols.InvokeCompletedEve ntArgs)(arg));
this.ListWorkGroupsCompleted(this, new
ListWorkGroupsCompletedEventArgs(invokeArgs.Result s, invokeArgs.Error,
invokeArgs.Cancelled, invokeArgs.UserState));
}
}

/// <remarks/>
public new void CancelAsync(object userState) {
base.CancelAsync(userState);
}

private bool IsLocalFileSystemWebService(string url) {
if (((url == null)
|| (url == string.Empty))) {
return false;
}
System.Uri wsUri = new System.Uri(url);
if (((wsUri.Port >= 1024)
&& (string.Compare(wsUri.Host, "localHost",
System.StringComparison.OrdinalIgnoreCase) == 0))) {
return true;
}
return false;
}
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Xml",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.SoapTypeAttribute(Namespa ce="http://openview.comp.ca")]
public partial class WorkGroupData {

private string nameField;

private string searchCodeField;

/// <remarks/>
[System.Xml.Serialization.SoapElementAttribute(IsNu llable=true)]
public string Name {
get {
return this.nameField;
}
set {
this.nameField = value;
}
}

/// <remarks/>
[System.Xml.Serialization.SoapElementAttribute(IsNu llable=true)]
public string SearchCode {
get {
return this.searchCodeField;
}
set {
this.searchCodeField = value;
}
}
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Web.Services",
"2.0.50727.42")]
public delegate void TestCompletedEventHandler(object sender,
TestCompletedEventArgs e);

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Web.Services",
"2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
public partial class TestCompletedEventArgs :
System.ComponentModel.AsyncCompletedEventArgs {

private object[] results;

internal TestCompletedEventArgs(object[] results, System.Exception
exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
}

/// <remarks/>
public int[] Result {
get {
this.RaiseExceptionIfNecessary();
return ((int[])(this.results[0]));
}
}
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Web.Services",
"2.0.50727.42")]
public delegate void ListWorkGroupsCompletedEventHandler(object sender,
ListWorkGroupsCompletedEventArgs e);

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Web.Services",
"2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
public partial class ListWorkGroupsCompletedEventArgs :
System.ComponentModel.AsyncCompletedEventArgs {

private object[] results;

internal ListWorkGroupsCompletedEventArgs(object[] results,
System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
}

/// <remarks/>
public WorkGroupData[] Result {
get {
this.RaiseExceptionIfNecessary();
return ((WorkGroupData[])(this.results[0]));
}
}
}
}


"John Saunders" <john.saunders at trizetto.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
"Jeremy Chapman" <no****@please.comwrote in message
news:ul**************@TK2MSFTNGP04.phx.gbl...
>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.

You should try a few things. First, please enclose the .NET proxy code
that is causing the error.

Second, try consuming an array of int to see if the problem is "array" or
"of class".

John


Mar 12 '07 #3
"Jeremy Chapman" <no****@please.comwrote in message
news:eh*************@TK2MSFTNGP04.phx.gbl...
>I added a method that returns an array of int and I can call that method
fine from my .net app.

As for the proxy code, this is an asp.net 2.0 app I'm consuming from, so
most proxy code is done somehow behind the scenes which I can't seem to
get to decided to consume it from a .net windows app, which generates the
same error, and does let me see the proxy code, so I included that below.
I didn't see anything blatantly wrong with the proxy code. Are you able to
find the line of code that the exception references?

John
Mar 13 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Samudrala | last post: by
reply views Thread by Jamie Phillips | last post: by
reply views Thread by Abhijit Salvi | last post: by
1 post views Thread by leslie_tighe | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.