2012-11-09 5 views
0

IIS 7에서 내 WCF 서비스를 호스팅하고 있는데 WCF 테스트 클라이언트를 사용할 때 제대로 작동하더라도 간단한 콘솔 응용 프로그램에서 서비스를 사용할 수 없습니다.IIS 호스팅 WCF 서비스

저는 이미 IIS에서 .svc 및 .wsdl 파일을 처리 할 수있었습니다. 내가 뭘 놓치고 있는지 모르겠다. 나는 나의 지역 IIS에서 서비스에 액세스 할 수 있습니다

static void Main(string[] args) { 
      EvalServiceClient client = new EvalServiceClient(); 

      client.SubmitEval(new Eval() { Comments = "Lorem Ipsum", Submitter = "egarcia", TimeSubmitted = DateTime.Now }); 

      List<Eval> evalList = client.GetEvals().ToList(); 

      foreach(var eval in evalList) { 
       Console.WriteLine(eval.Id); 
      } 

      client.Close(); 
     } 

:

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0"/> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service name="EvalServiceLibrary.EvalService"> 
     <endpoint address="http://localhost/WebEvalService" binding="basicHttpBinding" 
      bindingConfiguration="" name="basicHttpBinding" contract="EvalServiceLibrary.IEvalService" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false"/> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 

가 여기 내 클라이언트 코드의

namespace EvalServiceLibrary { 
    [ServiceContract] 
    public interface IEvalService { 
     [OperationContract] 
     void SubmitEval(Eval eval); 

     [OperationContract] 
     List<Eval> GetEvals(); 

     [OperationContract] 
     void RemoveEval(String id); 
    } 
} 

namespace EvalServiceLibrary { 
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] 
    public class EvalService : IEvalService { 
     #region 
     List<Eval> evals = new List<Eval>(); 

     public void SubmitEval(Eval eval) { 
      eval.Id = Guid.NewGuid().ToString(); 
      evals.Add(eval); 
     } 

     public List<Eval> GetEvals() { 
      return evals; 
     } 

     public void RemoveEval(String id) { 
      evals.Remove(evals.Find(e => e.Id.Equals(id))); 
     } 
     #endregion 
    } 
} 

그리고 내 Web.config의 : 여기

내 코드입니다 잘.

+0

고객 코드도 게시 할 수 있습니까? 서비스에 연결되는 부분. – JcFx

+0

서비스가 성공적으로 활성화되었는지 확인할 수 있습니까? URL http : // localhost/WebEvalService를 탐색하고 도움말 페이지를 참조하십시오. – Praburaj

답변

0

web.config 파일에 서비스 끝점 선언에 문제가 있습니다. ,

기본적으로
<service name="EvalServiceLibrary.EvalService"> 

    <!-- This endpoint is exposed at the http://localhost/EvalServiceLibrary/EvalService.svc--> 
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="" name="basicHttpBinding" contract="EvalServiceLibrary.IEvalService" /> 

    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service> 

,

  1. 엔드 포인트 주소가 잘못을이보십시오. Infact 당신은 지정할 필요가 없습니다.

  2. MexEndpoint를 추가하십시오.

관련 문제