hb2web
asked on
Connecting to an ASP.NET web service with classic ASP
I'm trying to connect to a ASP.NET web service from a classic ASP page.
I orignally tried it with the SOAP toolkit, but some of the webservice routines return custom datatypes.
I found a class on experts-exchange for ASP that should be working, but it's not.
Next 2 posts will include the source and the request being sent repectively.
It sends the request, then gets stuck. I have to restart IIS in order to run the page again.
Any relevant help would be spectacular..... and rewarded with 500 points.
I orignally tried it with the SOAP toolkit, but some of the webservice routines return custom datatypes.
I found a class on experts-exchange for ASP that should be working, but it's not.
Next 2 posts will include the source and the request being sent repectively.
It sends the request, then gets stuck. I have to restart IIS in order to run the page again.
Any relevant help would be spectacular..... and rewarded with 500 points.
ASKER
xml being sent to the webservice (strSOAPBody). This ran through a function that replaced < with { and > with } for legibility in a browser (aka ghettoness).
----------------------
{?xml version="1.0" encoding="utf-8"?} {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:Body} {HelloWorld xmlns="http://cletus/ss_webservice/ss_webservice"} {txtinput}testing{/txtinpu t} {/HelloWorld} {/soap:Body} {/soap:Envelope}
----------------------
{?xml version="1.0" encoding="utf-8"?} {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:Body} {HelloWorld xmlns="http://cletus/ss_webservice/ss_webservice"} {txtinput}testing{/txtinpu
ASKER
ASKER
I changed
Set objXmlHTTP = Server.CreateObject("Msxml 2.XMLHTTP. 4.0")
to
Set objXmlHTTP = Server.CreateObject("Msxml 2.XMLHTTP" )
And I'm now getting a response back.
Can anyone tell me what's the difference between the two versions, do i have to use 4? (it is installed on the server) and how to get it to work with 4?
Set objXmlHTTP = Server.CreateObject("Msxml
to
Set objXmlHTTP = Server.CreateObject("Msxml
And I'm now getting a response back.
Can anyone tell me what's the difference between the two versions, do i have to use 4? (it is installed on the server) and how to get it to work with 4?
ASKER
MODS:
I'm able to do what I need with the lower version of msXML. Please close this question and refund points
I'm able to do what I need with the lower version of msXML. Please close this question and refund points
sorry you didnt get any replies originally, but glad you got it working. the mods dont usually check these questions. the way to close questions is to post in community support to bring their attention to it.
https://www.experts-exchange.com/Community_Support/
here is the help page for closing questions:
https://www.experts-exchange.com/help.jsp#hs5
https://www.experts-exchange.com/Community_Support/
here is the help page for closing questions:
https://www.experts-exchange.com/help.jsp#hs5
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
PAQ with the points refunded.
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
Huji
EE Cleanup Volunteer
I will leave the following recommendation for this question in the Cleanup topic area:
PAQ with the points refunded.
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
Huji
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
--------------------------
Class SoapRequest
'Initialize Variables
Private objXmlHTTP
Private strSoapBody
Private strNameSpace
Private strEndPoint
Private strMethod
Private strURL
Private strStructNameSpace
Private bRequestSent
Private bResponseReceived
Private bInsideStructure
Private strResponseText
Private Sub Class_Initialize
Set objXmlHTTP = Server.CreateObject("Msxml
strSoapBody = ""
strNameSpace = ""
strEndPoint = ""
strMethod = ""
strURL = ""
strStructNameSpace = ""
bRequestSent = false
bResponseReceived = false
bInsideStructure = false
strResponseText = ""
End Sub
Public Sub OpenHTTPConnection(Method,
strMethod = Method
strURL = URL
strNameSpace = NameSpace
strEndPoint = EndPoint
End Sub
Private Sub AddHeader(Header, Value)
objXmlHTTP.setRequestHeade
response.write header & ":" & value & "<br>"
End Sub
Public Sub StartBody()
strSoapBody = "<?xml version=""1.0"" encoding=""utf-8""?>" & vbCrLf
strSoapBody = strSoapBody & "<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/"">" & vbCrLf
strSoapBody = strSoapBody & "<soap:Body>" & vbCrLf
strSoapBody = strSoapBody & "<" & strEndPoint & " xmlns=""" & strNameSpace & """>" & vbCrLf
End Sub
Public Sub StartStruct(Name,StructNam
strSoapBody = strSoapBody & "<" & Name & ">" & vbCrLf
strStructNameSpace = StructNameSpace
bInsideStructure = true
End Sub
Public Sub AddMember(Name,Value)
if bInsideStructure and Len(strStructNameSpace) > 0 then
strSoapBody = strSoapBody & "<" & Name & " xmlns=""" & strStructNameSpace & """>" & Value & "</" & Name & ">" & vbCrLf
else
strSoapBody = strSoapBody & "<" & Name & ">" & Value & "</" & Name & ">" & vbCrLf
end if
End Sub
Public Sub EndStruct(Name)
strSoapBody = strSoapBody & "</" & Name & ">" & vbCrLf
strStructNameSpace = ""
bInsideStructure = false
End Sub
Public Sub EndBody()
strSoapBody = strSoapBody & "</" & strEndPoint & ">" & vbCrLf
strSoapBody = strSoapBody & "</soap:Body>" & vbCrLf
strSoapBody = strSoapBody & "</soap:Envelope>"
End Sub
Public Sub SendRequest()
if not bRequestSent then
response.write "<br>" & "strMethod: " & strMethod & "<br>"
response.write "<br>" & "strURL: " & strURL & "<br>"
response.flush
objXmlHTTP.open strMethod, strURL, false
AddHeader "Host", "127.0.0.1"
AddHeader "Content-Type", "text/xml"
if Right(strNameSpace,1) = "/" then
AddHeader "SOAPAction", strNameSpace & strEndPoint
else
AddHeader "SOAPAction", strNameSpace & "/" & strEndPoint
end if
xmlRW "SendRequest Body", strSoapBody
response.flush
objXmlHTTP.send strSoapBody
bRequestSent = true
response.write "<br>Request Sent<br>"
strResponseText = objXmlHTTP.responseText
response.write "<br>Response Received<br>"
bResponseReceived = true
end if
End Sub
Public Function GetResults()
if bRequestSent then
GetResults = strResponseText
else
GetResults = ""
end if
End Function
Public Function Extract(Name)
Extract = ""
if bResponseReceived then
if Instr(strResponseText,Name
Extract = Mid(strResponseText,( Instr( Instr(strResponseText,Name
if Len(Extract) > 0 then
if Left(Name,1) = "b" then
Extract = CBool(Extract)
elseif Left(Name,1) = "d" then
Extract = CDbl(Extract)
elseif Left(Name,1) = "i" then
Extract = CInt(Extract)
end if
end if
end if
end if
End Function
Public Function GetSoapBody()
GetSoapBody = strSoapBody
End Function
Private Sub Class_Terminate
Set objXmlHTTP = nothing
End Sub
End Class
response.write "top of form" &"<br>"
response.flush
Set objSoapRequest = New SoapRequest
response.write "<br>newsoap ran<br>"
response.flush
objSoapRequest.OpenHTTPCon
response.write "<br>OpenHTTPConnection ran<br>"
response.flush
objSoapRequest.StartBody()
response.write "<br>StartBody ran<br>"
response.flush
objSoapRequest.AddMember "txtinput", "testing"
response.write "<br>AddMember ran<br>"
response.flush
objSoapRequest.EndBody()
response.write "<br>endbody ran<br>"
response.flush
objSoapRequest.SendRequest
response.write "<br>sendrequest ran<br>"
response.flush
response.write "<br>Results<hr noshade> " & objSoapRequest.Getresults & "<br><hr noshade>"
'to pull values from the response
'somevar = objSoapRequest.Extract("bA
objSoapRequest = Nothing