WCF service: unable to call methods through endpoint "WebHttpBinding"

I created a WCF service, here is the configuration section:

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

I connected to the service using WcfTestClient, added the service and can only call methods that are in the "IEnrollmentService (MetadataExchangeHttpBinding_IEnrollmentService)" section (they work as expected).

But the methods from another section of IEnrollmentService (WebHttpBinding_IEnrollmentService) cannot be called. When I try to call any of them, I get the following error:

Failed to call the service. Possible reasons: the service is disabled or unavailable; client side configuration does not match proxy; existing proxy is invalid. Refer to the stack trace in detail. You can try restoring the start of a new proxy server, restoring the default setting, or updating the service.

Error Details:

 The Address property on ChannelFactory.Endpoint was null. The ChannelFactory Endpoint must have a valid Address specified. at System.ServiceModel.ChannelFactory.CreateEndpointAddress(ServiceEndpoint endpoint) at System.ServiceModel.ChannelFactory`1.CreateChannel() at System.ServiceModel.ClientBase`1.CreateChannel() at System.ServiceModel.ClientBase`1.CreateChannelInternal() at System.ServiceModel.ClientBase`1.get_Channel() at EnrollmentServiceClient.UpdateEnrollmentProfile(String enrollmentId, String siteName, String deployServerName, Int32 methodId, String deviceClass, String deviceName, String registrationCode) 

Question 1: Do I understand correctly that for the case of calling the IEnrollmentService (WebHttpBinding_IEnrollmentService) methods, I need to additionally specify some endpoint?

Question 2: Can I get working?

Question 3: Do I have to take care of them (how can I call methods from my "user" application)?

0
source share
3 answers

Thanks guys for your answers, they gave me some food to think about. Here are the answers to my questions:

Answer1:

In fact, as indicated by "marc_s", the problem is that my service was configured as a "REST" service, so the answer is "Yes" to get these services for the WcfTestClient application, an additional endpoint (basicHttpBinding) is required.

Answer2:

As stated in "answer1": yes, in order to get it working, you need to add the basicHttpBinding endpoint.

Answer3:

It depends. If you do not plan to conduct "testing" using WcfTestClient, you do not care. In my specific case, I will run unit tests to check the results of the method call, so performance in WcfTestClient is not important.

Thank you and +1 for each helpful answer.

PS The reason I accepted my own answer is consistent with the questions (which are necessary for me).

+2
source

WCFTestClient does not support REST services (WebHttpBinding).

+2
source

You should be able to call methods in the service with webHttpBinding (REST) ​​using a regular browser - no WcfTestClient is required ... that the whole point (and benefit) of REST is simply "XML-over" -HTTP (greatly simplified).

Just point the browser to the service endpoint

 http://YourServer/YourVirtualDirectory/YourService.svc 

and you can see how your service lives there ...

+2
source

Source: https://habr.com/ru/post/1334957/


All Articles