开发者

ASP.NET Web Service - Passing a base object with list/collection?

We need to create a simple web service in ASP.NET that can be called from PHP or other languages. This in turn will be used to update records in a database for an item submission.

The core part is fairly simple, we have a base set of fields for the object - first name, last name, birth date, city, etc. In addition however we need to accept a list of items associated with that object that can range from 0-n. Jan 1 20开发者_Go百科09, ABC May 1 2010, 123 Jun 30 2010, XXXXX

What would be the best way to structure this so it can be easily passed to the ASP.NET web service and processed as a single call for the entire object? Would passing the list of items as a single delimted string be a wise approach? Ex: Jan 1 2009, ABC|May 1 2010, 123|Jun 30 2010, XXXXX


If you define a structure like:

class WebObject
{
   string Name { get; set; }
   string[] Parameters { get;set; }
}

You can specify in your method to just accept a WebObject. Will go fine with 99% of the PHP libraries, as well as JavaScript libraries etc.

F.e. this will just work against the function void Process(WebObject obj):

someJavascriptPiece.Process({ Name: "Jan", Parameters: ['param1', 'param2'] });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜