2010-05-25 77 views
2

我在使用ADO.NET iSeries驱动程序的c#应用程序中连接IBM.Iseries数据库。我的WCF服务正在抛出错误为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也会抛出错误。在哪里需要更改端口地址

+0

问题也没有使用任何IBM数据访问。普通的Hello World也会抛出错误。我需要更改端口地址。 – renjucool 2010-05-25 13:59:12

+0

我已将端口更改为8080,然后错误仍然存​​在 – renjucool 2010-05-25 14:31:16

+0

您可以发布相应的服务器app.config部分吗? – Vitalik 2010-05-25 15:18:17

回答

1

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

WCF会自动附加一个GUID到基地址,以确保它生成一个唯一的端点地址,但它当然需要它可以监听的端口号。有关配置部分的文档,请参见this MSDN page。它应该大致是这样的:

<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或其他“简单”绑定之一。 Here是WCF附带的绑定类型列表。

+0

当我停止iis服务正在工作 – renjucool 2010-05-26 05:29:36

+0

我需要wsDualHttpBinding作为wcf服务需要在双工模式下与Windows工作流进行通信。 – renjucool 2010-05-26 05:32:05

+0

@renjucool:这很有道理,因为它使用的是端口80.告诉它使用另一个端口,如上面配置中所示。 – Thorarin 2010-05-26 05:42:03