none
WCF service request object RRS feed

  • Question

  • I have seen a lot of the web services that use one request object to wrap multiple parameters inside.  Is this just a convention?  Is it recommended to design WCF service to accept just one request object?  What is the rational behind it?

    Thanks.

    Monday, January 28, 2013 4:26 PM

Answers

  • Hi,

    >>If I need more than one parameter for an OperationContract, it is ok to pass more than one parameters for this ServiceOperation? 

    Yes, it is ok.

    >>I can declare a custom class, such as a request object, and put the two parameters inside the object so I can pass the two in only one object.  Which way is the preferred?  What is the pros and cons?

    You can pass the object, but you need use the KownType attribute for the object. You may take a look at the discussions here for detail.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, January 30, 2013 5:56 AM
    Moderator

All replies

  • Hi,

    Can you give a sample here to better explain your question?

    Thanks.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, January 29, 2013 6:35 AM
    Moderator
  • My question is this:  If I need more than one parameter for an OperationContract, it is ok to pass more than one parameters for this ServiceOperation?  On the other hand, I can declare a custom class, such as a request object, and put the two parameters inside the object so I can pass the two in only one object.  Which way is the preferred?  What is the pros and cons? 

    Thanks. 

    Tuesday, January 29, 2013 1:01 PM
  • Hi,

    >>If I need more than one parameter for an OperationContract, it is ok to pass more than one parameters for this ServiceOperation? 

    Yes, it is ok.

    >>I can declare a custom class, such as a request object, and put the two parameters inside the object so I can pass the two in only one object.  Which way is the preferred?  What is the pros and cons?

    You can pass the object, but you need use the KownType attribute for the object. You may take a look at the discussions here for detail.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, January 30, 2013 5:56 AM
    Moderator