Dynamic page updates using XMLHTTP

Discussion in 'ASP .Net' started by =?Utf-8?B?TGFiaGVzaCBTaHJpbWFsaSAtIEJhbmdhbG9yZQ==, Aug 7, 2007.

  1. 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.

    --
    Labhesh Shrimali - MCP
    Mumbai-Bangalore - India
    9833952909
    =?Utf-8?B?TGFiaGVzaCBTaHJpbWFsaSAtIEJhbmdhbG9yZQ==, Aug 7, 2007
    #1
    1. Advertising

  2. On Aug 7, 9:30 am, Labhesh Shrimali - Bangalore
    <> wrote:
    > 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.
    >
    > --
    > Labhesh Shrimali - MCP
    > Mumbai-Bangalore - India
    > 9833952909


    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
    Alexey Smirnov, Aug 7, 2007
    #2
    1. Advertising

  3. 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


    "Alexey Smirnov" wrote:

    > On Aug 7, 9:30 am, Labhesh Shrimali - Bangalore
    > <> wrote:
    > > 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.
    > >
    > > --
    > > Labhesh Shrimali - MCP
    > > Mumbai-Bangalore - India
    > > 9833952909

    >
    > 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
    >
    >
    =?Utf-8?B?TGFiaGVzaCBTaHJpbWFsaSAtIEJhbmdhbG9yZQ==, Aug 7, 2007
    #3
  4. 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


    "Alexey Smirnov" wrote:

    > On Aug 7, 9:30 am, Labhesh Shrimali - Bangalore
    > <> wrote:
    > > 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.
    > >
    > > --
    > > Labhesh Shrimali - MCP
    > > Mumbai-Bangalore - India
    > > 9833952909

    >
    > 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
    >
    >
    =?Utf-8?B?TGFiaGVzaCBTaHJpbWFsaSAtIEJhbmdhbG9yZQ==, Aug 8, 2007
    #4
  5. On Aug 8, 9:04 am, Labhesh Shrimali - Bangalore
    <> wrote:

    Hi Labhesh

    > xmlHTTP.open "POST", sQuery, false


    in a working example you do POST

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


    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?
    Alexey Smirnov, Aug 8, 2007
    #5
  6. 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


    --
    Labhesh Shrimali - MCP
    Bangalore - India
    9886497756


    "Alexey Smirnov" wrote:

    > On Aug 8, 9:04 am, Labhesh Shrimali - Bangalore
    > <> wrote:
    >
    > Hi Labhesh
    >
    > > xmlHTTP.open "POST", sQuery, false

    >
    > in a working example you do POST
    >
    > > url="http://localhost/test.asmx/helloworld?param=test"; < this hangs
    > >

    >
    > 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?
    >
    >
    =?Utf-8?B?TGFiaGVzaCBTaHJpbWFsaSAtIEJhbmdhbG9yZQ==, Aug 8, 2007
    #6
  7. 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.
    --
    Labhesh Shrimali - MCP
    Bangalore - India
    9886497756


    "Alexey Smirnov" wrote:

    > On Aug 8, 9:04 am, Labhesh Shrimali - Bangalore
    > <> wrote:
    >
    > Hi Labhesh
    >
    > > xmlHTTP.open "POST", sQuery, false

    >
    > in a working example you do POST
    >
    > > url="http://localhost/test.asmx/helloworld?param=test"; < this hangs
    > >

    >
    > 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?
    >
    >
    =?Utf-8?B?TGFiaGVzaCBTaHJpbWFsaSAtIEJhbmdhbG9yZQ==, Aug 8, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    3
    Views:
    536
  2. markla
    Replies:
    1
    Views:
    393
    Allen Chen [MSFT]
    Oct 15, 2008
  3. Dev880

    Dynamic updates

    Dev880, Oct 27, 2004, in forum: ASP General
    Replies:
    2
    Views:
    93
    Ray Costanzo [MVP]
    Oct 27, 2004
  4. Doug Beaver
    Replies:
    0
    Views:
    111
    Doug Beaver
    Dec 17, 2005
  5. yawnmoth

    Msxml*.XMLHTTP vs. Microsoft.XMLHTTP

    yawnmoth, Nov 7, 2006, in forum: Javascript
    Replies:
    11
    Views:
    371
    Matt Kruse
    Nov 9, 2006
Loading...

Share This Page