如果排除了bindingNamespace属性,则webHttpBinding端点会在WSDL中添加temuri.org



我有一个WCF服务,需要通过SOAP端点(wsHttpBinding)和REST端点(webHttpBinding。我在相关属性中包含了名称和命名空间,以帮助进行版本控制(tempuri.org应该从WSDL中完全删除)。出于某种原因,如果我不在webHttpBinding端点上添加bindingNamespace属性,它就会在WSDL中添加一个tempuri.org命名空间。WSDL输出示例如下。

不带绑定的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">

这是我的网。为端点配置。我使用WCFExtra来压平我的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>

我已经在我的解决方案中加载了WCFExtra,并查看了WsdlExporter,看看我是否能找到tempuri.org的提及,但没有成功。我还使用了XSharper.Core来转储对象图,看看我是否能找到它。它不在那里。

以前有人经历过这种情况吗?作为解决方案,我将在webHttpBinding端点上包含bindingNamespace,以保持WSDL的干净,但我想知道为什么会发生这种情况。

谢谢!

端点配置中似乎需要BindingNamespace才能从WSDL中完全删除tempuri.org命名空间。见本帖(项目3)。

相关内容

  • 没有找到相关文章

最新更新