Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > passing complex data types with vbscript?

Reply
Thread Tools

passing complex data types with vbscript?

 
 
greg@apba.net
Guest
Posts: n/a
 
      05-26-2006
We have a set of .NET web services to provide access to our data. They
use complex data types for both incoming data and return data. We are
attempting to help another group access this web service from
vbscript/ASP. Is this possible? I have found a few posts scattered
around the internet saying complex data types aren't possible with
vbscript.

Is this true? Can I manually create my XML document in the vbscript,
pass it to the web service, then manually deconstruct the return XML?

Thanks,
Greg

 
Reply With Quote
 
 
 
 
Kirk Allen Evans
Guest
Posts: n/a
 
      05-27-2006
Absolutely, it's possible. Here's the web service:

using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld(PhoneNumber tn)
{
return "Phone number is: (" + tn.NPA + ")" + tn.NXX + "-" + tn.Line;
}
}

public class PhoneNumber
{
private string _npa;
private string _nxx;
private string _line;

public PhoneNumber()
{
}

public PhoneNumber(string npa, string nxx, string line)
{
_npa = npa;
_nxx = nxx;
_line = line;
}


public string NPA
{
get { return _npa; }
set { _npa = value; }
}
public string NXX
{
get { return _nxx; }
set { _nxx = value; }
}


public string Line
{
get { return _line; }
set { _line = value; }
}
}

The following uses JavaScript to call the web service, but the same exact
steps would apply for VBScript. You can concatenate a string, or you can
use the DOM model (more information at
http://support.microsoft.com/kb/893659/).

The following is an HTML file, no ASP.NET or anything involved here (nothing
but client code).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
</head>
<body>
<script language="javascript">
function CallWS(npa, nxx, line)
{
var x;
x = new ActiveXObject("Microsoft.XMLHTTP");

var envelope;
envelope = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soap:Body>" +
"<HelloWorld xmlns=\"http://tempuri.org/\">" +
"<tn>" +
"<NPA>" + npa + "</NPA>" +
"<NXX>" + nxx + "</NXX>" +
"<Line>" + line + "</Line>" +
"</tn>" +
"</HelloWorld>" +
"</soap:Body>" +
"</soap:Envelope>";
// send the POST to the Web service
x.open("POST", "http://localhost:8080/WebSite2/WebService.asmx",
false);
x.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
x.setRequestHeader("SOAPAction", "http://tempuri.org/HelloWorld");
x.send(envelope);
alert(x.responseText);
}
</script>

<button onclick="CallWS('404','555','1212');return false;" />
</body>
</html>


Kirk Allen Evans
Developer Evangelist
Microsoft Corporation
blogs.msdn.com/kaevans
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> We have a set of .NET web services to provide access to our data. They
> use complex data types for both incoming data and return data. We are
> attempting to help another group access this web service from
> vbscript/ASP. Is this possible? I have found a few posts scattered
> around the internet saying complex data types aren't possible with
> vbscript.
>
> Is this true? Can I manually create my XML document in the vbscript,
> pass it to the web service, then manually deconstruct the return XML?
>
> Thanks,
> Greg
>


 
Reply With Quote
 
 
 
 
greg@apba.net
Guest
Posts: n/a
 
      05-27-2006
Thanks for the replies. I hadn't mentioned that it was a SOAP web
service, so I'm glad you included that in your example.

It looks like I will need to construct my SOAP message and body
manually, which is fine.

Thanks for the tip on XML Serialization, I'll look into that also.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
woohoo.. passing complex types to JS with Atlas is working! but is this the only way? sonic ASP .Net Web Services 1 08-25-2006 06:44 PM
equivalent c data types for vc++ data types ramu C Programming 2 02-20-2006 09:33 AM
Can XSD simple types be derived from complex types? Soren Kuula XML 2 12-01-2005 07:51 PM
Union like mechanism for complex data types? Andrey Brozhko XML 0 12-21-2004 12:03 PM
Complex data types in Java Web Service Michael Java 0 09-16-2003 08:07 PM



Advertisments