473,382 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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

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
4 3633
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: CHouck | last post by:
I have what seems to be a simple problem but I can't figure it out. I have a page where I have a link with variables built in which I want to pass through the URL so another page can pick the...
3
by: chris | last post by:
hi how can i pass more than one values from one page to another thanks
0
by: Costa Lino | last post by:
Hi all, I have a webservice with 2 method public int AddUpdateTask(eurosmallbiz.FrameWork.Systems.Calendar.Task task,string username,string password,int companyid,string SyncRule)
0
by: sathya.krishnamurthy | last post by:
Hello Everybody I have an C++ COM DLL with the following implementation. __interface ICPM : IDispatch { HRESULT GlobalComputeClass ( VARIANT *inArr, double *pval); }
0
by: Dexter J. Le Blanc Jr. | last post by:
does anyone have a code sniplete for this? Im trying to except xml data in a webservice. then import it into a dataset process and pass back as a resultset
8
by: only_me | last post by:
Having a bit of trouble here moving to .net. very familiar with the classic ASP way of doing things but can't quite see the wood for the trees here in ..net Classic ASP On a form you have a...
2
by: Dave | last post by:
How can you pass an entire XML Document to a webservice (do you do this with a SOAP envelope body?). Say a supplier sends or posts the entire updated product & price list to your webservice. ...
2
by: SivaprakashShanmugam | last post by:
Hi, I have an Activex control with VARIANT* parameter type. I want to pass an Array from CSharp to that parameter how can i pass it.
9
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting...
0
by: ElTel | last post by:
Hi I am using both VB.2005 express and professional and need to access a COM server which requires a variant paramter. I have referenced the com dll and have seen some examples where a variable...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.