Click to See Complete Forum and Search --> : Problem with Load method of MSXML.DOMDocument object


Mohit Gupta
10-23-2001, 03:32 AM
I am using SOAP in this particularly simple VB/ASP App.
I am sending the userlogin and password from VB form(VB Client) to ASP and
validating it against the hardcoded values in ASP page. If it matches than
ASP will return +1 else -1. Depending upon this value VB will show me the
message box whether Login succeeded or Failed. The CB client is getting the
proper XML from ASP but while loading it to DOM Document variable its throwing
error.

My VB Client code is as follows -
'**************************************************************************
Option Explicit
Dim objXMLHTTP As New MSXML.XMLHTTPRequest
Dim objOutputXMLDoc As New MSXML.DOMDocument

Private Sub cmdConnect_Click()

Dim strMethodPkg As String
Dim strMethodResultXML As String

Dim iLoginResult As Integer

On Error GoTo ErrorHandler

strMethodPkg = "<SOAP:Envelope xmlns:SOAP=""http://schemas.xmlsoap.org/soap/envelope/"">"
strMethodPkg = strMethodPkg & "<SOAP:Header></SOAP:Header>"
strMethodPkg = strMethodPkg & "<SOAP:Body><m:DoLogin xmlns:m=""urn:soapserver/soap:AuthorizationModule"">"
strMethodPkg = strMethodPkg & "<UserName>" & txtUserName.Text & "</UserName>"
strMethodPkg = strMethodPkg & "<Password>" & txtPassword.Text & "</Password>"
strMethodPkg = strMethodPkg & "</m:DoLogin></SOAP:Body></SOAP:Envelope>"

objXMLHTTP.open "post", "http://localhost/MkgASP/simplesoap.asp", False

objXMLHTTP.setRequestHeader "Content-Type", "text/xml"

objXMLHTTP.setRequestHeader "SOAPAction", "soapserver/soap:AuthorizationModule#DoLogin"

objXMLHTTP.send strMethodPkg

strMethodResultXML = objXMLHTTP.responseText
MsgBox strMethodResultXML

Call objOutputXMLDoc.loadXML(strMethodResultXML)
MsgBox objOutputXMLDoc.xml

iLoginResult = objOutputXMLDoc.selectSingleNode("SOAP:Envelope/SOAP:Body/m:DoLoginResponse/LoginResult").Text

If iLoginResult > 0 Then
MsgBox "Login Successful"
Else
MsgBox "Login Failed!"
End If
Exit Sub

ErrorHandler:
If objOutputXMLDoc.parseError.errorCode <> 0 Then
MsgBox "The Error Code is : " & objOutputXMLDoc.parseError.errorCode
& "and Error Description is : "
Else
' proceed
End If

End Sub


Private Sub cmdExit_Click()
Set objXMLHTTP = Nothing
Set objOutputXMLDoc = Nothing
Unload Me
End Sub
'**************************************************************************

And The ASP Server code is as follows -
'*************************************************************************
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>

<%
Set objXMLDOM = Server.CreateObject("Microsoft.XMLDOM")

objXMLDOM.load Request

varUserName = objXMLDOM.selectSingleNode("SOAP:Envelope/SOAP:Body/m:DoLogin/UserName").Text
varPassword = objXMLDOM.selectSingleNode("SOAP:Envelope/SOAP:Body/m:DoLogin/Password").Text

if varUserName = "PerfectXML" and varPassword = "XML" then
strResult = 1
else
strResult = -1
end if

strResultXML = "<SOAP:Envelope xmlns:SOAP=""http://schemas.xmlsoap.org/soap/envelope/""><SOAP:Header></SOAP:Header>"

strResultXML = strResultXML & "<SOAP:Body><m:DoLoginResponse xmlns:m=""urn:soapserver/soap:AuthorizationModule"">"
strResultXML = strResultXML & "<LoginResult>" & strResult & "</LoginResult></m:DoLoginResponse>"
strResultXML = strResultXML & "</SOAP:Body></SOAP:Envelope>"

Response.Write strResultXML

%>

</BODY>
</HTML>

'***********************************************************************
In VB Client code while loading the XML from string variable i am getting
the following error-
ErrorCode is - -1072896659
Can Someone help me out what this error is.

Regards
Mohit

MarKN
10-23-2001, 07:11 AM
What is the return code when you loadXML()? I think you need to set the content
type in the response object also.

Mark

"Mohit Gupta" <mohit_1012@yahoo.com> wrote:
>
>
>I am using SOAP in this particularly simple VB/ASP App.
>I am sending the userlogin and password from VB form(VB Client) to ASP and
>validating it against the hardcoded values in ASP page. If it matches than
>ASP will return +1 else -1. Depending upon this value VB will show me the
>message box whether Login succeeded or Failed. The CB client is getting
the
>proper XML from ASP but while loading it to DOM Document variable its throwing
>error.
>
>My VB Client code is as follows -
>'**************************************************************************
>Option Explicit
>Dim objXMLHTTP As New MSXML.XMLHTTPRequest
>Dim objOutputXMLDoc As New MSXML.DOMDocument
>
>Private Sub cmdConnect_Click()
>
>Dim strMethodPkg As String
>Dim strMethodResultXML As String
>
>Dim iLoginResult As Integer
>
>On Error GoTo ErrorHandler
>
>strMethodPkg = "<SOAP:Envelope xmlns:SOAP=""http://schemas.xmlsoap.org/soap/envelope/"">"
>strMethodPkg = strMethodPkg & "<SOAP:Header></SOAP:Header>"
>strMethodPkg = strMethodPkg & "<SOAP:Body><m:DoLogin xmlns:m=""urn:soapserver/soap:AuthorizationModule"">"
>strMethodPkg = strMethodPkg & "<UserName>" & txtUserName.Text & "</UserName>"
>strMethodPkg = strMethodPkg & "<Password>" & txtPassword.Text & "</Password>"
>strMethodPkg = strMethodPkg & "</m:DoLogin></SOAP:Body></SOAP:Envelope>"
>
>objXMLHTTP.open "post", "http://localhost/MkgASP/simplesoap.asp", False
>
>objXMLHTTP.setRequestHeader "Content-Type", "text/xml"
>
>objXMLHTTP.setRequestHeader "SOAPAction", "soapserver/soap:AuthorizationModule#DoLogin"
>
>objXMLHTTP.send strMethodPkg
>
>strMethodResultXML = objXMLHTTP.responseText
>MsgBox strMethodResultXML
>
>Call objOutputXMLDoc.loadXML(strMethodResultXML)
>MsgBox objOutputXMLDoc.xml
>
>iLoginResult = objOutputXMLDoc.selectSingleNode("SOAP:Envelope/SOAP:Body/m:DoLoginResponse/LoginResult").Text
>
>If iLoginResult > 0 Then
> MsgBox "Login Successful"
>Else
> MsgBox "Login Failed!"
>End If
>Exit Sub
>
>ErrorHandler:
>If objOutputXMLDoc.parseError.errorCode <> 0 Then
> MsgBox "The Error Code is : " & objOutputXMLDoc.parseError.errorCode
>& "and Error Description is : "
>Else
> ' proceed
>End If
>
>End Sub
>
>
>Private Sub cmdExit_Click()
>Set objXMLHTTP = Nothing
>Set objOutputXMLDoc = Nothing
>Unload Me
>End Sub
>'**************************************************************************
>
>And The ASP Server code is as follows -
>'*************************************************************************
><%@ Language=VBScript %>
><HTML>
><HEAD>
><META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
></HEAD>
><BODY>
>
><%
>Set objXMLDOM = Server.CreateObject("Microsoft.XMLDOM")
>
>objXMLDOM.load Request
>
>varUserName = objXMLDOM.selectSingleNode("SOAP:Envelope/SOAP:Body/m:DoLogin/UserName").Text
>varPassword = objXMLDOM.selectSingleNode("SOAP:Envelope/SOAP:Body/m:DoLogin/Password").Text
>
>if varUserName = "PerfectXML" and varPassword = "XML" then
>strResult = 1
>else
>strResult = -1
>end if
>
>strResultXML = "<SOAP:Envelope xmlns:SOAP=""http://schemas.xmlsoap.org/soap/envelope/""><SOAP:Header></SOAP:Header>"
>
>strResultXML = strResultXML & "<SOAP:Body><m:DoLoginResponse xmlns:m=""urn:soapserver/soap:AuthorizationModule"">"
>strResultXML = strResultXML & "<LoginResult>" & strResult & "</LoginResult></m:DoLoginResponse>"
>strResultXML = strResultXML & "</SOAP:Body></SOAP:Envelope>"
>
>Response.Write strResultXML
>
>%>
>
></BODY>
></HTML>
>
>'***********************************************************************
>In VB Client code while loading the XML from string variable i am getting
>the following error-
>ErrorCode is - -1072896659
>Can Someone help me out what this error is.
>
>Regards
>Mohit
>
>
>