0

我们有一个外部客户端将用来提供请求的 wcf Web 服务。此 Web 服务(Web 服务)调用另一个实现业务逻辑的 wcf 服务(代理)。

代理还监视数据库中的活动,当请求的信息准备好时(通常是几天后),代理会生成一个包含请求数据的对象。它需要将对象传递给 Web 服务,Web 服务将在其中形成 XML 并将其发布到客户端 Web 服务。

Web 服务实现了两种不同的接口,一种是客户端使用的,一种是代理使用的。

问题是,在本地机器上,我无法让代理连接到 web 服务以发送结果。出于调试目的,Web 服务和代理都在我的本地计算机上运行。在 VisualStudio2012 中,webservice 项目设置为使用 IISExpress 并定义要使用的特定端口。项目 URL:https ://local.someaddress.net:51448/但是,代理用于尝试连接到 Web 服务的端口是不同的端口。

Web 服务能够很好地调用代理,但代理在尝试调用 Web 服务时会收到 tcp 错误代码 10061。

我已经尝试过“appcmd.exe set app”Default Web Site/“/enabledProtocols:http,net.tcp”。

是否可以将 IISExpress 配置为让 web 服务打开两个端口?还是我在这里遗漏了什么明显的东西?

(由于配置文件包含指向 localhost 的链接,而 stackoverflow 不允许这样做,我已将 localhost 替换为 local.someaddress.net。)

以下是 webservice 的 web.config 的内容:

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

  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" maxRequestLength="52428800"/>
  </system.web>
  <system.serviceModel>
    <client>
      <endpoint address="net.tcp://local.someaddress.net:8102/Acord/201307" behaviorConfiguration="NetTcpCertificatesBehavior" binding="netTcpBinding" bindingConfiguration="NetTcpCertificatesBinding" contract="AcordContract.IAcordService201307" name="AcordEndpoint">
        <identity>
          <certificateReference findValue="7da522dd75f3fca2687837b7b67e117a8700ec62" isChainIncluded="false" storeLocation="LocalMachine" x509FindType="FindByThumbprint" />
        </identity>
      </endpoint>
    </client>
    <services>
      <service name="AcordWebService.AcordWebService" behaviorConfiguration="Visible">
        <endpoint address="" binding="basicHttpsBinding" contract="AcordWebService.IAcordWebService" bindingConfiguration="BasicHttpsBinding">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
        <!--binding for clients outside the firewall calling from C# with WCF using certs -->
        <endpoint address="net.tcp://local.someaddress.net:8122/AcordWebService/201309" binding="netTcpBinding" bindingConfiguration="NetTcpCertificatesBinding" name="NetTcpCertificatesEndpoint" contract="AcordWSContract.IAcordWSService201309">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="NetTcpCertificatesBehavior">
          <clientCredentials>
            <clientCertificate findValue="631f5a67a9a70bc78540bb809e73fd1dbd00bbeb" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" />
            <serviceCertificate>
              <authentication certificateValidationMode="None" />
            </serviceCertificate>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="Visible">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceCredentials>
            <serviceCertificate findValue="7da522dd75f3fca2687837b7b67e117a8700ec62" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>
            <clientCertificate>
              <certificate findValue="631f5a67a9a70bc78540bb809e73fd1dbd00bbeb" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>
            </clientCertificate>
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpsBinding>
        <binding name="BasicHttpsBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </basicHttpsBinding>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IAcordWebService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="65535" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
        <binding name="WSHttpBinding_Mex" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="65535" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </wsHttpBinding>
      <netTcpBinding>
        <binding name="NetTcpCertificatesBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <security>
            <transport clientCredentialType="Certificate" protectionLevel="EncryptAndSign" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <protocolMapping>
      <add binding="wsHttpBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

以下是代理的 app.config 文件的内容:

<?xml version="1.0"?>
<configuration>
  <configSections>
  </configSections>
  <system.serviceModel>
    <client>
      <endpoint address="net.tcp://local.someaddress.net:8122/AcordWebService/201309" behaviorConfiguration="NetTcpCertificatesBehavior" binding="netTcpBinding" bindingConfiguration="NetTcpCertificatesBinding" contract="AcordWSContract.IAcordWSService201309" name="AcordWSEndpoint">
        <identity>
          <certificateReference findValue="7da522dd75f3fca2687837b7b67e117a8700ec62" isChainIncluded="false" storeLocation="LocalMachine" x509FindType="FindByThumbprint" />
        </identity>
      </endpoint>
      <endpoint address="net.tcp://qaschedapp:8001/IMS/201210" binding="netTcpBinding" bindingConfiguration="NetTcpWindowsBinding" contract="IdentityManagementContract.IIdentityManagementService201210" name="IMSEndpoint">
        <!--the name above cannot be changed-->
        <identity>
          <dns value="localhost"/>
        </identity>
      </endpoint>
      <endpoint address="net.tcp://qaschedapp:8012/CBS/201210" behaviorConfiguration="NetTcpCertificatesBehavior" binding="netTcpBinding" bindingConfiguration="NetTcpCertificatesBinding" contract="CrossbowContract.ICrossbowService201210" name="CBSEndpoint">
        <identity>
          <certificateReference findValue="7da522dd75f3fca2687837b7b67e117a8700ec62" isChainIncluded="false" storeLocation="LocalMachine" x509FindType="FindByThumbprint"/>
        </identity>
      </endpoint>
    </client>
    <diagnostics performanceCounters="Default"/>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpWindowsBinding">
          <security mode="Transport">
            <transport clientCredentialType="Windows"/>
          </security>
        </binding>
      </basicHttpBinding>
      <netTcpBinding>
        <binding>
          <readerQuotas maxDepth="32" maxStringContentLength="65535" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
        </binding>
        <binding name="NetTcpWindowsBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:10:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="65535" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
          <security mode="Transport">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
            <message clientCredentialType="Windows"/>
          </security>
        </binding>
        <binding name="NetTcpCertificatesBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <security>
            <transport clientCredentialType="Certificate" protectionLevel="EncryptAndSign"/>
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <services>
      <service name="AcordAgent.AcordService" behaviorConfiguration="AcordServiceBehavior">

        <endpoint address="http://qaschedapp:8100/Acord" binding="webHttpBinding" behaviorConfiguration="HttpWebGetBehavior" contract="AcordContract.IMeta" name="MetaEndpoint">
          <!--the name of this endpoint above (MetaEndpoint) must stay-->
        </endpoint>
        <!--binding for clients within the firewall calling from C# with WCF -->
        <endpoint address="net.tcp://qaschedapp:8101/Acord/201307" binding="netTcpBinding" bindingConfiguration="NetTcpWindowsBinding" name="NetTcpWindowsEndpoint" contract="AcordContract.IAcordService201307">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <!--binding for clients outside the firewall calling from C# with WCF using certs -->
        <endpoint address="net.tcp://qaschedapp:8102/Acord/201307" binding="netTcpBinding" bindingConfiguration="NetTcpCertificatesBinding" name="NetTcpCertificatesEndpoint" contract="AcordContract.IAcordService201307">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="HttpWebGetBehavior">
          <webHttp/>
        </behavior>
        <behavior name="NetTcpCertificatesBehavior">
          <clientCredentials>
            <clientCertificate findValue="631f5a67a9a70bc78540bb809e73fd1dbd00bbeb" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>
            <serviceCertificate>
              <authentication certificateValidationMode="None"/>
            </serviceCertificate>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="AcordServiceBehavior">
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceCredentials>
            <serviceCertificate findValue="7da522dd75f3fca2687837b7b67e117a8700ec62" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>
            <clientCertificate>
              <certificate findValue="631f5a67a9a70bc78540bb809e73fd1dbd00bbeb" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>
            </clientCertificate>
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
  </startup>
</configuration>
4

1 回答 1

0

我在 IIS Express 常见问题解答中发现了这一点:

问:IIS Express 是否支持非 HTTP 协议,例如 net.tcp 或 MSMQ?

答:不能。IIS Express 仅支持 HTTP 和 HTTPS 作为其协议。

看来这是我问题的根源。我需要在本地机器上安装 IIS。

于 2013-09-11T14:49:06.600 回答