【问题标题】:WCF Service Generated WSDLWCF 服务生成的 WSDL
【发布时间】:2016-10-21 15:06:52
【问题描述】:

我有一个使用 Visual Studio 创建的 WCF 服务。生成的 WSDL 有一部分我不想要,但是不知道从哪里来的。

-<wsdl:service name="AdfsService">
-<wsdl:port name="CustomBinding_IAdfsService" binding="tns:CustomBinding_IAdfsService">

<soap12:address location="https://localhost/AdCustomerService/AdfsService.svc"/>


-<wsa10:EndpointReference>

<wsa10:Address>https://localhost/AdCustomerService/AdfsService.svc</wsa10:Address>

</wsa10:EndpointReference>

</wsdl:port>

</wsdl:service>

我需要删除的是:

-<wsa10:EndpointReference>

<wsa10:Address>https://localhost/AdCustomerService/AdfsService.svc</wsa10:Address>

</wsa10:EndpointReference>

这是我的网络配置:

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>


      <customBinding>
        <binding name="CustomTransportSecurity">
          <transactionFlow />
          <textMessageEncoding />
          <httpsTransport />
        </binding>
      </customBinding>      
    </bindings>    


    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping> 

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false"/>

    <services>
      <service name="webservices.portalx.AdfsService">
        <endpoint address="" contract="webservices.portalx.IAdfsService" 
                  bindingNamespace="webservices.portalx" binding="customBinding"
                  bindingConfiguration ="CustomTransportSecurity"/>
        <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpsBinding"/>
      </service>
    </services>

  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="ApplicationInsightsWebTracking"/>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
        preCondition="managedHandler"/>
    </modules>

    <directoryBrowse enabled="true"/>
    <validation validateIntegratedModeConfiguration="false"/>    
  </system.webServer>

谁能指出我要寻找的方向?我尝试用谷歌搜索,但没有找到任何有用的链接。

【问题讨论】:

  • 您尝试过发布的解决方案吗?

标签: c# web-services wcf wsdl


【解决方案1】:

那是因为您的自定义配置, 从我测试的结果来看,我非常感兴趣,假设我定义和 Endpoint 是这样的:

<endpoint address="" binding="customBinding" bindingConfiguration="x" contract="interfaceContract">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>

然后定义自定义绑定如下:

<customBinding>
    <binding name="x"  openTimeout="00:00:10" >
      <binaryMessageEncoding/>
      <httpsTransport/>
    </binding>
  </customBinding>

您将在托管服务后看到类似的内容:

    <wsa10:EndpointReference>
      <wsa10:Address>https://localhost:2061/PCM/Exam.svc</wsa10:Address>
      <Identity xmlns="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity">
      <Dns>localhost</Dns>
      </Identity>
    </wsa10:EndpointReference>

另一方面,当我像这样定义我的端点服务时,没有自定义绑定:

 <endpoint address="" binding="basicHttpBinding" contract="MARCO.SOA.PCMServiceLib.IExamService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>

基本绑定如:

<basicHttpBinding>
    <binding allowCookies="true" openTimeout="00:00:10" maxReceivedMessageSize="2000000000" >
      <readerQuotas maxDepth="32" maxArrayLength="2000000000" maxStringContentLength="2000000000" />
      <security mode="None" />
    </binding>
  </basicHttpBinding>

wsdl 中没有 EndPointReference。 我认为当你定义EndPoint 时,默认情况下wsdl 中的net.tcpnet.pipe 等另一个协议有EndPointRefrence,例如:

<endpoint address="" binding="netTcpBinding" contract="interfaceContract">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="" binding="netNamedPipeBinding" contract="interfaceContract" />

希望这会给你提供线索。

【讨论】:

  • 删除绑定配置广告附加数据到 wsa10:Endpointreference。我开始使用 wsHttpBinding 并遇到与 customBinding 相同的问题。显示的解决方案都没有完全删除 wsa10:Endpointreference。
  • 你确定吗?我再次测试了它,通过删除另一个端点配置我在wsdl 中看不到任何EndPointRefrence
  • Inweb.config 我在wsdl 的绑定元素中只有端点元素&lt;endpoint address="" binding="basicHttpBinding" contract="contract"&gt;&lt;basicHttpBinding&gt; 输出没有EndPointReference
  • 它是绑定类型。使用的 wsHttpBinding 生成端点引用。我确实将其更改为 basicHttpsbinding,因为我不想使用不安全的连接。非常感谢您的帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-04-16
  • 1970-01-01
  • 2013-02-11
  • 1970-01-01
  • 1970-01-01
  • 2012-06-06
  • 2010-11-16
相关资源
最近更新 更多