Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Service interface - Complex Type as parameter?

Tags:

Just looking for some feedback on best-practices regarding Web Service interface design.

I have two options:

Option 1

public string GetSomeData(SomeCriteriaClass criteria);

where SomeCriteriaClass is defined as:

public int ID;
public string Name;
public string Property2; etc.

Option 2

public string GetSomeData(int id, string name, string property2)

Which is the preferred option? It seems like a conflict of design patterns - 1 is to wrap up parameters in a class, but the other is keeping the web service interface flexible and open.

The second question is - if we choose Option1 - how do you call this via a URL?

Thanks

like image 389
Duncan Avatar asked May 19 '09 08:05

Duncan


1 Answers

You can go the hard way and implement option #1, using SOAP. With SOAP you can define complex data types. On the other hand, you can do it the "hack" way as in option #2, using REST and just encode the parameters in either the URL or the HTTP POST message.

like image 163
Dan Avatar answered Oct 12 '22 07:10

Dan