WCF 서비스를 보유하고 있으며 MSTest 프로젝트에서이 서비스에 대한 참조를 만들었습니다. 여기에 내가 서비스 메소드를 호출하고 방법 예는 다음과 같습니다WCF : 자신의 WCF 서비스를 호출 할 수 없습니다.
나는 다음과 같은 오류가있어 대신 실행의IEnrollmentService serviceClient = ChannelFactory<IEnrollmentService>
.CreateChannel(new BasicHttpBinding(),
new EndpointAddress("http://localhost/EnrollmentService.svc"));
PublishResult res = serviceClient.PublishEnrollmentProfile(...);
:
지금까지 내가 이해로, ContractFilter 및 EndpointDispatcher 사이에 약간의 문제가The content type application/xml; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 710 bytes of the response were: '
Sendera:ActionNotSupported
The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).'. ---> System.Net.WebException: The remote server returned an error: (500) Internal Server Error..
.
EnrollmentServiceClient serviceClient = new EnrollmentServiceClient("http://localhost/EnrollmentService.svc");
PublishResult res = serviceClient.PublishEnrollmentProfile(...);
나에게 또 다른 오류 반환 :
을 나는Could not find endpoint element with name ' http://localhost/McActivation/EnrollmentService.svc ' and contract 'EnrollmentServiceReference.IEnrollmentService' 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 name could be found in the client element..
나는 또한 다른 방법으로 WCF 서비스 메소드를 호출하려고했습니다 ... goodgle하려고했으나 이해 아무것도 발견했습니다
Question1 :
WCF 서비스 클라이언트를 인스턴스화하는 올바른 방법은 무엇입니까?
Questions2는 :
내 경우에 어떤 문제가 있습니까?
고마워요.
P. WcfTestClient를 사용하여 서비스에 연결할 수있는 몇 가지 문제가 있습니다. 자세한 내용은 여기를 참조하십시오. WCF service: Can't call methods through the 'WebHttpBinding' endpoint
P.P.
<system.serviceModel>
<services>
<service name="McActivationApp.EnrollmentService" behaviorConfiguration="McActivationApp.EnrollmentServicBehavior">
<endpoint address="" binding="webHttpBinding" contract="McActivationApp.IEnrollmentService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="McActivationApp.IEnrollmentService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="McActivationApp.EnrollmentServicBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
H 귀하의 서비스 구성을 모른 채 말할 수 있습니다. –
wcf 테스트 클라이언트에 연결할 수 있습니까? http://msdn.microsoft.com/en-us/library/bb552364.aspx –
이와 같은 상황에서 저는 작업 예제로 시작하여 작동하기 시작할 때까지 응용 프로그램을 리버스 엔지니어링합니다. MSDN에서 제공하는 샘플 앱은 다음과 같습니다. http://msdn.microsoft.com/en-us/library/dd936243.aspx –