我有一个需要通过SOAP端点(wsHttpBinding)和REST端点(webHttpBinding)公开的WCF服务。我在相关属性上包含了Names和Namespaces以帮助进行版本控制(tempuri.org应该完全从WSDL中删除)。出于某种原因,如果我不在webHttpBinding端点上添加bindingNamepace属性,它会在WSDL中添加tempuri.org命名空间。示例WSDL输出如下。
没有bindingNamespace的WSDL -
<wsdl:definitions name="State" targetNamespace="http://example.com/services/masterdat/state/2012/02/05"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:tns="http://example.com/services/masterdata/state/2012/02/05"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:i0="http://tempuri.org/"
xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
xmlns:wsa10="http://www.w3.org/2005/08/addressing"
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
带有bindingNamespace的WSDL -
<wsdl:definitions name="State" targetNamespace="http://example.com/services/masterdata/state/2012/02/05"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:tns="http://example.com/services/masterdata/state/2012/02/05"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
xmlns:wsa10="http://www.w3.org/2005/08/addressing"
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
这是我的端点的web.Config。我正在使用WCFExtras来展平我的WSDL(因此wsHttpBinding端点上的behaviorConfiguration),但没有它的行为是相同的。
<services>
<service name="MasterDataExample.Services.StateService">
<!-- bindingConfiguration="defaultWsBinding" -->
<endpoint address="soap"
behaviorConfiguration="flatWsdl"
binding="wsHttpBinding"
bindingNamespace="http://example.com/services/masterdata/state/2012/02/05"
contract="MasterDataExample.Services.IStateService"
name="soap" />
<!-- -->
<endpoint address="json"
behaviorConfiguration="json"
binding="webHttpBinding"
bindingNamespace="http://example.com/services/masterdata/state/2012/02/05"
contract="MasterDataExample.Services.IStateService"
name="ajax" />
</service>
</services>
我已经在我的解决方案中加载了WCFExtras并查看了WsdlExporter,看看我是否可以找到提及tempuri.org但没有成功。我还使用XSharper.Core转储对象图,看看我是否能找到它。它不存在。
以前有没有人经历过这个?作为解决方法,我将在webHttpBinding端点上包含bindingNamespace以保持WSDL清洁,但我想知道为什么会发生这种情况。
谢谢!