p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Professional (http://p2p.wrox.com/forumdisplay.php?f=63)
-   -   Posting data from ASP to WebService (http://p2p.wrox.com/showthread.php?t=80781)

ampo September 2nd, 2010 02:11 AM

Posting data from ASP to WebService
 
Hi.



How can I send string from classic ASP to .Net web service?



Thanks.

J_P October 31st, 2010 12:54 PM

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


Old Pedant October 31st, 2010 07:02 PM

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.

Old Pedant October 31st, 2010 07:03 PM

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.

J_P October 31st, 2010 09:14 PM

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.

Old Pedant November 1st, 2010 03:12 PM

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.

J_P November 2nd, 2010 02:41 PM

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...

Old Pedant November 2nd, 2010 04:20 PM

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.

J_P November 2nd, 2010 05:03 PM

Quote:

Originally Posted by Old Pedant (Post 265145)
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.

Old Pedant November 2nd, 2010 05:12 PM

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.


All times are GMT -4. The time now is 02:27 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.