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.
내 프로젝트 구조가
-
호스트 역할을
- 콘솔 응용 프로그램을 여기에
- 서비스 계약
- 서비스 구현
된다 내 서비스 구현 및 계약 클래스는 두 개의 개별 프로젝트에 있습니다.
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를 사용하여 어떻게 테스트 할 준비가되었는지입니다.
offtopic하지만 당신의 네임 스페이스와 같은 클래스의 이름을 가지고 있습니다. 라인 아래에있는 혼동을위한 완벽한 요소입니다. – V4Vendetta
나는 동의합니다. 그러나 이것은 연구 프로젝트이므로, 그렇게하도록하겠습니다. – user20358