How to use own classes as WebMethod-Parameters?

Discussion in 'ASP .Net Web Services' started by Daniel Barisch, Aug 19, 2003.

  1. Is it possible to use self defined classes as parameters for a WebMethod? I
    thought of the following....

    1. Library-Project: "LibProj"

    Public Class ParamClass
    private ...
    public ...
    public sub addXY...
    End Class

    2. WebService-Project: "WSProj"
    (Reference to "LibProj")

    <WebService>
    Public Class WServer
    <WebMethod> _
    Public function getSth( param as LibProj.ParamClass)....
    end class

    3. Client-Project: "ClientProj"
    (Reference to "LibProj", WebReference to "WSProj" as "WSProjProxy")

    public sub doSth
    dim ws as new WSProjProxy.WServer()
    dim pc as new LibProj.ParamClass()
    msgbox ws.getSth( pc ) >> ERROR (Parameter "pc")
    end sub


    This does not work, because " 'LibProj.ParamClass' can't be converted to
    'ClientProj.WSProjProxy.ParamClass' "

    What is wrong with this code? Why suddenly the type of the
    WebService-parameter switches from 'LibProj.ParamClass' (as defined in the
    WebMethod) to 'WSProjProxy.ParamClass'?

    Is there possibility to get this work?

    Thanks, D.Barisch
     
    Daniel Barisch, Aug 19, 2003
    #1
    1. Advertising

  2. Daniel Barisch

    Simon Smith Guest

    "Daniel Barisch" <> wrote in message news:<#>...
    > Is it possible to use self defined classes as parameters for a WebMethod? I
    > thought of the following....
    >


    <snip>

    > This does not work, because " 'LibProj.ParamClass' can't be converted to
    > 'ClientProj.WSProjProxy.ParamClass' "
    >
    > What is wrong with this code? Why suddenly the type of the
    > WebService-parameter switches from 'LibProj.ParamClass' (as defined in the
    > WebMethod) to 'WSProjProxy.ParamClass'?
    >
    > Is there possibility to get this work?
    >
    > Thanks, D.Barisch


    You're almost there. The Web Reference in the client has the code in a
    file called Reference.cs - this is the proxy for the Web Service. In
    that file is a definition of what your custom class looks like when
    deserialised - all properties etc as public fields. This is the class
    called WSProjProxy.ParamClass. Whjat you need to do is delete that
    class and add a using LibProj to theis file. That will tell the
    compiler to deserialise to you your custom class in LibProj, not the
    'stub' generated.

    HTH.
     
    Simon Smith, Sep 1, 2003
    #2
    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. Stefan Siegl
    Replies:
    1
    Views:
    807
  2. Alin Popovici

    Carriage Return in WebMethod parameters

    Alin Popovici, Jan 8, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    306
    Jan Tielens
    Jan 9, 2004
  3. PMCG

    WebMethod and WSDL with optional parameters

    PMCG, Mar 2, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    826
    Jan Tielens
    Mar 2, 2004
  4. Darren via .NET 247

    Mandatory WebMethod parameters

    Darren via .NET 247, May 5, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    445
    Dino Chiesa [Microsoft]
    May 5, 2004
  5. webmethod parameters issue 500 error

    , Apr 27, 2007, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    278
Loading...

Share This Page