J
Julian Hershel
Hi.
I have a very simple web service that I am trying to call from a classic ASP
page. The web service project and the ASP page are both on my development
machine. That's the code of my web service:
<WebService(Namespace:="http://tempuri.org/")> _
Public Class TextData
Inherits System.Web.Services.WebService
<WebMethod(Description:="Simple method")> _
Public Function GetName(ByVal sName As String) As String
Return "The name is: " & sName
End Function
End Class
And in my ASP page I have the following code:
<%Option Explicit
Dim objRequest, objXMLDoc, objXmlNode, strRet, strError
Set objRequest = Server.createobject("MSXML2.XMLHTTP")
With objRequest
.open "GET", "HTTP://tempuri.org/TextData/TextData.asmx", False
.setRequestHeader "Content-Type", "text/xml"
.setRequestHeader "SOAPAction", "HTTP://tempuri.org/GetName"
.send
End With
Set objXMLDoc = Server.createobject("MSXML2.DOMDocument")
objXmlDoc.async = false
If objXMLDoc.LoadXml(objRequest.ResponseXml.Xml) Then
Set objXMLNode = objXMLDoc.SelectSingleNode("GetNameResponse")
If Not objXMLNode Is Nothing then
strRet = objXMLNode.NodeTypedValue
Response.Write("Response: " & sRet)
End If
Else
strError = objXMLDoc.parseError.reason
Response.Write("Error: " & strError)
End If
%>
When I run the ASP page, I receive the error: XML document must have a top
level element.
What do I need to do in order to consume this web service in a classic ASP
page? And why do I need to use tempuri.org instead of localhost, in my
Request?
Thank you,
Julian
I have a very simple web service that I am trying to call from a classic ASP
page. The web service project and the ASP page are both on my development
machine. That's the code of my web service:
<WebService(Namespace:="http://tempuri.org/")> _
Public Class TextData
Inherits System.Web.Services.WebService
<WebMethod(Description:="Simple method")> _
Public Function GetName(ByVal sName As String) As String
Return "The name is: " & sName
End Function
End Class
And in my ASP page I have the following code:
<%Option Explicit
Dim objRequest, objXMLDoc, objXmlNode, strRet, strError
Set objRequest = Server.createobject("MSXML2.XMLHTTP")
With objRequest
.open "GET", "HTTP://tempuri.org/TextData/TextData.asmx", False
.setRequestHeader "Content-Type", "text/xml"
.setRequestHeader "SOAPAction", "HTTP://tempuri.org/GetName"
.send
End With
Set objXMLDoc = Server.createobject("MSXML2.DOMDocument")
objXmlDoc.async = false
If objXMLDoc.LoadXml(objRequest.ResponseXml.Xml) Then
Set objXMLNode = objXMLDoc.SelectSingleNode("GetNameResponse")
If Not objXMLNode Is Nothing then
strRet = objXMLNode.NodeTypedValue
Response.Write("Response: " & sRet)
End If
Else
strError = objXMLDoc.parseError.reason
Response.Write("Error: " & strError)
End If
%>
When I run the ASP page, I receive the error: XML document must have a top
level element.
What do I need to do in order to consume this web service in a classic ASP
page? And why do I need to use tempuri.org instead of localhost, in my
Request?
Thank you,
Julian