Limiting access to fields for web service client

Discussion in 'ASP .Net' started by dev, Sep 10, 2006.

  1. dev

    dev Guest

    Hello,

    I have a web service that returns an entity (C# class). I would like to
    disallow access to some of the members in write access to the WebService
    clients. Setting them private or protected in the class definition can
    not be achieved since in the WebService they must be writeable.

    Dummy example to explain if it is not clear:

    In WebService definition:

    // ...
    class MyClass
    {
    public int id;
    public int name;
    };

    // ...
    MyClass WebService_GetMyClass()
    {
    MyClass mc = new MyClass();
    mc.id = 1; // id must be public
    mc.name = "foo";
    }

    void WebService_UpdateMyClass(MyClass mc)
    {
    // ...
    }

    WebService client:

    MyClass mc = WS.WebService_GetMyClass();
    mc.id = 22; // <== this is what I want to avoid *******
    WS.WebService_UpdateMyClass(mc);


    Thanks for your answers.
     
    dev, Sep 10, 2006
    #1
    1. Advertisements

  2. dev

    Joerg Jooss Guest

    Thus wrote Dev,

    > Hello,
    >
    > I have a web service that returns an entity (C# class). I would like
    > to disallow access to some of the members in write access to the
    > WebService clients. Setting them private or protected in the class
    > definition can not be achieved since in the WebService they must be
    > writeable.
    >
    > Dummy example to explain if it is not clear:
    >
    > In WebService definition:
    >
    > // ...
    > class MyClass
    > {
    > public int id;
    > public int name;
    > };
    > // ...
    > MyClass WebService_GetMyClass()
    > {
    > MyClass mc = new MyClass();
    > mc.id = 1; // id must be public
    > mc.name = "foo";
    > }
    > void WebService_UpdateMyClass(MyClass mc)
    > {
    > // ...
    > }
    > WebService client:
    >
    > MyClass mc = WS.WebService_GetMyClass();
    > mc.id = 22; // <== this is what I want to avoid *******
    > WS.WebService_UpdateMyClass(mc);
    > Thanks for your answers.


    The overall model of transmitting an object across process boundaries while
    still trying to maintain control over is dangerously flawed. Web Services
    are all about exchaging messages. If you don't want to make information visible
    on the receiver's side, don't put that information in your message.

    Cheers,
    --
    Joerg Jooss
     
    Joerg Jooss, Sep 19, 2006
    #2
    1. Advertisements

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:
    1
    Views:
    871
    Jan Tielens
    Jan 3, 2004
  2. dev
    Replies:
    1
    Views:
    400
    Laurent Bugnion
    Sep 10, 2006
  3. Bert Leu
    Replies:
    1
    Views:
    633
    Cowboy \(Gregory A. Beamer\)
    Nov 23, 2007
  4. Replies:
    0
    Views:
    373
  5. Curt K
    Replies:
    3
    Views:
    704
    John Saunders [MVP]
    Jun 15, 2007
  6. Bert Leu

    Creating a Web Service (Service, not Client) from WSDL

    Bert Leu, Nov 23, 2007, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    408
    Cowboy \(Gregory A. Beamer\)
    Nov 23, 2007
  7. John Sedlak

    Limiting a WCF Service to "On" Domain Apps

    John Sedlak, Apr 24, 2008, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    186
    John Sedlak
    Apr 24, 2008
  8. Leo Violette
    Replies:
    0
    Views:
    1,302
    Leo Violette
    Apr 17, 2009
Loading...