2011-02-08 125 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,您应该能够从客户端配置中删除其中一个端点。