2011-08-25 5 views
3

WCFTestClient를 사용하여 자체 호스팅 wcf 서비스를 테스트하려고합니다. 나는 오류과 같이 얻을 다음과 같이WCFTestClient를 통해 셀프 호스트 WCF 서비스를 테스트 할 수 없습니다.

Error: Cannot obtain Metadata from http://localhost:2303/MyService If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost:2303/MyService Metadata contains a reference that cannot be resolved: 'http://localhost:2303/MyService'. Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:2303/MyService . The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..HTTP GET Error URI: http://localhost:2303/MyService There was an error downloading 'http://localhost:2303/MyService'. The request failed with HTTP status 400: Bad Request.

내 프로젝트 구조가

    호스트 역할을
  1. 콘솔 응용 프로그램을 여기에
  2. 서비스 계약
  3. 서비스 구현

된다 내 서비스 구현 및 계약 클래스는 두 개의 개별 프로젝트에 있습니다.

namespace MyService 
{ 
    public class MyService : IMyService 
    { 
     public string GetGreeting(string name) 
     { 
      return "Hello " + name; 
     } 

     public string GetYelling(string name) 
     { 
      return "What the hell " + name + "!!"; 
     } 
    } 
} 

namespace MyService 
{ 
    [ServiceContract] 
    public interface IMyService 
    { 
     [OperationContract] 
     string GetGreeting(string name); 

     [OperationContract] 
     string GetYelling(string name); 
    } 
} 

이 콘솔 응용 프로그램

namespace MyWCFHost 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 

      ServiceHost serviceHost = new ServiceHost(typeof(MyService.MyService), new Uri("http://localhost:2303")); 
      serviceHost.Open(); 

      Console.WriteLine("MyService is running..."); 
      Console.ReadKey(); 
      serviceHost.Close(); 
     } 
    } 
} 

이는 설정 파일 내가 잘못 뭐하는 거지

<configuration> 

    <system.serviceModel> 
    <services> 
     <service name ="MyService.MyService" behaviorConfiguration="MyService.MyServiceBehavior"> 
     <endpoint address="http://localhost:2303/MyService" binding="basicHttpBinding" contract="MyService.IMyService"/> 
     <endpoint address="mex" binding="mexHttpBinding" name="mexpoint" contract="IMetadataExchange" /> 
     </service> 

    </services> 

    <behaviors> 
     <serviceBehaviors> 
     <behavior name="MyService.MyServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 

    </system.serviceModel> 


</configuration> 

이다? 시간에 대한

감사합니다 ...

편집

나는 윈폼 클라이언트를 통해 그것을 실행하려고하면 서비스가 작동 그래서 서비스가 작동 알고있다. 질문은 WcfTestClient를 사용하여 어떻게 테스트 할 준비가되었는지입니다.

+1

offtopic하지만 당신의 네임 스페이스와 같은 클래스의 이름을 가지고 있습니다. 라인 아래에있는 혼동을위한 완벽한 요소입니다. – V4Vendetta

+0

나는 동의합니다. 그러나 이것은 연구 프로젝트이므로, 그렇게하도록하겠습니다. – user20358

답변

3

MEX 엔드 포인트에 문제가 있다고 생각됩니다. 현재 만 상대 주소를 ("MEX")을 지정하고 -하지만 서비스에 정의 된 HTTP에 대한 기본 주소 ......에

내가 제안이 없다 :

  • 중 하나는 정의가 일반 및 MEX 엔드 포인트

OR을 위해 - 그의 "위에"단지 상대 주소를 사용하고 기본 주소 :

  • 전체, 전체 주소로 주소를 정의 - 일반 엔드 포인트뿐 아니라 MEX 엔드 포인트의 경우에도 마찬가지입니다.

그래서 할 수 있도록 설정을 변경 뭔가 같은 :

<service name ="MyService.MyService" behaviorConfiguration="MyService.MyServiceBehavior"> 
    <endpoint 
     address="http://localhost:2303/MyService" 
     binding="basicHttpBinding" 
     contract="MyService.IMyService"/> 
    <endpoint name="mexpoint" 
     address="http://localhost:2303/MyService/mex" 
     binding="mexHttpBinding" 
     contract="IMetadataExchange" /> 
    </service> 

하고 난 당신이 메타 데이터에서 얻을 따라서 귀하의 서비스에 연결할 수 있어야합니다 바랍니다!

+0

굉장해 !! 효과가있었습니다. 고마워. 마크. 그러나 이제 WcfTestClient에서 작업 중이므로 브라우저 창에서 URL http : // localhost : 2303/MyService를 누르면 뭔가를 볼 수 있는지 확인하려고했습니다. HTTP 400 요청이 잘못되었습니다. 여기에 어떤 포인터가 있니? – user20358

+0

또한 cassini 호스팅 서비스의 경우 기본 주소를 지정하지 않아도됩니다. 그 구성은 내가 작동하는 cassini 호스팅 wcf 서비스에서 꺼낸 것입니다. 카시니가 커버 아래에 뭔가를 추가하고 있습니까? – user20358

+1

@ user20358 : ** SOAP ** 서비스 - 브라우저에서 SOAP 서비스에 "도달"할 수 없습니다. 브라우저는 SOAP을 말하지 않습니다. http : // localhost : 2303/MyService/mex? WSDL' –

1

Windows 7을 사용하고 있습니까?

시도 실행 :

netsh http add urlacl url=http://+:2303/MyService user=DOMAIN\user 

info 여기 too

+0

예, Win 7을 사용하고 있습니다. 또한 DOMAIN \ user에 대해 무엇을 넣어야합니까? 저는 어떤 도메인에도 연결되지 않은 가정용 PC에서이 프로그램을 실행하고 있습니다. 사용자가 로그인 한 사용자 일 필요가 있습니까? – user20358

+0

서비스가 작동 중임을 알 수 있도록 서비스를 winforms 클라이언트를 통해 실행하려고하면 서비스가 작동합니다. 질문은 WcfTestClient를 사용하여 어떻게 테스트 할 준비가되었는지입니다. – user20358

+0

명령 netsh http add urlacl url = http : // + : 2303/MyService 사용자 = PCNAME \ mylogin이 내게 이렇게했습니다 : URL 예약 추가 실패, 오류 : 87 – user20358

0

시도는 관리자로 비주얼 스튜디오를 실행합니다. 그런 다음 (url = http : // + : 2303/MyService 사용자 = PCNAME \ mylogin)과 같은 명령을 수동으로 실행할 필요가 없습니다.

+0

admin으로 실행하고있다. – user20358

관련 문제