Dynamic page updates using XMLHTTP

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 METHOD:(C#,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.
 
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 METHOD:(C#,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.

So, you mean that this is not working?

Dim szUrl
szUrl = "http://localhost:1400/wsXMLHTTP/DynaProducts.asmx/" +
methodName

If wsParamValue <> null Then
szUrl = szUrl + "?" + wsParamName + "=" + wsParamValue
End If

I think you have to change IF..THEN to

If Not wsParamValue Is Nothing Then

and then debug if you have the right szUrl at the end
 
G

Guest

Not Sure what is the problem, but i receive an error when i try to execute
webmethod which has argument[GetTransferResult],
but it work fine when i use webmethod which has no argument[GetCategories()].

Steps:
1. First I uncomment the code for GetGategories() Method in
WSController(),also change the strEnvelop string value for this method and it
works fine. (Note this method does not have argument]
2. Second I try to comment GetCategories() and uncomment GetTransferResult()
with the required SOAP xml. and this does not work work.not sure why.


--
Labhesh Shrimali - MCP
Bangalore - India
9886497756


Anon User said:
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 METHOD:(C#,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.

So, you mean that this is not working?

Dim szUrl
szUrl = "http://localhost:1400/wsXMLHTTP/DynaProducts.asmx/" +
methodName

If wsParamValue <> null Then
szUrl = szUrl + "?" + wsParamName + "=" + wsParamValue
End If

I think you have to change IF..THEN to

If Not wsParamValue Is Nothing Then

and then debug if you have the right szUrl at the end
 
G

Guest

I explain again

I have an aspx site, in which I like to access a webservice (asmx
file) with vbscript. I think it like this:

set xmlHTTP = CreateObject("Msxml2.XMLHTTP")
set xmlDoc = CreateObject("Msxml2.DOMDocument")
sQuery = "http://mshsrmnsisd0086/IS04/Invoke.aspx"
senddata="<is04_service_request><action step='1'><arg name='Description'
value='xxxxx'/><arg name='TransferID'
value='TB0660000001'/></action></is04_service_request>"

xmlHTTP.open "POST", sQuery, false
' on error resume next
xmlHTTP.send(senddata)
' on error goto 0

xmlDoc.async = false
xmlDoc.loadXML(xmlHTTP.responseText)

' Error Handling
if xmlDoc.parseError.errorCode <> 0 Then
'Error handling invalid response or XML not valid
Wscript.echo "oops" & xmlDoc.parseError.errorCode & vbCrLf &
xmlHTTP.responseText
else

'Treat Response
strXMLOUT = xmlDOC.XML
Wscript.echo strXMLOUT
Set xmlDoc = Nothing
Set xmlHTTP = Nothing
end if


In this example the webservice gave back an url, on which the site is
redirected to.

But one problem still occour. When
I try to ask a webservice via get method without any parameters, it
works. But when I try to ask a webservice with methods it hangs.

For example:

url="http://localhost/test.asmx/helloworld"; < this works
url="http://localhost/test.asmx/helloworld?param=test"; < this hangs

The following Message comes:

System.InvalidOperationException
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.Invoke()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

What could be problem?
Thanks for all answers.

Labhesh

--
Labhesh Shrimali - MCP
Bangalore - India
9886497756


Anon User said:
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 METHOD:(C#,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.

So, you mean that this is not working?

Dim szUrl
szUrl = "http://localhost:1400/wsXMLHTTP/DynaProducts.asmx/" +
methodName

If wsParamValue <> null Then
szUrl = szUrl + "?" + wsParamName + "=" + wsParamValue
End If

I think you have to change IF..THEN to

If Not wsParamValue Is Nothing Then

and then debug if you have the right szUrl at the end
 
G

Guest

On Aug 8, 9:04 am, Labhesh Shrimali - Bangalore

Hi Labhesh
xmlHTTP.open "POST", sQuery, false

in a working example you do POST

and in the problem code you do GET

So, what the exact code which returned an error?

url="http://localhost/test.asmx/helloworld?param=test"
Set xmlHTTP = CreateObject("MSXML2.ServerXMLHTTP")
xmlHTTP.Open "GET", url, False
xmlHTTP.Send

Like this?

The message is from .NET, where do you get it?
The following Message comes:

System.InvalidOperationException
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.Invoke()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

Can you post the service description and an asmx, so we can take look?
Does web service return an answer when you type
http://localhost/test.asmx/helloworld?param=test in a browser?
 
G

Guest

Webservice as below *********
[System.Web.Services.WebMethod]
public string GetTransferResult(string TransferID, string Description)
{
try
{

}
catch
{
// error handling ommitted for brevity
}
finally
{
}

return Description;
}

[WebMethod]
public string GetCategories()
{
return "LABHESHSHRIMALI";
}

VB Script Code as below ***************
' VBScript File

Dim objHttp
dim objXmlDoc

MsgBox("Starting the Calling webservice")
WSController()
MsgBox("End Calling the webservice")


Public Function getDataFromWS(methodName, dataSetName, wsParamValue,
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 = "<soap12:Envelope
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xmlns:xsd=http://www.w3.org/2001/XMLSchema
xmlns:soap12=http://www.w3.org/2003/05/soap-envelope> <soap12:Body>
<GetCategories xmlns=http://marksandspencer.com/ />
</soap12:Body></soap12:Envelope>"
'strEnvelope = "<soap12:Envelope
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xmlns:xsd=http://www.w3.org/2001/XMLSchema
xmlns:soap12=http://www.w3.org/2003/05/soap-envelope><soap12:Body><GetTransferResult
xmlns=http://marksandspencer.com/><Description>string</Description><TransferID>string</TransferID></GetTransferResult></soap12:Body></soap12:Envelope>"
'strEnvelope = "<soap12:Envelope
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xmlns:xsd=http://www.w3.org/2001/XMLSchema
xmlns:soap12=http://www.w3.org/2003/05/soap-envelope> <soap12:Body>
<GetTransferResultResponse xmlns=http://marksandspencer.com/>
<GetTransferResultResult>string</GetTransferResultResult>
</GetTransferResultResponse> </soap12:Body></soap12: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
szUrl = szUrl + + "?TransferID=" + wsParamName + "&Description=" +
wsParamValue
Msgbox(szUrl)

If IsEmpty(wsParamValue) Then
szUrl = szUrl + "?" + wsParamName + "=" + wsParamValue
Msgbox("Param not null" + wsParamValue)
Else
Msgbox("Param null" + 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.setRequestHeader "Content-Type", "application/soap+xml;
charset=utf-8"
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
MsgBox(szresponse)
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","AAA","BBBB")
'func = getDataFromWS("GetTransferResult",
"GetTransferResultDS","AA","BB")
'func = getDataFromWS("OneArgument", "OneArgumentOnly")
MsgBox("Please wait while data is retrieved...")
'Window.setTimeout func, 1
idTimer = window.setTimeout("func", 1000, "VBScript")
' window.setTimeout func, 1, "JavaScript"
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)

End Function
 
G

Guest

My Code as below:
WebService Methods: *****************************
[System.Web.Services.WebMethod]
public string GetTransferResult(string TransferID, string Description)
{
try
{

}
catch
{
// error handling ommitted for brevity
}
finally
{
}

return Description;
}
[WebMethod]
public string GetCategories()
{
return "LABHESHSHRIMALI";
}

VBScript files ********************************
' VBScript File

Dim objHttp
dim objXmlDoc

MsgBox("Starting the Calling webservice")
WSController()
MsgBox("End Calling the webservice")


Public Function getDataFromWS(methodName, dataSetName, wsParamValue,
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 = "<soap12:Envelope
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xmlns:xsd=http://www.w3.org/2001/XMLSchema
xmlns:soap12=http://www.w3.org/2003/05/soap-envelope> <soap12:Body>
<GetCategories xmlns=http://marksandspencer.com/ />
</soap12:Body></soap12:Envelope>"
'strEnvelope = "<soap12:Envelope
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xmlns:xsd=http://www.w3.org/2001/XMLSchema
xmlns:soap12=http://www.w3.org/2003/05/soap-envelope><soap12:Body><GetTransferResult
xmlns=http://marksandspencer.com/><Description>string</Description><TransferID>string</TransferID></GetTransferResult></soap12:Body></soap12:Envelope>"
'strEnvelope = "<soap12:Envelope
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xmlns:xsd=http://www.w3.org/2001/XMLSchema
xmlns:soap12=http://www.w3.org/2003/05/soap-envelope> <soap12:Body>
<GetTransferResultResponse xmlns=http://marksandspencer.com/>
<GetTransferResultResult>string</GetTransferResultResult>
</GetTransferResultResponse> </soap12:Body></soap12: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
szUrl = szUrl + + "?TransferID=" + wsParamName + "&Description=" +
wsParamValue
Msgbox(szUrl)

If IsEmpty(wsParamValue) Then
szUrl = szUrl + "?" + wsParamName + "=" + wsParamValue
Msgbox("Param not null" + wsParamValue)
Else
Msgbox("Param null" + 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.setRequestHeader "Content-Type", "application/soap+xml;
charset=utf-8"
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
MsgBox(szresponse)
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","AAA","BBBB")
'func = getDataFromWS("GetTransferResult",
"GetTransferResultDS","AA","BB")
'func = getDataFromWS("OneArgument", "OneArgumentOnly")
MsgBox("Please wait while data is retrieved...")
'Window.setTimeout func, 1
idTimer = window.setTimeout("func", 1000, "VBScript")
' window.setTimeout func, 1, "JavaScript"
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)

End Function

Let me know if you need any other info in understanding the problem.

In webservice there are two methods:
One method works fine which does not have arguemetn. but other give an error
because that has an argument.
and i want to provide the argument to the webservice method.

Plz help me how to achive this.
 

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,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top