Web service

Web service

Old forum URL: forums.lhotka.net/forums/t/5646.aspx


Slayer posted on Wednesday, October 22, 2008

Hi

I have worked through Rocky`s web service sample code, but I have a few questions.

Lets use the PTService`s addProject web method as example.

Querstion1:The parameters to the addProject method will overwrite the default project values...this is not always desired. If the default values are need at the consumers end, will you then need to create a new web method in order to return default project data?

Querstion2: In the sample, Rocky uses parameters for each field. What if my parameters list becomes to long? I have about 10 mandatory fields in order for Customer to be created.

Thanks in advance

JoeFallon1 replied on Wednesday, October 22, 2008

First thing to recall is that PT is used to show various ways to accomplish things. It is not 100% "best practices". Also - there is nothing stopping you from modifying things to sduit your needs.

#1 - Then don't expose those values in the parameter list! A new project gets created under the hood and the default values are set and only those in the param list that *you expose* overwrite defaults. The param list can be the minimum amount of data required to save a valid project. Maybe just ID and Name - all other fields can be filled in later.

#2 - Intead of using a param list, use a class like ProjectRequest to pass in the data as a single parameter. You can expand ProjectRequest to act as a DTO with 10 fields and Properties which can be filled out by the client and passed to the AddProject method which just reads the Properties instead of reading a param list.

Joe

Copyright (c) Marimer LLC