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

R

ryan.mclean

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/webservi...erName=help&strPassword=please&plainText=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
 
B

bruce barker

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)


| 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&plainText=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
|
 
R

ryan.mclean

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=text"

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
 
R

ryan.mclean

Oops, where I put:

xmlhttp.send xmlhttp.send

That should read:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top