2012-09-14 74 views
0

我在以下位置有可用的服務文件。絕對路徑不適用於WCF服務

C:\Documents and Settings\U16990\My Documents\Visual Studio 2010\Projects\CalculationService\CalculationService\CalculationService.svc

當我瀏覽了SVC文件,它工作正常。服務端點如下所列。它目前是用於地址的相對地址。我的機器

<service name="CalculationService.CalculationService" behaviorConfiguration="MyServiceTypeBehaviors"> 
    <endpoint address="CalculationService" behaviorConfiguration="" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_CalculationServiceInterface" 
     contract="ICalculationService" /> 
    </service> 

IP地址是10.10.179.180 //互聯網絡AddressFamily

當我更改地址使用絕對路徑,它拋出錯誤:

<services> 
    <service name="CalculationService.CalculationService" behaviorConfiguration="MyServiceTypeBehaviors"> 
    <endpoint 
    address="http://10.10.179.180/C:/Documents and Settings/U16990/My Documents/Visual Studio 2010/Projects/CalculationService/CalculationService/CalculationService.svc/CalculationService" 
    behaviorConfiguration="" 
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_CalculationServiceInterface" 
    contract="ICalculationService" /> 
    </service> 
</services> 

Error:: No protocol binding matches the given address ' http://10.10.179.180/C:/Documents and Settings/U16990/My Documents/Visual Studio 2010/Projects/CalculationService/CalculationService/CalculationService.svc/CalculationService'. Protocol bindings are configured at the Site level in IIS or WAS configuration. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

能有什麼我們是否要糾正它?

注意:我正在使用Visual Studio 2010測試該服務。

參考:

  1. Hosting a Simple Wcf Service in Console
  2. error "No protocol binding matches the given address ..."
  3. How to derive a website absolute file path from a WCF service hosted in IIS?

回答

1

端點地址不是一個文件的位置,但URI在該客戶端可以/會發現服務。你或許應該使用這樣的事:

<service name="CalculationService.CalculationService" behaviorConfiguration="MyServiceTypeBehaviors"> 
    <endpoint 
     address="http://10.10.179.180/CalculationService/CalculationService.svc" 
     behaviorConfiguration="" binding="basicHttpBinding" 
     bindingConfiguration="BasicHttpBinding_CalculationServiceInterface" 
     contract="ICalculationService" /> 
</service> 

在這種情況下,您使用的是完整的URI,而不是一個相對的。在你的客戶端中,你必須確保端點指向相同的地址,並且你很好。