处理响应流时出错。 XML 元素包含混合内容
我正在通过 WCF-DataService 和 EF4 调用存储过程。其他方法工作正常,但返回列表的方法失败,并出现异常处理响应流时出错。 XML 元素包含混合内容。
这是该方法返回的 XML(在 http 中调用)
<GetShowName>
<element>MONT</element>
<element>INTERPEECH 08/2011</element>
<element>POI MOBILIER 09/2011</element>
<element>ASSEMBLE GALE CLUB 41 06/2011</element>
<element>AFTES 10/2011</element>
<element>DIVERS DEVIS 12/2011</element>
<element>DIVERS DEVIS 12/2011</element>
<element>SFTS 2011</element>
<element>COUPE DU MONDE BIATHLON 12/11</element>
<element>CADRE NOIR GENEVE 04/2011</element>
</GetShowName>
,代码是:
private List<T> ListWithFilter<T>(string methodName, string methodParameters)
{
StringBuilder methodParams = new StringBuilder("/" + methodName + "?");
methodParams.Append(methodParameters);
Uri methodUri = new Uri(entities.BaseUri + methodParams.ToString());
List<T> result = entities.Execute<T>(methodUri).ToList(); //Exception here
return result;
}
知道吗?
I'm calling a stored procedure via WCf-DataService and EF4. Other method works fine but one which return List failed with the exception Error processing response stream. The XML element contains mixed content.
Here is the XML return by the method (call in http)
<GetShowName>
<element>MONT</element>
<element>INTERPEECH 08/2011</element>
<element>POI MOBILIER 09/2011</element>
<element>ASSEMBLE GALE CLUB 41 06/2011</element>
<element>AFTES 10/2011</element>
<element>DIVERS DEVIS 12/2011</element>
<element>DIVERS DEVIS 12/2011</element>
<element>SFTS 2011</element>
<element>COUPE DU MONDE BIATHLON 12/11</element>
<element>CADRE NOIR GENEVE 04/2011</element>
</GetShowName>
And the code is:
private List<T> ListWithFilter<T>(string methodName, string methodParameters)
{
StringBuilder methodParams = new StringBuilder("/" + methodName + "?");
methodParams.Append(methodParameters);
Uri methodUri = new Uri(entities.BaseUri + methodParams.ToString());
List<T> result = entities.Execute<T>(methodUri).ToList(); //Exception here
return result;
}
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据这篇文章,客户端从 .NET 4.0 开始不支持原始类型具体化。可能需要手动解析结果:
调用WebGet 抛出异常
According to this post the client does not support primitive type materialization as of .NET 4.0. May need to parse the result manually:
Invoking a WebGet throws an exception