2

我正在使用 ADO.NET iSeries 驱动程序在 ac# 应用程序中连接 IBM.Iseries 数据库。我的 WCF 服务将错误抛出为

“HTTP 无法注册 URL http://+:80/Temporary_Listen_Addresses/771be107-8fa3-46f9-ac01-12c4d503d01e/,因为另一个应用程序正在使用 TCP 端口 80。”

 <system.serviceModel>
<client>
  <endpoint address="http://localhost:8080/Design_Time_Addresses/DataAccessLayer/POEngine/"
    binding="wsDualHttpBinding"  bindingConfiguration="" contract="POServiceReference.IPOEngine"
    name="MyPoBindings">
    <identity>
      <dns value="localhost" />
    </identity>
  </endpoint>
  <endpoint address="http://localhost:8080/Design_Time_Addresses/DataAccessLayer/POEngine/"
    binding="wsDualHttpBinding" bindingConfiguration="PoBindings1"
    contract="POServiceReference.IPOEngine" name="PoBindings">
    <identity>
      <dns value="localhost" />
    </identity>
  </endpoint>
</client>
<bindings>
  <wsDualHttpBinding>
    <binding name="PoBindings1" 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">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00" />
      <security mode="Message">
        <message clientCredentialType="Windows" negotiateServiceCredential="true"
          algorithmSuite="Default" />
      </security>
    </binding>
  </wsDualHttpBinding>
  <wsHttpBinding>
    <binding name="PoBindings" />
  </wsHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="DataAccessLayer.POEngineBehavior"
    name="DataAccessLayer.POEngine">
    <endpoint address="" binding="wsDualHttpBinding" bindingConfiguration=""
      name="PoBindings" contract="DataAccessLayer.IPOEngine">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8080/Design_Time_Addresses/DataAccessLayer/POEngine/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="NewBehavior" />
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="DataAccessLayer.Service1Behavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
    <behavior name="DataAccessLayer.POEngineBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>  </system.serviceModel>

在不使用任何 IBM 数据访问的情况下也有问题。一个普通的 Hello World 也会抛出错误。我需要在哪里更改端口地址

4

1 回答 1

1

“问题”是您使用的是 wsDualHttpBinding,用于双工合同(服务器回调客户端)。你需要这个功能吗?如果这样做,则需要通过clientBaseAddress在绑定配置中指定 a 来为其提供一个地址供客户端监听。此外,您需要告诉端点使用 PoBindings1 绑定配置。

WCF 会自动将 GUID 附加到基地址,以确保它生成唯一的端点地址,但它当然需要一个可以侦听的端口号。有关配置部分的文档,请参阅此 MSDN 页面。它应该大致如下所示:

<system.serviceModel>
    <!-- client section omitted -->
    <bindings>
        <wsDualHttpBinding>
            <binding name="PoBindings1"
                     clientBaseAddress="http://localhost:8080/Callbacks/">
                <!-- extra config elements and attributes omitted -->
            </binding>
        </wsDualHttpBinding>
    </bindings>
    <services>
        <service behaviorConfiguration="DataAccessLayer.POEngineBehavior"
            name="DataAccessLayer.POEngine">
            <endpoint address=""
                      binding="wsDualHttpBinding"
                      bindingConfiguration="PoBindings1"
                      name="PoBindings" contract="DataAccessLayer.IPOEngine">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost:8080/Design_Time_Addresses/DataAccessLayer/POEngine/" />
                </baseAddresses>
            </host>
        </service>
    </services>
    <!-- behaviors omitted -->
</system.serviceModel>

如果您使用双工合同,这就是服务合同通常的样子:

[ServiceContract(CallbackContract = typeof(IMyCallbackContract))]
interface IMyContract
{
    [OperationContract]
    void DoSomething();
}

interface IMyCallbackContract
{
   [OperationContract]
   void OnCallback();
}

如果您不需要回调功能,则应该使用 WSHttpBinding 或其他“简单”绑定之一。是 WCF 附带的绑定类型列表。

于 2010-05-26T05:08:26.040 回答