Pass array via SOAP from asp page to dotnet webservice

J

Jon Maz

Hi,

I am trying to pass an array from an asp page (JScript) to a dotnet web
service using the SOAP Toolkit 3.0. This is still at the Hello World stage,
as you can see:

WEB SERVICE METHOD

[WebMethod]
public string AcceptArray(object[] parameters)
{
return "no error!!!";
}

Can anyone post a very simple, working example of how the .asp page can pass
the array? Below you can see as far as I got, and the error message I'm
getting:

ASP PAGE

<%@ Language="JScript" %>
<%
var mySoapClient = Server.CreateObject("MSSOAP.SoapClient30");
mySoapClient.ClientProperty("ServerHTTPRequest") = true;

var myArray = new Array(0);
myArray[0] = "hallo";

mySoapClient.MSSoapInit("http://mywebservice/test.asmx?wsdl");
var answer = mySoapClient.AcceptArray(myArray);

Response.Write(answer);

//tidy up
mySoapClient = null;
%>

ERROR MESSAGE

Error Type: Client (0x80020005)
Client:Type conversion failure for element parameters
HRESULT=0x80020005:
Type mismatch. - Client:Unspecified client error.
HRESULT=0x80020005:

TIA

JON
 
C

Chad Z. Hower aka Kudzu

Jon Maz said:
[WebMethod]
public string AcceptArray(object[] parameters)
{
return "no error!!!";
}

You cant just simply pass objects. Everything has to be seriliazible and the
type known. Pass strings instead of objects. Im not sure if string[] will
work or not, but you can try it. string for sure will work.
 
J

Jon Maz

Hi,

Thanks for your reply.

Changing to string[] as follows does NOT work:

[WebMethod]
public string AcceptArray(string[] parameters)
{
return "no error!!!";
}

Same error as before:
Error Type: Client (0x80020005)
Client:Type conversion failure for element parameters
HRESULT=0x80020005: Type mismatch. - Client:Unspecified client error.
HRESULT=0x80020005: Type mismatch.

I know that string will work, but I really want to pass an *array*. Any
ideas?

TIA,

JON
 
C

Chad Z. Hower aka Kudzu

Jon Maz said:
I know that string will work, but I really want to pass an *array*. Any
ideas?

I dont think arrays are serializable off hand. Use a collection instead, but
make sure its typed to a string.
 
J

Jon Maz

Hi Chad,

Nice idea, but unfortunately not applicable to this scenario... Remember,
I'm going FROM classic asp (the web page calling the webservice via SOAP) TO
dotnet (the .asmx). In classic asp (AFAIK) all I *have* is simple arrays,
and there is no typing at all.

I assumed this must be a simple thing to do, but I've been searching the net
for days and haven't come up with a solution yet...

:-(

JON
 
J

Jon Maz

Hi All,

Well, some progress. Have defeated the evil error message, but don't quite
understand how/why:

ASP PAGE
<%@ Language="JScript" %>
<%
var mySoapClient = Server.CreateObject("MSSOAP.SoapClient30");
mySoapClient.ClientProperty("ServerHTTPRequest") = true;

var myArray = new Array(0);
myArray[0] = "hallo";
myArray[1] = "goodbye";

var myArrayTwo = new Array(0);
myArrayTwo[0] = "nuts";
myArrayTwo[1] = "squirrel";

mySoapClient.MSSoapInit("http://mywebservice/test.asmx?wsdl");
var answer = mySoapClient.AcceptArray(myArray, myArrayTwo);
Response.Write(answer);

//tidy up
mySoapClient = null;
%>

WEB SERVICE
[WebMethod]
public string AcceptArray(string myArray, string myArrayTwo)
{
return myArray + " ????? " + myArrayTwo;
}


and I get this:

hallo,goodbye ????? nuts,squirrel

In other words, the classic asp array is being converted (god knows where)
into a comma-delimited string!

Can anyone explain??

TIA,

JON
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top