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

Calling a .NET web service from classic ASP w/o soap tookit

P: n/a
Hi everyone! I'm hoping that someone can help me out. I have a
webservice written in vb.net. This service uses the SoapHeader to
secure the webservice to users that give a username and password. I am
trying to call this webservice via classic asp. This works as long as
the service is not authenticated. Here is the asp code:

response.write(GetHTML("http://www5dev.nau.edu/asd/webservices/randomchars/randomchars.asmx/Range?minLength=25&maxLength=35"))

Function GetHTML(strURL)
Dim objXMLHTTP, strReturn
Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.Open "GET", strURL, False
objXMLHTTP.Send
strReturn = objXMLHTTP.responseText
Set objXMLHTTP = Nothing
GetHTML = strReturn
End Function

This call works great unless I try to call the service that requires
header information, I'm not sure how best to attach the header
information. I have tried passing the two variables (strUserName,
strPassword) in the querystring to the service:

response.write(GetHTML("http://www5dev.nau.edu/asd/webservices/tripledes/tripledes.asmx/Encrypt?strUserName=help&strPassword=please&plainT ext=test"))

This does not error, but it does not recognize the header information.

These services work great when being called via .net, the service is
fine (hopefully).

Any help would be greatly appreciated.

Ryan

Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
you are not using soap at all. you are using the html form interface the
asp.net webservices support (which is usually doabled for remote calls). to
pass a soap header you will need to pass a soap body. you can do this with
xmlhttp, but you will need to learn enough of the soap protocal to build the
right body, and pass the correct header.

-- bruce (sqlwork.com)
<ry*********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
| Hi everyone! I'm hoping that someone can help me out. I have a
| webservice written in vb.net. This service uses the SoapHeader to
| secure the webservice to users that give a username and password. I am
| trying to call this webservice via classic asp. This works as long as
| the service is not authenticated. Here is the asp code:
|
|
response.write(GetHTML("http://www5dev.nau.edu/asd/webservices/randomchars/r
andomchars.asmx/Range?minLength=25&maxLength=35"))
|
| Function GetHTML(strURL)
| Dim objXMLHTTP, strReturn
| Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
| objXMLHTTP.Open "GET", strURL, False
| objXMLHTTP.Send
| strReturn = objXMLHTTP.responseText
| Set objXMLHTTP = Nothing
| GetHTML = strReturn
| End Function
|
| This call works great unless I try to call the service that requires
| header information, I'm not sure how best to attach the header
| information. I have tried passing the two variables (strUserName,
| strPassword) in the querystring to the service:
|
|
response.write(GetHTML("http://www5dev.nau.edu/asd/webservices/tripledes/tri
pledes.asmx/Encrypt?strUserName=help&strPassword=please&plainT ext=test"))
|
| This does not error, but it does not recognize the header information.
|
| These services work great when being called via .net, the service is
| fine (hopefully).
|
| Any help would be greatly appreciated.
|
| Ryan
|
Nov 19 '05 #2

P: n/a
Thank you for the response Bruce! I am familiar enough with soap. It
is that I don't understand the interaction between the asp and
webservice. Here is my attempt using the xmlhttp object. I'm hoping
that you or someone else can give me further assistance.

This is the basic function:

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

I then tried to send the username and password using this:

str = _
"<?xml version=""1.0""><soap:Envelope
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & _
"<soap:Header>" & _
"<AuthHeader xmlns=""http://tempuri.org/TripleDES/TripleDES"">" & _
"<strUserName>my_uid</strUserName>" & _
"<strPassword>none_of_your_beezwax</strPassword>" & _
"</AuthHeader>" & _
"</soap:Header>" & _
"<soap:Body>" & _
"<Encrypt xmlns=""http://tempuri.org/TripleDES/TripleDES"">" & _
"<plainText>text</plainText>" & _
"</Encrypt>" & _
"</soap:Body>" & _
"</soap:Envelope>"

set x=Server.createObject("MSXML2.DOMDocument")
x.async=false
x.load str

(I got the xml from when I test the webservice, this seems to be the
format it would like)

and modifying this line:
xmlhttp.send

to be:
xmlhttp.send x

This did not work, it did not recognize the nodes in the xml (Missing
parameter: plainText).

I've also tried changing the line:

xmlhttp.send

to be:
xmlhttp.send xmlhttp.send
"strUserName=my_uid&strPassword=pass&plainText=tex t"

and get the same Missing parameter: plainText error

When I try to send the three arguments using the querystring, I get no
error, but it is not authenticating either . . .

At this point, I'm hoping that I am correct in my assumption that if
the web service call works correctly in asp.net, that the problem is
not with the webservice. I feel like I am floundering around . . .
Thanks again.

More help would be greatly appreciated.

Ryan

Nov 19 '05 #3

P: n/a
Oops, where I put:

xmlhttp.send xmlhttp.send

That should read:

xmlhttp.send
"strUserNamemy_uid&strPassword=none_of_your_beezwa x&plainText=text"
Thanks!
Ryan

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.