C# WCF删除xmlns:tem=";http://tempuri.org/"
我无法让客户机与我的系统集成。我想我已经把问题缩小了。客户端通过xml消息发送,我的系统设置为接受xml消息;然而,它期望它以某种形式出现。客户已经表示希望我在我的终端设置格式以接受他们的格式 这是客户端消息:C# WCF删除xmlns:tem=";http://tempuri.org/",c#,.net,xml,wcf,soap,C#,.net,Xml,Wcf,Soap,我无法让客户机与我的系统集成。我想我已经把问题缩小了。客户端通过xml消息发送,我的系统设置为接受xml消息;然而,它期望它以某种形式出现。客户已经表示希望我在我的终端设置格式以接受他们的格式 这是客户端消息: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<NewOrder>
<Message id="d3a39c31-cc9f-4331-ad13-be74522df6eb">
<Header>
<LoginAccountIdentifier>Blank</LoginAccountIdentifier>
<LoginAccountPassword>password</LoginAccountPassword>
</Header>
空白
密码
我注意到我期望的格式是节点上的前缀tem:除外
这是预期的消息:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:NewOrder>
<tem:Message id="d3a39c31-cc9f-4331-ad13-be74522df6eb ">
<Header>
<LoginAccountIdentifier>Blank</LoginAccountIdentifier>
<LoginAccountPassword>password</LoginAccountPassword>
</Header>
空白
密码
我相信,如果我可以删除前缀,那么这将使客户端消息与预期消息匹配。问题是在哪里删除前缀“
[WebService(命名空间=”http://tempuri.org/")]
属性位于类定义的顶部。删除此项(或将其设置为适当的值)应该可以解决此问题。我很久以前遇到过类似的问题。尝试使用以下方法:
[ServiceContract(Namespace = "")]
显然,前缀是由名称空间决定的,所以如果您想删除它,那么这就是最好的选择
祝你好运 因此,这实际上是一个更大问题的答案。我有一个服务项目,在其他项目中用作WCF引用和二进制引用。。由于其中一些站点的位置,我必须为不同的应用程序公开不同的服务,这意味着名称空间将根据它的使用位置而改变。设置空白命名空间允许我仅通过Web配置来设置URI。