首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WCF端口配置错误

WCF端口配置错误
EN

Stack Overflow用户
提问于 2009-07-06 11:09:53
回答 2查看 10.1K关注 0票数 4

我有两个服务,通过一个配置文件进行配置。它们每个都监听一个http和一个https地址。问题是如何配置端口。如果我将http端口配置为相同的值,将https端口配置为另一个值,则在调试整个项目时,将在WCF服务主机中获得以下错误消息:

System.ServiceModel.AddressAlreadyInUseException:状态:错误的TCP无法注册

https://+:8002/Services/xxxService/,因为另一个应用程序正在使用端口8002。-> System.Net.HttpListenerException:进程无法访问该文件,因为它正被另一个进程使用

如果我将四个端口(http和https)配置为具有不同的值,并且没有一个https值是IIS中配置和认证的ssl端口的值,则在服务调用时会得到以下异常(但这两个服务都是在WCF服务主机中启动的):

https://localhost:8000/Services/yyyService/发出HTTP请求时发生错误。这可能是因为在HTTPS情况下,服务器证书没有正确配置HTTP.SYS。这也可能是由于客户端和服务器之间的安全绑定不匹配造成的。

如果我将第一个服务配置为使用SSL端口(443),那么只启动第二个服务(带有“错误”https端口的服务)。第一个服务的错误消息是:

System.ServiceModel.AddressAlreadyInUseException: HTTP无法注册

https://+:443/Services/xxxService/,因为另一个应用程序正在使用端口443。-> System.Net.HttpListenerException:进程无法访问该文件,因为它正被另一个进程使用

更重要的是,当调用第二个服务时,我会得到一个异常:

https://localhost/Services/yyyService/发出HTTP请求时发生错误。这可能是因为在HTTPS情况下,服务器证书没有正确配置HTTP.SYS。这也可能是由于客户端和服务器之间的安全绑定不匹配造成的。

当我将这两个服务配置为对https使用443时,嗯.那就什么都没有了。我得到了各种各样奇怪的例外--客户证书是只读的,握手遇到了意想不到的数据包格式,一些关于远程地址的事情等等。

我在web.config中将这两个地址配置如下:

代码语言:javascript
复制
<baseAddresses>
            <add baseAddress="http://localhost:port1/Services/xxxService/"   />
            <add baseAddress="https://localhost:port2/Services/xxxService/"   />
          </baseAddresses>

[...]

<baseAddresses>
            <add baseAddress="http://localhost:port3/Services/yyyService/"   />
            <add baseAddress="https://localhost:port4/Services/yyyService/"   />
          </baseAddresses>

我已经尝试了两天了,所以如果你能帮忙的话,我将不胜感激。

PS。在Visual中,我已经将IIS配置为开发服务器,而不是内置的visual Studio web开发服务器。

编辑:

代码语言:javascript
复制
 <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

    <services>
      <service name="namespace.xxxService"
               behaviorConfiguration="default">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000/Services/xxxService/"   />
            <add baseAddress="https://localhost:8001/Services/xxxService/"   />
          </baseAddresses>
        </host>
        <endpoint address=""
                  binding="wsHttpBinding"
                  bindingConfiguration="defaultWsHttpBinding"
                  contract="namespace.IxxxService" />

        <endpoint address="mex/"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange"
                  bindingConfiguration="" />
      </service>
      <service name="namespace.yyyService" behaviorConfiguration="default">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8003/Services/yyyService/" />
            <add baseAddress="https://localhost:8004/Services/yyyService/" />
          </baseAddresses>
        </host>
        <endpoint address=""
                  binding="wsHttpBinding"
                  bindingConfiguration="defaultWsHttpBinding"
                  contract="namespace.IyyyService" />

        <endpoint address="mex/"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>

    <client>
<endpoint address="https://localhost:8001/Services/xxxService/"
          binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IxxxService"
          contract="namespace.IxxxService" name="WSHttpBinding_IxxxService" />
      <endpoint address="https://localhost:8001/Services/yyyService/"
          binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IyyyService"
          contract="namespace.IyyyService" name="WSHttpBinding_IyyyService" />

    </client>

    <behaviors>
      <serviceBehaviors>
        <behavior name="default">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />

          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="MembershipProvider"
                                    membershipProviderName="SqlMembershipProvider" />
          </serviceCredentials>

          <serviceAuthorization principalPermissionMode="UseAspNetRoles"
                                roleProviderName="SqlRoleProvider" />

        </behavior>
      </serviceBehaviors>
    </behaviors>

    <bindings>

      <wsHttpBinding>
        <binding name="defaultWsHttpBinding">
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName" />
            <transport clientCredentialType="None" />
          </security>
        </binding>

        <binding name="WSHttpBinding_IyyyService" 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="TransportWithMessageCredential">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" negotiateServiceCredential="true"
                algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
        <binding name="WSHttpBinding_IxxxService" 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="TransportWithMessageCredential">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" negotiateServiceCredential="true"
                algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>

    </bindings>

  </system.serviceModel>
EN

回答 2

Stack Overflow用户

发布于 2009-07-06 14:02:03

您的错误“服务器证书未正确配置”可能与使用"localhost“访问服务有关。您的证书可能使用其他东西,例如机器名。

尝试将地址更改为计算机名。

您还需要在配置中指定将传输安全性用于https端点。

票数 1
EN

Stack Overflow用户

发布于 2009-07-06 11:26:47

是否将SSL证书配置为端口?(如果端口可用于您的服务)是否尝试在IIS中承载您的服务?

http://msdn.microsoft.com/en-us/library/ms733791.aspx

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1086478

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档