WCF服务生成的WSDL

时间:2016-10-21 15:06:52

标签: c# web-services wcf wsdl

我有一个使用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>

这是我的Webconfig:

    <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>

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

1 个答案:

答案 0 :(得分:0)

那是因为你的自定义配置, 从我测试的内容来看,我非常感兴趣,假设我定义了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>

EndPointReference中没有wsdl。 我认为默认情况下EndPointRefrencenet.tcpnet.pipe等其他协议wsdlEndPoint,如下所示:

<endpoint address="" binding="netTcpBinding" contract="interfaceContract">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="" binding="netNamedPipeBinding" contract="interfaceContract" />
希望这会给你一些线索。