473,657 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=10 0",
False

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

"System.Argumen tException: Cannot convert to System.Int32. Parameter
name: type ---System.FormatEx ception: 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(objec t PersonID)

and then casting etc but I keep getting casting errors

Any help appreciated
Thanks in advance
MarkusJ
=============== =============== ====
googlenews2006m arkusj

Oct 6 '06 #1
4 3656
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*******@gmai l.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=10 0",
False

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

"System.Argumen tException: Cannot convert to System.Int32. Parameter
name: type ---System.FormatEx ception: 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(objec t PersonID)

and then casting etc but I keep getting casting errors

Any help appreciated
Thanks in advance
MarkusJ
=============== =============== ====
googlenews2006m arkusj

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*******@gmai l.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=10 0",
False

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

"System.Argumen tException: Cannot convert to System.Int32. Parameter
name: type ---System.FormatEx ception: 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(objec t PersonID)

and then casting etc but I keep getting casting errors

Any help appreciated
Thanks in advance
MarkusJ
=============== =============== ====
googlenews2006m arkusj

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=10 0",
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("M SXML2.XMLHTTP")
Set xmlDOC =CreateObject(" MSXML.DOMDocume nt")
HTTP.Open ...
xmlDOC.load(HTT P.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=10 0",
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
1804
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 info up. My link on the first page (schedule.html) goes to this link: disclaimer.html?customer=238297&EventID=19080 And I have some Javascript in the page which places the link info into the URL:
3
932
by: chris | last post by:
hi how can i pass more than one values from one page to another thanks
0
1466
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
2075
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
261
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
1473
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 number of form controls to accept user input, using the the submit button passes those parameters across to next page in request.form(keyname) fashion ..NET
2
1605
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. Also, how to access or "grab" the Document within the webmethod? Is it just a parameter? I'm also concerned with the size limitations for the XML being passed Any documentation on this that would be great.
2
2764
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
3784
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 techniques are not feasible) The question is; Given that I have a Person object with a private set for id. What is the recommended approac in passing that object to the web service
0
789
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 can be decalred as a variant in .net which is not supported in the .net framework. If I try and do anything with the com interfaces which require a variant intellisense uses the interop mapping and prompts for an object I have tried importing...
0
8421
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.