我试图找出为什么我的HTTPService导致Flex是返回回多个XML头..Flex HTTPService组件返回多个XML头
C#的WebAPI服务:
[HttpPost, HttpGet]
public List<vwRecord24Category> GetClientCategories(int companyId)
{
var categories = Db.Fetch<vwRecord24Category>(@"SQLQUERY", companyId);
return categories;
}
的调用上的结果这个webservice是;
<ArrayOfvwRecord24Category xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Record24Entities">
<vwRecord24Category>
<CategoryName>John Doe</CategoryName>
<Name>adsf</Name>
</vwRecord24Category>
<vwRecord24Category>
<CategoryName>John Doe</CategoryName>
<Name>df</Name>
</vwRecord24Category>
<vwRecord24Category>
<CategoryName>John Doe</CategoryName>
<Name>new thing 4</Name>
</vwRecord24Category>
<vwRecord24Category>
<CategoryName>John Doe</CategoryName>
<Name>Surgery Center 1</Name>
</vwRecord24Category>
</ArrayOfvwRecord24Category>
我HttpService的内部Flash Builder中(ActionScript 3.0中):
params.companyId = clientData.data.companyId;
httpService.method = 'POST';
httpService.url = 'http://****.domain.com/record24api/content/GetClientCategories';
httpService.contentType = "application/json";
httpService.resultFormat = "e4x";
httpService.addEventListener(ResultEvent.RESULT, onLibrariesLoaded);
httpService.addEventListener(FaultEvent.FAULT, onLibraryLoadError);
httpService.send(JSON.stringify(params));
好吧,那么毕竟,当成功的事件被触发我response.result看起来像这样:
我一直在争论这个问题几个小时了,我缩小了它不能成为我的web服务,因为它显示正确时,我通过Chrome或IE拨打电话。有什么建议么?
在设置params.companyId后查看是否正确设置了断点。也许你将null传递给了服务,所以它将返回所有的类别,而不仅仅是与id匹配的类别。 –
它正在返回适当的数量,这不是问题;问题在于它正在为Web服务的每个结果返回一个新的xml集合。据我所知,它不应该从源中为每个记录返回多个xml对象。 – jhartzell