没有端点监听WCF休息服务?

时间:2014-07-23 09:47:14

标签: c# web-services wcf rest wcf-rest

我正在调用一个服务来检索产品列表但是当它为检索列表进行读取时,它会给出异常:

  

没有端点侦听可以接受该消息。这通常是由错误的地址或SOAP操作引起的。有关更多详细信息,请参阅InnerException(如果存在)。

我的c#代码为

  ProductRestService.ProductRESTServiceClient pro = new ProductRestService.ProductRESTServiceClient("ProductRestService");
  var prodcuts = pro.GetProductList(); //Generating exception here

客户服务模型是

<system.serviceModel> 
      <bindings>
        <webHttpBinding>
          <binding name="WebHttpBinding_IProductRESTService" />
        </webHttpBinding>
      </bindings>
      <client>     
        <endpoint address="http://localhost:1175/ProductRestService.svc/" binding="webHttpBinding"  behaviorConfiguration="web" bindingConfiguration="WebHttpBinding_IProductRESTService" contract="ProductRestService.IProductRESTService" name="ProductRestService" />
      </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

我的服务web.config如下:

 <system.serviceModel>
    <services>
      <service name="WcfService1.ProductRestService"
               behaviorConfiguration="serviceBehavior">
    <endpoint address="ProductRestService" binding="webHttpBinding" contract="WcfService1.IProductRESTService"
              behaviorConfiguration="web"></endpoint>
    </service>
    </services>
      <behaviors>
        <serviceBehaviors>
          <behavior name="serviceBehavior">
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="false"/>
          </behavior>
        </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
      </behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> 
  </system.serviceModel>

请知道如何解决这个问题!

0 个答案:

没有答案