 |
| Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 2nd, 2010, 02:11 AM
|
|
Registered User
|
|
Join Date: Aug 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Posting data from ASP to WebService
Hi.
How can I send string from classic ASP to .Net web service?
Thanks.
|
|

October 31st, 2010, 12:54 PM
|
|
Authorized User
|
|
Join Date: May 2009
Posts: 12
Thanks: 0
Thanked 1 Time in 1 Post
|
|
it doesn't matter what type of code the webservice uses.
ASP can send the string as a querystring via the url.
Code:
function GetIt(strUrl)
Dim xmlhttp
Set xmlhttp=Server.CreateObject("MSXML2.ServerXMLHTTP" )
xmlhttp.open "GET",strUrl,false
xmlhttp.send
GetIt = xmlhttp.responseText
Set xmlhttp=nothing
end function
|
|

October 31st, 2010, 07:02 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
|
|
Not true, at all.
If the Web Service is using SOAP, which 99.5% of all ASP.NET Web Services do (because that's what the ASP.NET framework automatically creates for you when you ask for a Web Service) then you
(a) can *NOT* use "GET"; you MUST use "POST"
(b) MUST send a CORRECTLY FORMATTED request, using XML notation, with the XML parameters, etc., that the SOAP service is expecting.
It's not easy. But it can be done.
Google for "SOAP via classic ASP" or something to that effect.
|
|

October 31st, 2010, 07:03 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
|
|
Oh, yes...and the response you will receive will *ALSO* be in SOAP format. So you will need to learn to use the XML DOM to read it.
|
|

October 31st, 2010, 09:14 PM
|
|
Authorized User
|
|
Join Date: May 2009
Posts: 12
Thanks: 0
Thanked 1 Time in 1 Post
|
|
not that big of a deal - use post if you wish...
sending xml is just as easy as sending a string and so is receiving it...
I've done it with simple code as shown above.
|
|

November 1st, 2010, 03:12 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
|
|
LOL! Well, sure, if you have used XML quite a bit. But I'm assuming that anyone newbie enough to need to ask the question will be utterly lost when it comes to creating a proper SOAP request. Possibly even lost when it comes to handling the XML response.
As for "use post if you wish": Depending on how big the request needs to be, you may have no choice. And certainly won't have a choice if the ASP.NET code is *ONLY* looking for posted data.
|
|

November 2nd, 2010, 02:41 PM
|
|
Authorized User
|
|
Join Date: May 2009
Posts: 12
Thanks: 0
Thanked 1 Time in 1 Post
|
|
I rarely use XML.
This is just not that complicated. Stop trying to make it sound like rocket science. It's as simple as it looks in the code example above.
If the OP has problems with xml they will post another question - likely to the XML forums...
|
|

November 2nd, 2010, 04:20 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
|
|
And clearly you've never used a stanadard ASP.NET Web Service. Or a SOAP Web Service, at all.
http://www.w3schools.com/webservices...nheitToCelsius
Granted, that shows using an HTTP Post, but that's only possible with really really simple web services. The two SOAP versions are much more typical.
Well, we shall see if and when the OP comes back.
|
|

November 2nd, 2010, 05:03 PM
|
|
Authorized User
|
|
Join Date: May 2009
Posts: 12
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Quote:
Originally Posted by Old Pedant
And clearly you've never used a stanadard ASP.NET Web Service. Or a SOAP Web Service, at all....
|
You make a lot of assumptions. A bad habit.
|
|

November 2nd, 2010, 05:12 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
|
|
I will withdraw the comment. But for the rest I'll still wait to see what the OP intended. It would have been helpful if he'd shown the web service he wanted to query.
|
|
 |