IntelliJ Java IDE
The moose likes Web Services and the fly likes .net java InvalidCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark ".net java InvalidCastException" Watch ".net java InvalidCastException" New topic
Author

.net java InvalidCastException

kuldeep malhotra
Greenhorn

Joined: May 03, 2005
Posts: 5
Hi i am using apache axis to write web services but when .net calls my service it gives the following error.
System.InvalidCastException: Cannot assign object of type SystemWebService.d31504.organisationdetails to an object of type SystemWebService.d31504.organisationdetails[].

here is the part of my wsdl


<complexType name="OrganisationList">
<sequence>
<element name="id" nillable="true" type="xsd:string"/>
<!--<element name="arrayorganisationDetails" minOccurs="0" maxOccurs="1" nillable="true" type="tns1:arroyorganisationdetails" /> -->
<element name="arrayorganisationDetails" nillable="true" minOccurs="0" maxOccurs="1" type="tns1:ArrayOfString1"/>

</sequence>
</complexType>

<complexType name="ArrayOfString1">
<sequence>
<element minOccurs="0" maxOccurs="unbounded" name="orgstring" nillable="true" type="becta rganisationdetails" />
</sequence>
</complexType>

i am not sure is this the right place to ask my question , any one help.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906

What Axis can send via SOAP with restricted Interoperability
Java Collections
Some of the Collection classes, such as Hashtable, do have serializers, but there is no formal interoperability with other SOAP implementations, and nothing in the SOAP specifications which covers complex objects. The most reliable way to send aggregate objects is to use arrays. In particular, .NET cannot handle them, though many Java SOAP implementations can marshall and unmarshall hash tables.

from Axis User's Guide

What version of axis are you using? There used to be a bug with unbounded arrays Java2WSDL generates invalid WSDL for arrays specified as public members

Seems like your not the first one with these kinds of problems (Web Services in Java Vs C#).

My guess is that the organisationsdetails type from the becta namespace is the culprit.

tool WSDL error

Clearly somewhere a single object is being assigned where an array of objects is expected. Maybe this is relevant:

Dino Chiesa [Microsoft] (VIP)
the WSDL file - how did you generate this? Is it auto-generated by AXIS?

Can you try this: Wrap the array of objects in an object.
Eg, rather than a method signature like this:

MyObject[] WebServiceMethod(RequestMessage req)

Do this:

ResponseMessage WebServiceMethod(RequestMessage req)

where
public ResponseMessage {
MyObject[] ary;
}

-Dino

from Serialization problem, VB.Net Client consuming Java Axis Web Service
and Serialization problem, using .NET client to access Java (Apache Axis) Web Service

Also take a look at axis-dev RE: Wrapped vs. Document

You may have to tweak the WSDL that you are using to generate the .NET proxy's or even modify the generated code

Hope this helps somehow.
[ October 26, 2005: Message edited by: Peer Reynders ]

"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
kuldeep malhotra
Greenhorn

Joined: May 03, 2005
Posts: 5
Tons of thanks,
i have sorted my problem .
Actually i was doing similar things but could get sorted .
Finally this email sorted all.
http://issues.apache.org/bugzilla/show_bug.cgi?id=14152
 
 
subject: .net java InvalidCastException
 
Threads others viewed
XML Schema Problem
Question on axis 1.4 wsdl2java
XML Schema Problem
Help with TypeMapping
Using Axis webservice with a browser or c# client
MyEclipse, The Clear Choice