2010-05-25 120 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