我有一个由 Web 项目和类库项目组成的解决方案。Web 项目解决方案直接引用 wcf 服务。有第二个 wcf 服务,但它是直接引用它的类库项目。我正在添加类库(输出)作为对我的 Web 项目的引用。
因此,在我的 web 项目的 web.config 中,我现在配置了两个 scf 服务。这个过程很简单,因为我手动将 app.config(system.serviceModel 部分)直接复制到 web.config,然后将 web 项目配置为直接与另一个 wcf 服务通信(直接,而不是通过任何 dll)。
我的 Web 项目需要与第三个 Web 服务 (asmx) 通信。我再次计划将其作为类库引入,并将 dll 包含到我的 Web 项目中。(这是一个单独的解决方案)。当我查看这个特定的类库项目的 app.config 时,我想我只是复制那些必要的部分并将其与我当前的 web.config 相应地合并。
所以对于第 3 个类库项目(它引用 asmx 服务),我碰巧注意到它在绑定节点下有一个名为 basicHttpBinding 的节点,然后是一个 customBinding。然后在客户端节点下方,有两个具有服务属性的端点节点。(我不明白为什么这里首先应该有两个端点)。
因此,我复制了绑定节点下的内容(来自 3rd class lib prj app.config)并将其附加到绑定节点(在 web.config 中)。我也做了类似的复制端点的过程。但是现在当我尝试运行该网站时,我得到一个异常,该异常在初始化soap客户端(asmx服务)时停止:它说它无法确定该合同的端点。
添加 asmx Web 服务之前的 web.config 如下所示:
<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)向我显示两个端点?