Psst! Did you know DevelopmentNow is a mobile web site design agency?

Contact us for help mobilizing your site, or to sign up for our beta Mobile Web SDK!
all groups > inetserver asp general > june 2009 >

inetserver asp general : Pass array via SOAP from asp page to dotnet webservice


Jon Maz
6/2/2005 12:00:00 AM
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



Jon Maz
6/6/2005 12:00:00 AM
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





Davide
6/30/2009 3:16:45 PM
Easy way to resolve that: use split's function.

Example:



public class StringSplit {
public static void main(String args[]) throws Exception{
new StringSplit().doit();
}

public void doit() {
String s3 = "Real-How-To";
String [] temp = null;
temp = s3.split("-");
dump(temp);
}

public void dump(String []s) {
System.out.println("------------");
for (int i = 0 ; i < s.length ; i++) {
System.out.println(s[i]);
}
System.out.println("------------");
}
}

/*
output :
------------
Real
How
To
------------
*/



Reference: (more examples)
http://www.rgagnon.com/javadetails/java-0438.html



From http://www.developmentnow.com/g/62_2005_6_0_0_534422/Pass-array-via-SOAP-from-asp-page-to-dotnet-webservice.htm

Posted via DevelopmentNow.com Groups
AddThis Social Bookmark Button