2009-08-26 106 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.我认为那就是问题所在。