locked
VBScript SOAP Call RRS feed

  • Question

  • Hi community,

    I wondered if anybody has got an example snippet of how SOAP calls can be utilised within a VB Script.

    I know the URL of the call I need to make and, when using this URL within Internet Explorer, a set of piped values are returned to me.

    I cannot figure out how to assign this returned value to a variable within my script and cannot find a simple example to get me started when searching the net.

    I would appreciate any help or guidance anyone can spare me.

    Thanks for looking.

    Thursday, December 29, 2011 6:42 PM

Answers

  • I didn't have a working example in VBScript so I built one.

    Here is the basic template for returning data from a Web Service:

    Set osoap=CreateObject("MSSOAP.SoapClient")
    oSoap.ClientProperty("ServerHTTPRequest") = True
    oSoap.mssoapinit("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL")
    result=oSoap.FahrenheitToCelsius(30)
    WScript.Echo result
    


    Once the proxy is loaded you can call any method directly.

     

     


    jv
    • Edited by jrv Thursday, December 29, 2011 8:36 PM
    • Marked as answer by spunkymuffmonkey Thursday, December 29, 2011 11:44 PM
    Thursday, December 29, 2011 8:34 PM

All replies

  • Hi community,

    I wondered if anybody has got an example snippet of how SOAP calls can be utilised within a VB Script.

    I know the URL of the call I need to make and, when using this URL within Internet Explorer, a set of piped values are returned to me.

    I cannot figure out how to assign this returned value to a variable within my script and cannot find a simple example to get me started when searching the net.

    I would appreciate any help or guidance anyone can spare me.

    Thanks for looking.


    You need to create a proxy to use SOAP (Web Services) within VBScript.

    In PowerShell we have a proxy generator built in.  If you access the web site you will just return the banner page.  If you call through the WSDL link you will just get XML.  The XML is used to generate a proxy.

    Here is the SOAP tutorial.

    You need to use HTTP calls with the appropriate XML included.  Her are som eexamples and a discussion of ho this might be accomplished.

    Raw SOAP is very difficult to use if you are not well versed in HTTP protocols and SOAP/XML.

    You can also use the builtin SOAP client;

    Set sc = CreateObject("MSSOAP.SoapClient")
    sc.mssoapinit("http://Web.com/App/SoapApp.Calc.soap?WSDL)

     

     

     


    jv
    Thursday, December 29, 2011 8:06 PM
  • I didn't have a working example in VBScript so I built one.

    Here is the basic template for returning data from a Web Service:

    Set osoap=CreateObject("MSSOAP.SoapClient")
    oSoap.ClientProperty("ServerHTTPRequest") = True
    oSoap.mssoapinit("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL")
    result=oSoap.FahrenheitToCelsius(30)
    WScript.Echo result
    


    Once the proxy is loaded you can call any method directly.

     

     


    jv
    • Edited by jrv Thursday, December 29, 2011 8:36 PM
    • Marked as answer by spunkymuffmonkey Thursday, December 29, 2011 11:44 PM
    Thursday, December 29, 2011 8:34 PM
  • Many thanks JV, I shall start reading.
    Thursday, December 29, 2011 11:45 PM
  • thanks for the code...it helped me alot

    Set osoap = CreateObject("MSSOAP.SoapClient")
    osoap.ClientProperty("ServerHTTPRequest") = True
    osoap.mssoapinit ("http://192.168.2.30:5050/Selling/soap/description?WSDL")
    result = osoap.get_customer_debit_balance(CUSTOMERID)'this function return type is float and it is working fine
    Dim result1 As object
    result1 = osoap.get_customer_balance(1010) 'this function return type is CustomerBalance class object
    MsgBox result1


    I am running this code and getting invalid procedure or function call error message


    when I am using PHP with SOAP and this function returning array but in VB i am getting error. 


    please help me to fix up this problem and explain me how to get multiple values from a function using VB.
    Wednesday, March 21, 2012 11:06 AM
  • thanks for the code...it helped me alot

    Set osoap = CreateObject("MSSOAP.SoapClient")
    osoap.ClientProperty("ServerHTTPRequest") = True
    osoap.mssoapinit ("http://192.168.2.30:5050/Selling/soap/description?WSDL")
    result = osoap.get_customer_debit_balance(CUSTOMERID)'this function return type is float and it is working fine
    Dim result1 As object
    result1 = osoap.get_customer_balance(1010) 'this function return type is CustomerBalance class object
    MsgBox result1


    I am running this code and getting invalid procedure or function call error message


    when I am using PHP with SOAP and this function returning array but in VB i am getting error. 


    please help me to fix up this problem and explain me how to get multiple values from a function using VB.

    This topic has been closed fo r sometme. Please start a new wquestion with your code and I will answer why you are getting this.

    Note this is a scripting forum and not a VB coding forum.


    ¯\_(ツ)_/¯

    Wednesday, March 21, 2012 11:10 AM