G
Guest
I am using vbscript for calling my webservice. From vbscript I Post XML
file/argument to webservice. and i get response from webservice.
This is working perfectly when there is no argument. but does not work when
my webmethod(In Webserice) takes argument.
I repeat: When service give me response when webmethod without argument, but
another webmethod with argument does not work.
not sure what is wronge with my code. Code as below
VBSCRIPT :
' VBScript File
'************************************************'
Dim objHttp
dim objXmlDoc
MsgBox("Starting the Calling webservice")
WSController()
MsgBox("End Calling the webservice")
Public Function getDataFromWS(methodName, dataSetName)
Dim wsParamValue
Dim wsParamName
'// create the XML object
Set objXmlDoc = CreateObject("Msxml2.DOMDocument")
'Set objDictionary = CreateObject("Scripting.Dictionary")
If IsNull(objXmlDoc) Then
Msgbox("Unable to create DOM document!")
Else
'// create an XmlHttp instance
Set objHttp = CreateObject("Microsoft.XMLHTTP")
Dim objGetTransferResult
objGetTransferResult = "GetTransferResult"
Dim objDescription
objDescription = "Description"
Dim objTransferID
objTransferID = "TransferID"
'// Create the SOAP Envelope
strEnvelope = "<soap:Envelope
xsi=\http://www.w3.org/2001/XMLSchema-instance\" + "
xsd=\http://www.w3.org/2001/XMLSchema\" + "
soap=\http://schemas.xmlsoap.org/soap/envelope/\>" + " <soap:Body>" + " <" +
methodName + " xmlns=\http://marksandspencer.com\>" + " </" + methodName +
">" +" </soap:Body>" +"</soap:Envelope>"
MsgBox(strEnvelope)
'// Set up the post
objHTTP.onreadystatechange = getRef("LoadAndProcessDocument")
'objHttp.onreadystatechange = Call abc(objHttp,objXmlDoc)
Dim szUrl
szUrl = "http://localhost:1400/wsXMLHTTP/DynaProducts.asmx/" + methodName
If wsParamValue <> null Then
szUrl = szUrl + "?" + wsParamName + "=" + wsParamValue
End If
'// send the POST to the Web service
objHttp.open "POST", szUrl, true
objHttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
objHttp.send strEnvelope
End If
End Function
Public function LoadAndProcessDocument()
' a readyState of 4 means we're ready to use the data returned by XMLHTTP
if objHttp.readystate = 4 then
dim szresponse
szresponse = objHttp.responsetext
objXmlDoc.loadxml(szresponse)
if objXmlDoc.parseerror.errorcode <> 0 then
dim xmlerr
Set xmlerr = objXmlDoc.parseerror
MsgBox("you have error " + xmlerr.reason)
Else
ProcesstheRequest()
'
End If
End If
End Function
Public Function WSController()
MsgBox("I am inside WSController Function")
Dim func
'func = getDataFromWS("GetCategories", "GetCategoriesDS")
func = getDataFromWS("GetTransferResult", "GetTransferResultDS")
'MsgBox("Please wait while data is retrieved...")
'Window.setTimeout func, 1
End Function
Public Function ProcesstheRequest()
'// get an XML data island with the category data
'MsgBox("I will show you Returned XML DOc" + objXmlDoc)
MsgBox(objXmlDoc.text)
'objNodeList = objXmlDoc.getElementsByTagName("Description")
'MsgBox("NodeList Size" + objNodeList.length)
' For i=0 to objNodeList.length
' Dim dataNodeList
' Dim textNode
' Dim valueNode
' dataNodeList = objNodeList(i).childNodes
' MsgBox(dataNodeList.item(0))
' MsgBox(dataNodeList.item(1))
' Next
End Function
'********************************
TWO WEBSERVICE METHODC#,ASP.NET)
[WebMethod]
public string GetTransferResult(string Description, string TransferID)
{
try
{
}
catch
{
// error handling ommitted for brevity
}
finally
{
}
return Description;
}
[WebMethod]
public string GetCategories()
{
return "LABHESHSHRIMALI";
}
How to run: Defind webservice method and run webservice.
give the path of webservice in vbscirpt file and execute the vbscript.
I have taken the reference from following URL (in javascript)
http://support.microsoft.com/kb/893659
Please let me know if you have any problem in understanding my problem.
file/argument to webservice. and i get response from webservice.
This is working perfectly when there is no argument. but does not work when
my webmethod(In Webserice) takes argument.
I repeat: When service give me response when webmethod without argument, but
another webmethod with argument does not work.
not sure what is wronge with my code. Code as below
VBSCRIPT :
' VBScript File
'************************************************'
Dim objHttp
dim objXmlDoc
MsgBox("Starting the Calling webservice")
WSController()
MsgBox("End Calling the webservice")
Public Function getDataFromWS(methodName, dataSetName)
Dim wsParamValue
Dim wsParamName
'// create the XML object
Set objXmlDoc = CreateObject("Msxml2.DOMDocument")
'Set objDictionary = CreateObject("Scripting.Dictionary")
If IsNull(objXmlDoc) Then
Msgbox("Unable to create DOM document!")
Else
'// create an XmlHttp instance
Set objHttp = CreateObject("Microsoft.XMLHTTP")
Dim objGetTransferResult
objGetTransferResult = "GetTransferResult"
Dim objDescription
objDescription = "Description"
Dim objTransferID
objTransferID = "TransferID"
'// Create the SOAP Envelope
strEnvelope = "<soap:Envelope
xsi=\http://www.w3.org/2001/XMLSchema-instance\" + "
xsd=\http://www.w3.org/2001/XMLSchema\" + "
soap=\http://schemas.xmlsoap.org/soap/envelope/\>" + " <soap:Body>" + " <" +
methodName + " xmlns=\http://marksandspencer.com\>" + " </" + methodName +
">" +" </soap:Body>" +"</soap:Envelope>"
MsgBox(strEnvelope)
'// Set up the post
objHTTP.onreadystatechange = getRef("LoadAndProcessDocument")
'objHttp.onreadystatechange = Call abc(objHttp,objXmlDoc)
Dim szUrl
szUrl = "http://localhost:1400/wsXMLHTTP/DynaProducts.asmx/" + methodName
If wsParamValue <> null Then
szUrl = szUrl + "?" + wsParamName + "=" + wsParamValue
End If
'// send the POST to the Web service
objHttp.open "POST", szUrl, true
objHttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
objHttp.send strEnvelope
End If
End Function
Public function LoadAndProcessDocument()
' a readyState of 4 means we're ready to use the data returned by XMLHTTP
if objHttp.readystate = 4 then
dim szresponse
szresponse = objHttp.responsetext
objXmlDoc.loadxml(szresponse)
if objXmlDoc.parseerror.errorcode <> 0 then
dim xmlerr
Set xmlerr = objXmlDoc.parseerror
MsgBox("you have error " + xmlerr.reason)
Else
ProcesstheRequest()
'
End If
End If
End Function
Public Function WSController()
MsgBox("I am inside WSController Function")
Dim func
'func = getDataFromWS("GetCategories", "GetCategoriesDS")
func = getDataFromWS("GetTransferResult", "GetTransferResultDS")
'MsgBox("Please wait while data is retrieved...")
'Window.setTimeout func, 1
End Function
Public Function ProcesstheRequest()
'// get an XML data island with the category data
'MsgBox("I will show you Returned XML DOc" + objXmlDoc)
MsgBox(objXmlDoc.text)
'objNodeList = objXmlDoc.getElementsByTagName("Description")
'MsgBox("NodeList Size" + objNodeList.length)
' For i=0 to objNodeList.length
' Dim dataNodeList
' Dim textNode
' Dim valueNode
' dataNodeList = objNodeList(i).childNodes
' MsgBox(dataNodeList.item(0))
' MsgBox(dataNodeList.item(1))
' Next
End Function
'********************************
TWO WEBSERVICE METHODC#,ASP.NET)
[WebMethod]
public string GetTransferResult(string Description, string TransferID)
{
try
{
}
catch
{
// error handling ommitted for brevity
}
finally
{
}
return Description;
}
[WebMethod]
public string GetCategories()
{
return "LABHESHSHRIMALI";
}
How to run: Defind webservice method and run webservice.
give the path of webservice in vbscirpt file and execute the vbscript.
I have taken the reference from following URL (in javascript)
http://support.microsoft.com/kb/893659
Please let me know if you have any problem in understanding my problem.