WebMethod signature which takes SortedList as parameter??

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default Re: WebMethod signature which takes SortedList as parameter??

    SortedList is a .NET class and shouldn't be used as a parameter to a Webmethod.
    I just posted earlier today discussing why things like this aren't by design
    in Web Services. Here's the link:

    [url]http://groups-beta.google.com/group/microsoft.public.dotnet.framework.aspnet.webservic es/browse_thread/thread/8989a6ff68d23be4/37e6b9f3c05f75c8#37e6b9f3c05f75c8[/url]

    So, in short, you need to design around XML and XML Schema and then figure
    out how to represent it in your .NET code.

    -Brock
    DevelopMentor
    [url]http://staff.develop.com/ballen[/url]


    > It seems like, it is not allowed to specify a parameter of type
    > SortedList in
    > WebMethod signature, Is is true?
    > What other option(s) do we have to pass in a named-value piar to a web
    > method?
    > i am using vb.net for creating web service.


    Brock Allen Guest

  2. Similar Questions and Discussions

    1. Signature properties --> Bad parameter
      Hi, I have a strange problem. I wrote a plugin with Acrobat SDK 6.0 for Adobe Acrobat and Adobe Reader which signs and verifies PDF documents. I...
    2. WebMethod + MaxOccurs for input parameter; possible?
      Good afternoon everyone, I have a WebMethod function (VB .NET) that receive a parameter (Order #). I would like to be able to change my function...
    3. Date Parameter For Saved Parameter Queries
      Hi again, I finally got to using saved parameter queries in my application (a big thank you to Bob Barrows for helping me with this). Currently...
    4. Adding an XmlNode parameter to the HelloWorld WebMethod
      I've added an XmlNode as a parameter to the HelloWorld WebMethod. The automaticall generated WSDL would leave one to believe that any well-formed...
    5. DataTable parameter of a WebMethod?
      DataTable is not serializable, you have to put them in a dataset. DataTable object to it. I visit the .asmx can't pass in a...
  3. #2

    Default Re: WebMethod signature which takes SortedList as parameter??

    Well, you can use arrays, as those do map ok into XML Schema:

    [WebMethod]
    void YourMethod(string[] items)
    {
    }

    And then you'll have to do the sorting yourself. That's easy, with Array.Sort(items);

    -Brock
    DevelopMentor
    [url]http://staff.develop.com/ballen[/url]


    > Hi Allen,
    >
    > I really appreciate that you replied to my question. I am new to Web
    > Service
    > development.
    > I went to the link mentioned in your reply, but I am not able figure
    > out how
    > it is going to solve my problem(new to WS).
    > I understand that we can not specify Sorted List as parameter for
    > WebMethod,
    > so what OTHER OPTIONS DO WE HAVE, which offers the same
    > functionality Name-Value pair without using Sorted List(limitation
    > with
    > webmethod).
    > Explanation: my scenario is:
    >
    > MyWebMethod(v_filterCriteria As SortedList)
    > {
    > ... talk to db and execute query with WHERE clause equal to items in
    > v_filterCriteria.
    > }
    > The client can create a sortedlist object and add some filter criteria
    > and
    > send it to web method as
    > MyWebMethodClinet()
    > {
    > Dim objSortedList as sortedlist
    > objSortedList.add(a,1)
    > objSortedList.add(b,2)
    > MyWebMethod(objSortedList)
    > }
    > Thanks in advance.
    > Faiz
    > "Brock Allen" wrote:
    >
    >> SortedList is a .NET class and shouldn't be used as a parameter to a
    >> Webmethod. I just posted earlier today discussing why things like
    >> this aren't by design in Web Services. Here's the link:
    >>
    >> [url]http://groups-beta.google.com/group/microsoft.public.dotnet.framework[/url]
    >> .aspnet.webservices/browse_thread/thread/8989a6ff68d23be4/37e6b9f3c05
    >> f75c8#37e6b9f3c05f75c8
    >>
    >> So, in short, you need to design around XML and XML Schema and then
    >> figure out how to represent it in your .NET code.
    >>
    >> -Brock
    >> DevelopMentor
    >> [url]http://staff.develop.com/ballen[/url]
    >>> It seems like, it is not allowed to specify a parameter of type
    >>> SortedList in
    >>> WebMethod signature, Is is true?
    >>> What other option(s) do we have to pass in a named-value piar to a
    >>> web
    >>> method?
    >>> i am using vb.net for creating web service.


    Brock Allen Guest

  4. #3

    Default Re: WebMethod signature which takes SortedList as parameter??

    Sure, so you can simulate that by creating your own name/value pair class.
    Now, keeping in mind webservices aren't about classes and objects, but the
    class you create in the .NET code is used to express what XML representation
    you want on the wire. So something like this would work:

    class Container
    {
    public string Key;
    public string Value;
    }

    [WebMethod]
    void TakeThis(Container[] items)
    {

    }

    So the Container class can contain whatever primitives you want (int, double,
    DateTime, etc). You can create class/object models in code like the above,
    so Container can hold references to other objects, but again, keep in mind
    that it's all being mapped onto XML Schema. So as long as you build simple
    classes to hold your XML data and don't add method to these classes, you
    should be able to represent the types of XML data structures you want to
    accept in your web service.

    -Brock
    DevelopMentor
    [url]http://staff.develop.com/ballen[/url]


    > Hi Allen,
    > Thanks for quick response. String array is not named-value pair
    > collection(single dimention), and we can not use multidimetional array
    > in
    > webmethod declaration as well.
    > It will make my life easier, if i can get some sort of Named-Value
    > pair in my webmethod declaration (as an alternate of SortedList).
    >
    > Any suggestion will be highly appreciated.
    >
    > Thanks
    > Faiz
    > Faiz
    >
    > "Brock Allen" wrote:
    >
    >> Well, you can use arrays, as those do map ok into XML Schema:
    >>
    >> [WebMethod]
    >> void YourMethod(string[] items)
    >> {
    >> }
    >> And then you'll have to do the sorting yourself. That's easy, with
    >> Array.Sort(items);
    >>
    >> -Brock
    >> DevelopMentor
    >> [url]http://staff.develop.com/ballen[/url]
    >>> Hi Allen,
    >>>
    >>> I really appreciate that you replied to my question. I am new to Web
    >>> Service
    >>> development.
    >>> I went to the link mentioned in your reply, but I am not able figure
    >>> out how
    >>> it is going to solve my problem(new to WS).
    >>> I understand that we can not specify Sorted List as parameter for
    >>> WebMethod,
    >>> so what OTHER OPTIONS DO WE HAVE, which offers the same
    >>> functionality Name-Value pair without using Sorted List(limitation
    >>> with
    >>> webmethod).
    >>> Explanation: my scenario is:
    >>> MyWebMethod(v_filterCriteria As SortedList)
    >>> {
    >>> ... talk to db and execute query with WHERE clause equal to items in
    >>> v_filterCriteria.
    >>> }
    >>> The client can create a sortedlist object and add some filter
    >>> criteria
    >>> and
    >>> send it to web method as
    >>> MyWebMethodClinet()
    >>> {
    >>> Dim objSortedList as sortedlist
    >>> objSortedList.add(a,1)
    >>> objSortedList.add(b,2)
    >>> MyWebMethod(objSortedList)
    >>> }
    >>> Thanks in advance.
    >>> Faiz
    >>> "Brock Allen" wrote:
    >>>> SortedList is a .NET class and shouldn't be used as a parameter to
    >>>> a Webmethod. I just posted earlier today discussing why things like
    >>>> this aren't by design in Web Services. Here's the link:
    >>>>
    >>>> [url]http://groups-beta.google.com/group/microsoft.public.dotnet.framewo[/url]
    >>>> rk
    >>>> .aspnet.webservices/browse_thread/thread/8989a6ff68d23be4/37e6b9f3c
    >>>> 05 f75c8#37e6b9f3c05f75c8
    >>>>
    >>>> So, in short, you need to design around XML and XML Schema and then
    >>>> figure out how to represent it in your .NET code.
    >>>>
    >>>> -Brock
    >>>> DevelopMentor
    >>>> [url]http://staff.develop.com/ballen[/url]
    >>>>> It seems like, it is not allowed to specify a parameter of type
    >>>>> SortedList in
    >>>>> WebMethod signature, Is is true?
    >>>>> What other option(s) do we have to pass in a named-value piar to a
    >>>>> web
    >>>>> method?
    >>>>> i am using vb.net for creating web service.


    Brock Allen Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139