File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Consuming a SOAP Vector Type from .Net Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Consuming a SOAP Vector Type from .Net" Watch "Consuming a SOAP Vector Type from .Net" New topic

Consuming a SOAP Vector Type from .Net

wawa piggy

Joined: Apr 05, 2004
Posts: 4
I am new to web services.
I am not sure if this problem should be posted in a .Net forum or Java forum
because it involves a ASP.Net applicaton consuming a Java web service exposed using AXIS.
But I hope i can get some help here.

I have exposed my Java web services to receive a SOAP Vector type and to return results as a SOAP Vector.
Both vectors should contain Arrays of String.
My .net web application need to consume this web service and I have added a web refernce to this Java web services.
From the debug writeline statement below, i can assume "myVector" is initialise correctly before calling the web service.
'========= .NET
Dim arr1 As String() = {"1", "2"} 'an array of String
Dim arr2 As String() = {"3", "4"}
Dim arr3 As String() = {"5", "6"}
'' stockAppl is the project name
'' Enq is the web reference name
'' Vector is the class name
Dim myVector As New stockAppl.Enq.Vector()
myVector.item = Array.CreateInstance(GetType(String()), 3)
myVector.item(0) = arr1
myVector.item(1) = arr2
myVector.item(2) = arr3
'System.Diagnostics.Debug.WriteLine(" *" & myVector.item.GetType().ToString & " *")
'System.Diagnostics.Debug.WriteLine(" *" & myVector.item.Length.ToString & " *")
Dim abc As New stockAppl.Enq.EnquireStockWSService()
Dim myAL2 As stockAppl.Enq.Vector() = abc.EnquireStockWS(myVector)

'========= .NET

But in my Java code, i try to perform the following explicit casting into a java.util.Vector object.
Line 1 : System.out.println(javaVector.getClass().getName());
line 2 : WSRequestVector = (Vector)javaVector;
Though the Line 1 print out "java.util.Vector" Line 2 throws a ClassCastException.

Did i do something wrong here???
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
This belongs in the Web Services forum. Why not just send an array of Strings? Both Java and Net understand array of type string and there are very convenient methods in the Collections API for converting from Vector to an array.
I agree. Here's the link:
subject: Consuming a SOAP Vector Type from .Net
It's not a secret anymore!