Search code examples
c#wcfwcftestclient

How to access Federated WCF via WCF test Client?


I have a simple WCF client over HTTPS that works pretty fine with the WCF Test Client. Now when I enabled Federation to WCF, the same works fine in a browser.

  1. As soon as I access the svc URL, it redirects to the federated login page.
  2. After valid authentication, it comes back with the metadata page.

I would like to perform the same with WCF Test Client. But in Fiddler, it redirects with an Error 302 and hence fails to get any metadata. The same is observed when I created a console application and consume the call.

Note: I do not want to create a Web application to test the same.

Questions:

  1. Is this scenario possible?
  2. If yes, what needs to be done if I need to make it work via client applications.

Solution

  • If you are using WSFederationBinding, the WCF Test Client does not support it, as noted here:

    https://msdn.microsoft.com/en-us/library/bb552364%28v=vs.110%29.aspx

    You can, however, build a custom test client. For example, you can build a Windows Forms client or a Console app that makes a service reference to the federated services and issues a client credential token in code. Microsoft has an article on programmatically creating a client credential token here:

    https://msdn.microsoft.com/en-us/library/ms731690%28v=vs.110%29.aspx