开发者

WCF REST: passing a generic list as a request

I have a POST with a WebMessageFormat.Xml. It's a simple method that takes in a Company object. Aside from simple types containing "CompanyId", "CompanyName", "CompanyDescription etc., inside the XML there is a series of the s开发者_Python百科ame element containing tons of metadata involving contacts. I wanted to pop that into a List.

[DataContract(Namespace = "http://www.testcompany.com/2010/01")]
public class Company
{
     ...
     ...
     [DataMember] public List<CompanyContact> CompanyContacts;
}

The request goes through fine but the list is empty. The other fields are populated from the request without issue. Any ideas of what step I'm missing?

Here's a snapshot of my svc file:

<%@ ServiceHost Language="C#" 
                Debug="true" 
                Service="CompanyService"
                Factory="Microsoft.ServiceModel.Web.WebServiceHost2Factory"%>

Using the "/help", I doubled checked the schema I'm passing in with the examples provided by the help page.

Any suggestions would be appreciated!


Still reviewing the demo code I created but the issue was resolved. I created a Contact class for all the metadata in the XML. I added a List to the Company object. I wrote the XML and created a request through Fiddler. Everything worked accordingly.

Now I'm going back to my original app to see if I can track why the collection is empty. I need to review that the XML is correct and that my data contracts are proper.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜