1

I am unable to test a WCF Data service using the Wcf test client provided in VS2010. A regular service works fine but then for a data service I get this error when trying to call the url in the test client:

Error: Cannot obtain Metadata from http://localhost:31745/MyWcfDataService.svc 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:31745/MyWcfDataService.svc Metadata contains a reference that cannot be resolved: 'http://localhost:31745/MyWcfDataService.svc'. The remote server returned an unexpected response: (405) Method Not Allowed. The remote server returned an error: (405) Method Not Allowed.HTTP GET Error URI: http://localhost:31745/MyWcfDataService.svc The document at the url http://localhost:31745/MyWcfDataService.svc/ was not recognized as a known document type.The error message from each known type may help you fix the problem:- Report from 'XML Schema' is 'The root element of a W3C XML Schema should be and its namespace should be 'http://www.w3.org/2001/XMLSchema'.'.- Report from 'DISCO Document' is 'Discovery document at the URL http://localhost:31745/MyWcfDataService.svc/ could not be found.'. - The document format is not recognized.- Report from 'WSDL Document' is 'There is an error in XML document (2, 2).'. - was not expected.

The data service is running fine and I am able to do a View in browser to the svc file in question and see the wsdl.

Was wcf test client not meant to test WCF Data services? If it can be used, then how do I go about doing it? Do I need to make any modifications?

Thanks..

user20358
  • 14,182
  • 36
  • 114
  • 186

2 Answers2

4

The WcfTestClient only works with SOAP bindings, e.g. basicHttpBinding, wsHttpBinding, netTcpBinding.

It does not support REST based WCF services.

What for?? You can test your REST based services using your favorite browser - no special test client needed! If you need to carry out HTML requests like a POST or PUT, you should check out Fiddler

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • While fiddler can inject input into the API, you can't really use fiddler for formal testing of that interfaces. There is no straightforward way to have pass/fail analysis short of manually seeing the response. – DeepSpace101 Mar 02 '12 at 02:59
  • I am not sure but fiddler can get the response of post request? http://www.ehow.com/how_8788176_do-post-using-fiddler.html @Sid – zhfkt May 15 '13 at 18:26
  • @zhfkt: yes - sure - that's what I was saying in my response - no? – marc_s May 15 '13 at 18:36
  • I think he's saying as a matter of convenience. Ideally you have jasmine test runner setup with Grunt and easily create some TDD tests fast to hit the service via Http. If you are not doing TDD yet, then I think he's saying it woudl be nice to have the ability to do some Fiddler-like functionality within WCF tester which I agree, however we all know WCF was NOT created with REST in mind originally so that's why they did not put that in there. IF you want to quick and dirty test requests and see responses without code, use Fiddler. – PositiveGuy Oct 21 '13 at 21:18
2

My answer might be a bit late, but you could test your WCF data service with LINQPad (http://www.linqpad.net) which supports OData / WCF Data Services.

Alexander Zbinden
  • 2,315
  • 1
  • 17
  • 21