Budda
Budda

Reputation: 18353

WCF service: Can't call methods through the 'WebHttpBinding' endpoint

I've created WCF service, here is it's 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 with WcfTestClient, added service and can call only methods that are in "IEnrollmentService (MetadataExchangeHttpBinding_IEnrollmentService)" section (they work as expected).

But methods from another section "IEnrollmentService (WebHttpBinding_IEnrollmentService)" are not callable. When I try to call any of them I receives the following error:

Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service.

Error Details:

The Address property on ChannelFactory.Endpoint was null.  The ChannelFactory's 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: Am I correctly understand that for case of "IEnrollmentService (WebHttpBinding_IEnrollmentService)" methods calling I need to specify additionally some endpoint?

Question 2: Can I get workable that at all?

Question 3: Should I care about them (as I will be able to call methods from my 'custom' application)?

Upvotes: 0

Views: 5738

Answers (3)

Budda
Budda

Reputation: 18353

Thank you, guys, for your answers, they gave me some food to think. Here are answers on my questions:

Answer1:

Actually, as is stated by "marc_s" the problem is that my service was configured as 'REST' service, so answer is "Yes" to get those services accessible for WcfTestClient application additional endpoint (basicHttpBinding) is required.

Answer2:

As is stated in "answer1": yes, to get it workable you need to add basicHttpBinding endpoint.

Answer3:

It depends. If you don't plan to do 'testing' with WcfTestClient - don't care. In my particular case I will implement unit tests to check method call results, so workability in WcfTestClient not important.

Thanks you and "+1" for each helpful answer.

P.S. The reason why I've accepted own answer is that is consistent with questions (that are essential for me).

Upvotes: 2

marc_s
marc_s

Reputation: 755411

You should be able to call methods on a service with webHttpBinding (REST) using a regular browser - no WcfTestClient needed.... that's the whole point (and benefit) of REST - it's just a "XML-over-HTTP" service (vastly simplified).

Just simply point your browser at your service endpoint

http://YourServer/YourVirtualDirectory/YourService.svc

and you should be able to see your service living there...

Upvotes: 2

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364409

WCFTestClient does not support REST services (WebHttpBinding).

Upvotes: 2

Related Questions