2011-02-08 124 views
1

我有一個解決方案,它由一個web項目和一個類庫項目組成。 Web項目解決方案直接引用wcf服務。有第二個wcf服務,但它是直接引用它的類庫項目。我添加類庫(輸出)作爲我的web項目的參考。配置web.config(system.serviceModel)與多個Web服務通信的網站(一些通過dll)

因此,在我的web項目的web.config我現在有兩個scf服務配置。這個過程很簡單,因爲我手動將app.config(system.serviceModel部分)手動複製到web.config,,然後將Web項目配置爲直接與另一個wcf服務(不通過任何dll)直接交談。

我的web項目需要與第三個Web服務(asmx)交談。再次,我打算把這個作爲一個類庫,並將dll包含到我的web項目中。 (這是一個單獨的解決方案)。當我看看這個特定的類庫項目的app.config時,我想我只是複製這些必要的部分,並將其與我當前的web.config相對應地合併。

因此,對於第三類lib項目(引用asmx服務),我碰巧注意到它在綁定節點下有一個名爲basicHttpBinding的節點,接下來是一個customBinding。然後在客戶端節點的下面,有兩個具有服務屬性的端點節點。 (我不明白爲什麼首先應該有兩個端點)。

因此,我複製了綁定節點下的內容(來自第三個類lib prj app.config)並將其附加到綁定節點(在web.config中)。我也做了類似的過程來複制終點。但是現在,當我嘗試運行網站時,我得到一個異常,它在初始化soap客戶端(asmx服務)時停止:它說明類似它無法確定此合同的端點。

的web.config文件之前,我添加ASMX Web服務是這樣的:

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="WSHttpBinding_IEmployeeService" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" 
      textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <reliableSession ordered="true" inactivityTimeout="00:10:00" 
      enabled="false" /> 
      <security mode="Message"> 
      <transport clientCredentialType="Windows" proxyCredentialType="None" 
       realm="" /> 
      <message clientCredentialType="Windows" negotiateServiceCredential="true" 
       algorithmSuite="Default" /> 
      </security> 
     </binding> 
     <binding name="WSHttpBinding_IHelper" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" 
      textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <reliableSession ordered="true" inactivityTimeout="00:10:00" 
      enabled="false" /> 
      <security mode="Message"> 
      <transport clientCredentialType="Windows" proxyCredentialType="None" 
       realm="" /> 
      <message clientCredentialType="Windows" negotiateServiceCredential="true" 
       algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </wsHttpBinding>  
    </bindings> 
    <client> 
     <endpoint address="http://localhost:8731/Design_Time_Addresses/InfiniumIS/EmployeeService/" 
     binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IEmployeeService" 
     contract="InfiniumWS.IEmployeeService" name="WSHttpBinding_IEmployeeService"> 
     <identity> 
      <dns value="localhost" /> 
     </identity> 
     </endpoint> 
     <endpoint address="http://localhost:8732/Design_Time_Addresses/SQLIS/Service1/" 
     binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IHelper" 
     contract="SQLIS.IHelper" name="WSHttpBinding_IHelper"> 
     <identity> 
      <dns value="localhost" /> 
     </identity> 
     </endpoint> 
    </client> 
    </system.serviceModel> 

下面是與ASMX服務項目(從app.config中獲得)

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="ServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00" 
       receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" 
       bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
       messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
       useDefaultWebProxy="true"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
        maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       <security mode="Transport"> 
        <transport clientCredentialType="None" proxyCredentialType="None" 
         realm="" /> 
        <message clientCredentialType="UserName" algorithmSuite="Default" /> 
       </security> 
      </binding> 
      <binding name="ServiceSoap1" closeTimeout="00:01:00" openTimeout="00:01:00" 
       receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" 
       bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
       messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
       useDefaultWebProxy="true"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
        maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       <security mode="None"> 
        <transport clientCredentialType="None" proxyCredentialType="None" 
         realm="" /> 
        <message clientCredentialType="UserName" algorithmSuite="Default" /> 
       </security> 
      </binding> 
     </basicHttpBinding> 
     <customBinding> 
      <binding name="ServiceSoap12"> 
       <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" 
        messageVersion="Soap12" writeEncoding="utf-8"> 
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       </textMessageEncoding> 
       <httpsTransport manualAddressing="false" maxBufferPoolSize="524288" 
        maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous" 
        bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard" 
        keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous" 
        realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" 
        useDefaultWebProxy="true" requireClientCertificate="false" /> 
      </binding> 
     </customBinding> 
    </bindings> 
    <client> 
     <endpoint address="https://is.security/WebAppSec_WS/service.asmx" 
      binding="basicHttpBinding" bindingConfiguration="ServiceSoap" 
      contract="apps.intranet.ws.ServiceSoap" name="ServiceSoap" /> 
     <endpoint address="https://is.security/WebAppSec_WS/service.asmx" 
      binding="customBinding" bindingConfiguration="ServiceSoap12" 
      contract="apps.intranet.ws.ServiceSoap" name="ServiceSoap12" /> 
    </client> 
</system.serviceModel> 
服務模式

我簡單地合併了部分 - 意味着複製綁定節點下的第二個配置中的任何內容,然後將其添加到第一個配置節點中。我做了一個類似的複製端點的過程。

ps:我不知道爲什麼第二個配置(asmx)向我展示兩個端點?

+0

爲什麼不等到可以包含代碼? – RQDQ 2011-02-08 16:25:40

回答

0

ASMX結尾使用兩個不同的綁定。第一個綁定是HTTP,而第二個綁定是HTTPS。假設ASMX服務同時支持HTTP和HTTPS,您應該能夠從客戶端配置中刪除其中一個端點。