Hashtable to VBA using SOAP Toolkit

Discussion in 'ASP .Net Web Services' started by Salman, May 21, 2004.

  1. Salman

    Salman Guest

    How an ASP.Net webservice return hashtable or any other (key value pairs
    like structure) that can be consumed in VBA or vbscript like this following
    (using Soap Toolkit):

    value1 = soapProxy.Items["Key1"]
    value2 = soapProxy.Items["Key2"]

    Thanks.
     
    Salman, May 21, 2004
    #1
    1. Advertising

  2. Salman

    [MSFT] Guest

    Hi Salman,

    The hashtable or collection objects used in asp.net service are classes in
    ..NET framework, which cannot be refered in VBA or VBScript directly, I
    suggest you may use array instead, for example, such a web method:


    [WebMethod]
    public string [] GetStringArray()
    {
    string [] results= new string[3] ;

    results[0]="sss";
    results[1]="sss";
    results[2]="sss";

    return results;
    }


    On client side, we can use following code:


    Dim rs

    strWSURL = "..."
    SoapClient.MSSoapInit(strWSURL)

    rs = SoapClient.GetStringArray()
    MsgBox rs(0)

    Hope this help,

    Luke
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    [MSFT], May 21, 2004
    #2
    1. Advertising

  3. Salman

    Salman Guest

    Thanks for your response.
    Let me rephrase my question.

    What datatype should I use in a .Net webservice that can be loaded in vba
    like a key-value pair collection.
    value1 = soapProxy.Items["Key1"]
    value2 = soapProxy.Items["Key2"]

    "[MSFT]" <> wrote in message
    news:...
    > Hi Salman,
    >
    > The hashtable or collection objects used in asp.net service are classes in
    > NET framework, which cannot be refered in VBA or VBScript directly, I
    > suggest you may use array instead, for example, such a web method:
    >
    >
    > [WebMethod]
    > public string [] GetStringArray()
    > {
    > string [] results= new string[3] ;
    >
    > results[0]="sss";
    > results[1]="sss";
    > results[2]="sss";
    >
    > return results;
    > }
    >
    >
    > On client side, we can use following code:
    >
    >
    > Dim rs
    >
    > strWSURL = "..."
    > SoapClient.MSSoapInit(strWSURL)
    >
    > rs = SoapClient.GetStringArray()
    > MsgBox rs(0)
    >
    > Hope this help,
    >
    > Luke
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
     
    Salman, May 21, 2004
    #3
  4. Salman

    [MSFT] Guest

    Hi Salman,

    I have to tell the answer is "No such one" to the question. All collections
    used in VBA/VBScript are COM based, which cannot be passed from a .NET web
    service.

    If you need a collection from a web service, you may first get the XML data
    of the XML service and then convert it to a collection object. For example,
    here is a web method:

    public struct MyItem
    {
    public string key;

    public string myvalue;

    }

    [WebMethod]
    public MyItem [] Getitems()
    {
    MyItem [] ddd= new MyItem[2] ;

    ddd[0].key ="key1";

    ddd[0].myvalue="hello ";

    ddd[1].key ="key2";

    ddd[1].myvalue="World";

    return ddd;
    }


    It will return an array of MyItem objects. On client side:

    soapProxy.ClientProperty("ServerHTTPRequest") = True
    soapProxy.MSSoapInit ("http://localhost/WebService6/Service3.asmx?wsdl")

    Dim results

    results = soapProxy.GetItems()


    Dim mydictionary

    Set mydictionary = CreateObject("scripting.dictionary")

    Dim i

    For i = 0 To UBound(results)

    mydictionary.Add results(i)(0).Text, results(i)(1).Text

    Next

    MsgBox mydictionary("key1") + mydictionary("key2")

    Hope this help,

    Luke
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    [MSFT], May 24, 2004
    #4
    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. Sham Ramakrishnan
    Replies:
    2
    Views:
    8,406
    Sham Ramakrishnan
    Jul 1, 2003
  2. Bill Poitras
    Replies:
    2
    Views:
    1,096
    Carl Howells
    May 12, 2004
  3. Mike Cook
    Replies:
    0
    Views:
    478
    Mike Cook
    Jul 17, 2003
  4. Tony C
    Replies:
    2
    Views:
    368
    Xiangyang Liu
    Jul 20, 2003
  5. Prabhu

    .net SOAP toolkit performance for SOAP deserialization

    Prabhu, Nov 12, 2004, in forum: ASP .Net Web Services
    Replies:
    5
    Views:
    300
    Dan Rogers
    Nov 18, 2004
Loading...

Share This Page