By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,288 Members | 1,148 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,288 IT Pros & Developers. It's quick & easy.

Passing an variant from classic ASP page to a .NET webservice

P: n/a
Hi, I am trying to pass an number from a classic asp webpage to a .NET
webservice.

Because my C# webservice expects an integer and classic ASP uses
variants I keep getting problems with object casts;

In my asp page I have the following code which works fine

HTTP.Open "GET","http://myserver/myService.asmx/LogPerson?ID=100",
False

*IF* I do the following I get an error from the .NET webservice

"System.ArgumentException: Cannot convert to System.Int32. Parameter
name: type ---System.FormatException: Input string was not in a
correct format"

Dim PersonID
PersonID=100
HTTP.Open "GET","http://myserver/myService.asmx/LogPerson?ID=" &
PersonID, False
==========

My signature in the webservice is simply

[WebMethod]
public bool LogPerson(int PersonID)
{
/// some code
return true;
}

I have tried changing my signature to

public bool LogPerson(object PersonID)

and then casting etc but I keep getting casting errors

Any help appreciated
Thanks in advance
MarkusJ
==================================
googlenews2006markusj

Oct 6 '06 #1
Share this Question
Share on Google+
4 Replies

P: n/a
Hello,

If you wan't to read a web service from an asp.net page, you need to format
a soap request, it isn't possible to get an answer with a simple http call.

this is a good way to do it :http://www.eggheadcafe.com/articles/20011103.asp

Draggi


"Ma*******@gmail.com" wrote:
Hi, I am trying to pass an number from a classic asp webpage to a .NET
webservice.

Because my C# webservice expects an integer and classic ASP uses
variants I keep getting problems with object casts;

In my asp page I have the following code which works fine

HTTP.Open "GET","http://myserver/myService.asmx/LogPerson?ID=100",
False

*IF* I do the following I get an error from the .NET webservice

"System.ArgumentException: Cannot convert to System.Int32. Parameter
name: type ---System.FormatException: Input string was not in a
correct format"

Dim PersonID
PersonID=100
HTTP.Open "GET","http://myserver/myService.asmx/LogPerson?ID=" &
PersonID, False
==========

My signature in the webservice is simply

[WebMethod]
public bool LogPerson(int PersonID)
{
/// some code
return true;
}

I have tried changing my signature to

public bool LogPerson(object PersonID)

and then casting etc but I keep getting casting errors

Any help appreciated
Thanks in advance
MarkusJ
==================================
googlenews2006markusj

Oct 6 '06 #2

P: n/a
oh! i'm sorry, i didn't view that you wan't to request from an ASP 3.0 page.

take a look at this page
http://www.codeproject.com/soap/Cons...icefromASP.asp
Fo calling a webservices from an classic ASP page you need to install

"Ma*******@gmail.com" wrote:
Hi, I am trying to pass an number from a classic asp webpage to a .NET
webservice.

Because my C# webservice expects an integer and classic ASP uses
variants I keep getting problems with object casts;

In my asp page I have the following code which works fine

HTTP.Open "GET","http://myserver/myService.asmx/LogPerson?ID=100",
False

*IF* I do the following I get an error from the .NET webservice

"System.ArgumentException: Cannot convert to System.Int32. Parameter
name: type ---System.FormatException: Input string was not in a
correct format"

Dim PersonID
PersonID=100
HTTP.Open "GET","http://myserver/myService.asmx/LogPerson?ID=" &
PersonID, False
==========

My signature in the webservice is simply

[WebMethod]
public bool LogPerson(int PersonID)
{
/// some code
return true;
}

I have tried changing my signature to

public bool LogPerson(object PersonID)

and then casting etc but I keep getting casting errors

Any help appreciated
Thanks in advance
MarkusJ
==================================
googlenews2006markusj

Oct 6 '06 #3

P: n/a
Hi,

Ma*******@gmail.com wrote:
Hi, I am trying to pass an number from a classic asp webpage to a .NET
webservice.

Because my C# webservice expects an integer and classic ASP uses
variants I keep getting problems with object casts;

In my asp page I have the following code which works fine

HTTP.Open "GET","http://myserver/myService.asmx/LogPerson?ID=100",
False
That's not how web services work. Web services are not simple AJAX, they
are SOAP-encoded calls.

On the client, you need to create a POST request, and the request's body
must be compliant with SOAP. SOAP is a XML dialect, which encodes a
remote method call.

If you really want to do that, you need to study SOAP and create a
correctly encoded request. That's a lot of work (I did it for
JavaScript, and it needs a lot of study before getting it to work).
Nowadays, SOAP clients use proxy-generating code to make using web
services easier (.NET with Web references, JavaScript with ATLAS, etc...).

In your case, for something simple as that, I would recommend abandoning
web services and using a ASHX generic HTTP handler on .NET. Then it's
much, much easier to send GET requests to it. The ASHX handler can
return plain text, plain old XML, or whatever you can place into a Response.

See this article I wrote:
http://www.galasoft-lb.ch/mydotnet/a...on-server.aspx

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Oct 6 '06 #4

P: n/a
Thanks for your help everyone.

In the end I just loaded the returned XML into an DOMObject

Set HTTP = CreateObject("MSXML2.XMLHTTP")
Set xmlDOC =CreateObject("MSXML.DOMDocument")
HTTP.Open ...
xmlDOC.load(HTTP.responseXML)

and parsed the DOM object and it works a treat
again, thanks
Markus
Regards
Markus
Laurent Bugnion, GalaSoft wrote:
Hi,

Ma*******@gmail.com wrote:
Hi, I am trying to pass an number from a classic asp webpage to a .NET
webservice.

Because my C# webservice expects an integer and classic ASP uses
variants I keep getting problems with object casts;

In my asp page I have the following code which works fine

HTTP.Open "GET","http://myserver/myService.asmx/LogPerson?ID=100",
False

That's not how web services work. Web services are not simple AJAX, they
are SOAP-encoded calls.

On the client, you need to create a POST request, and the request's body
must be compliant with SOAP. SOAP is a XML dialect, which encodes a
remote method call.

If you really want to do that, you need to study SOAP and create a
correctly encoded request. That's a lot of work (I did it for
JavaScript, and it needs a lot of study before getting it to work).
Nowadays, SOAP clients use proxy-generating code to make using web
services easier (.NET with Web references, JavaScript with ATLAS, etc...).

In your case, for something simple as that, I would recommend abandoning
web services and using a ASHX generic HTTP handler on .NET. Then it's
much, much easier to send GET requests to it. The ASHX handler can
return plain text, plain old XML, or whatever you can place into a Response.

See this article I wrote:
http://www.galasoft-lb.ch/mydotnet/a...on-server.aspx

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Oct 8 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.