2009-08-26 107 views
1

我已經開發了一個WCF服務,我必須託管在IIS它,作爲跟隨在使用IIS託管的wcf服務時出現問題?

<%@ ServiceHost Language="C#" Debug="true" Service="ServiceImplemetation.HelloService" %> 

SVC文件和web.config文件的system.servicemodel部分如下:

<system.serviceModel> 
    <behaviors> 
    <serviceBehaviors> 
     <behavior name="MetadataBehavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     </behavior> 
     <behavior name="WebApplication1.Service1Behavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     <behavior name="WebApplication1.MyHelloBehavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
    </serviceBehaviors> 
    </behaviors> 
    <services> 
    <service name="ServiceImplemetation.HelloService" 
       behaviorConfiguration="MetadataBehavior"> 
     <endpoint address="" 
        binding="basicHttpBinding" 
        contract="ServiceContracts.IHello" /> 
     <endpoint address="mex" 
        binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 

服務優良運行,現在我已經創建了一個Web客戶端消費服務和如下所寫web.config文件的cleint部分:

<system.serviceModel> 
    <behaviors> 
    <endpointBehaviors> 
     <behavior name="wsServiceBehaviour"> 
     <dataContractSerializer maxItemsInObjectGraph="6553600"/> 
     </behavior> 
    </endpointBehaviors> 
    </behaviors> 
    <client> 
    <endpoint address="http://localhost:8379/HelloService/" 
       binding="basicHttpBinding" 
       behaviorConfiguration="wsServiceBehaviour" 
       contract="ServiceContracts.IHello" 
       name="BasicHttpBinding_IIHello" /> 
    </client> 
</system.serviceModel> 

現在,當我訪問這個服務我收到以下錯誤:

無連接可以作出,因爲目標機器積極地拒絕它127.0.0.1:8379

我猜測這是錯誤的問題地址,但我不知道哪裏是錯誤... 有人可以看看這個問題...

回答

1

如果您在IIS中託管,則不能使用自己的基址 - 您的服務URL將成爲保存SVC文件的虛擬目錄的URL,以及SVC文件,以及服務端點上的任何相關地址。

在你的是,你應該連接到:在您的system.serviceModel節

http://myserver/MyVirtualDirectory/MyService.svc/ 

任何配置的「基址」(你離開了,很不幸地)會,如果你使用IIS託管您是無用WCF服務。

Marc

0

通常,IIS配置爲運行在端口80上,而不是端口8379.我認爲那就是問題所在。