0
我遇到了让我的WCF服务与其他客户端一起工作的问题。WCF如何包装xml正文消息?
的的ServiceContract看起来是这样的:
[ServiceContract]
public interface IMyService
{
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare,
ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml,
UriTemplate = "/calculation/{accountNumber}")]
string RunCalculations(string returnInformation, string accountNumber);
}
我写了一个简单的客户端,以确保一切工作,当我通过我希望XML,一切正常顺顺当当。
问题是,该服务存在将我们的产品接口暴露给第三方供应商,他们正在开发一个php界面。当他尝试发出请求时,他得到一个400错误请求错误,该错误通过跟踪查看,是WCF尝试解析其xml时引起的。
该错误消息我得到的是:
Unable to deserialize XML body with root name 'BusinessTaxReturn' and root namespace '' (for operation 'RunCalculations' and contract ('IMyService', 'http://tempuri.org/')) using DataContractSerializer.
Ensure that the type corresponding to the XML is added to the known types collection of the service.
我认为WCF是包装,我的客户端发送消息,然后尝试在服务临危消息解开它。这给我留下了两个问题:
- WCF是如何包装XML消息的?
- 解决此问题的最佳方法是什么?我应该只是让客户端包装他们的消息,还是应该真的试图使用DataContract?