簡體   English   中英

我的wcf端點怎么了?

[英]What's wrong with my wcf endpoints?

我正在嘗試使用兩個端點(一個SOAP 1.1和另一個SOAP 1.2)創建一個wcf服務。 這是我的配置:

<?xml version="1.0"?>
<configuration>

<configSections>
</configSections>
<connectionStrings>
<add name="ProgramInformationWS.Properties.Settings.IMTConnectionString" connectionString="Data Source=DLADD00001;Initial Catalog=IMT;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true"/>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's 
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
  <service name="EnterpriseReportingWS.ERPService" behaviorConfiguration="ERPService.Behavior">
      <endpoint address="soap" binding="basicHttpBinding" bindingConfiguration="" contract="EnterpriseReportingWS.IERPService">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
      <endpoint address="soap12" binding="wsHttpBinding" bindingConfiguration="" contract="EnterpriseReportingWS.IERPService">
          <identity>
              <dns value="localhost"/>
          </identity>
      </endpoint>         
    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://MyServerHere/ERPService/"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
<serviceBehaviors>
    <behavior name="ERPService.Behavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
</system.serviceModel>

<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>

我要在這里配置的是當我點擊

http://caaditl20bz3.national.edu/ERPService/EnterpriseReportingWS.ERPService.svc/soap

我得到SOAP 1.1,當我點擊

http://caaditl20bz3.national.edu/ERPService/EnterpriseReportingWS.ERPService.svc/soap12

我得到SOAP 1.2。 但是,我得到的行為是沒有一個解決,而我訪問服務的唯一方法是從

http://caaditl20bz3.national.edu/ERPService/EnterpriseReportingWS.ERPService.svc

我搞砸了什么?

更新:通過刪除wshttpbinding端點並僅在配置中使用basichttpbinding端點,我可以獲得get SOAP 1.1。 我需要做什么才能使兩者都可用?

這是一種方法:

<system.serviceModel>
  <services>
    <service behaviorConfiguration="Service1Behavior" name="WcfTest.Service1">
      <endpoint address="" contract="WcfTest.IService1" binding="wsHttpBinding" />
      <endpoint address="/basic/" binding="basicHttpBinding" contract="WcfTest.IService1" />
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="Service1Behavior">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

在上面的示例中,我將wsHttpBinding放在根地址http://server/service1.svc上,basicHttpBinding可以在http://server/service1.svc/basic/上找到。 請注意,您將無法在瀏覽器中看到http://server/service1.svc/basic/ ,但這並不意味着它不存在。

要在Visual Studio中添加對wsHttpBinding端點的引用,只需像通常那樣添加服務引用即可。 要添加對basicHttpBinding端點的引用,請轉到“添加服務引用”屏幕的高級設置對話框,然后選擇“添加Web引用”。

請注意,在添加Web參考時,要為basicHttpBinding端點生成客戶端代理,必須使用http://server/service1.svc不是 http://server/service1.svc/basic/ 但是,如果仔細查看客戶端上生成的.config文件,您會發現它使用/ basic /端點,如下所示:

<endpoint address="http://server/Service1.svc/basic/"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
    contract="Service1Reference.IService1" name="BasicHttpBinding_IService1" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM