2014-07-23 3 views
0

저는 초급부터 WCF service입니다. Wcf rest service를 만듭니다. 만약 내가 그것을 탐색이 잘 작동합니다.계약을 참조하는 기본 엔드 포인트 요소를 찾을 수 없습니까?

그런 다음 새로운 웹 응용 프로그램을 추가하고 해당 서비스에 대한 참조를 추가합니다. 서비스가 올바르게로드되었습니다. 그러나 web.config를 검사 할 때 서비스 모델과 비어있는 부분에 대한 세부 정보는 포함되어 있지 않습니다. 나는 구현과 내장이 오류를, 그것은 나누기 솔루션을 실행하고 제공 :

Could not find default endpoint element that references contract 'ProductRestService.IProductRESTService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

내 서비스 webconfig가 그대로 :

<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> 

나는대로 테스트를 implemeted :

if (!IsPostBack) 
    { 
     ProductRestService.ProductRESTServiceClient pro = new ProductRestService.ProductRESTServiceClient("ProductRestService"); 
     var prodcuts = pro.GetProductList(); 
     GridView1.DataSource = prodcuts; 
     GridView1.DataBind(); 
    } 

이고 클라이언트 web.config는 다음과 같이 비어 있습니다.

<configuration> 
    <system.web> 
     <compilation debug="true" targetFramework="4.5.1" /> 
     <httpRuntime targetFramework="4.5.1" /> 
    </system.web> 

</configuration> 

이 도움말은 어떻게 해결합니까?

답변

0
당신의 web.config 파일의 코드를 다음

추가하고이 문제가 해결됩니다,

<system.serviceModel> 
    <bindings> 
    <webHttpBinding> 
     <binding name="WebHttpBinding_IProductRESTService" /> 
    </webHttpBinding> 
    </bindings> 
    <client> 
    <endpoint address="http://{DomainName}/ProductRestService/" binding="webHttpBinding" bindingConfiguration="WebHttpBinding_IProductRESTService" contract="WcfService1.IProductRESTService" name="WebHttpBinding_IProductRESTService" /> 
    </client> 
</system.serviceModel>