Question

I'm working with WCF (VS2005, .Net 3.0) and want to test out a service by directly calling it via a web browser instead of from code.

I have one method decorated with the OperationContract attribute call GetTest(). I have the service behind a .svc file that I can access; however, when I go .../Test.svc/GetTest, only a blank screen comes up.

Here is the web.config:

<system.serviceModel>
  <services>
    <service name="TestService" behaviorConfiguration="TestBehavior">
      <endpoint
        address=""
        binding="basicHttpBinding"
        contract="TestService.ITestService"></endpoint>
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="TestBehavior">
        <serviceMetadata httpGetEnabled="true"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

Whenever I try to set a breakpoint in the service, it does not get hit as well. Any ideas on where I'm going wrong here? I'm used to ASMX services where I get a response when I access the methods via a browser; however, I can only get the "You've created a Service" page when I access the service but nothing from the methods.

Was it helpful?

Solution

WCF does not offer the "call it from the web" options that ASMX services used to do. Why? It's a huge security hole, and not the best way to test a web service.

One option is to do as @Yossi suggested, and use the Wcf Service Test Tool.

Or better yet, write your own client to consume your web service. This will help you deal with the same issues those who will consume your service will deal with, and believe me, WCF can have quite a few of those hangups.

Don't get me wrong, WCF is frikkin awesome! But there's a lot to juggle, and if you're new odds are you're going to get it wrong. Even early adopters still don't know all the ins and outs of WCF.

OTHER TIPS

Consider using the Wcf Service Test Tool for initial testing of your service (but really- unit testing is your friend :-)) (and yeah - you will need a mex endpoint, at least initially)

As for debugging - are you attached to the correct process hosting the service? are you compiled with debug symbols? if the service is published to IIS - is the published code the same as the code in visual studio?

Have you tried using SoapUI? They provide a really great Web Services Testing tool. They even have a free version that will run as a webStart!

Also, try installing a mex endpoint, c.f. msdn link.

Take a look at WebGetAttribute - which needs .NET 3.5.

This allows you to get REST data from a WCF web service.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top