REST in WCF – Part V (HI-REST – Exposing a service via GET – The ServiceContract and Implementation)

The post on building a HI-REST GET with WCF has been moved to my new blog at


Comments (9)
  1. wormster says:

    Hi Rob

    I am trying to implement an interface for the service contract:-

    namespace Medquist


       [ServiceContract(Namespace = “WCFServices”)]

       public interface IXDomainService



           [WebGet(ResponseFormat = WebMessageFormat.Json)]

           Medquist.PatientData SearchPAS(string userSessionId, string patientID, string patientDoB);



    and the service…

    namespace Medquist


       public class XDomainService : IXDomainService


           public PatientData SearchPAS(string userSessionId, string patientID, string patientDoB)



    config file :-


               <service name=”XDomainService”>

                   <endpoint address=”” behaviorConfiguration=”XDomainServiceAspNetAjaxBehavior”

                    binding=”webHttpBinding” contract=”IXDomainService” />



    However the proxy in the AJAX javascipt cannot resolve the namespace

    var proxy = new WCFServices.XDomainService();


    I have specified Factory=”System.ServiceModel.Activation.WebScriptServiceHostFactory” in the .svc file. Am I missing something else? Without the interface and all the attributes in place, everything works fine.


  2. Garry Trinder says:


    If you set the WebScriptServiceHostFactory in the svc, your configurations will be ignored (or an exception will be thrown).  It automatically configures the webHttpBinding with the enableWebScript endpoint behavior.  If you omit this, you would need to add an endpoint behavior configured in the web.config.  Something like this:




           <behavior name="XDomainServiceAspNetAjaxBehavior">

             <enableWebScript />




    In either case, you also need to have a ScriptManager in your page with a service path configured:

           <asp:ScriptManager ID="scriptManager" runat="server">


                   <asp:ServiceReference Path="~/YourPathToYourSvc.svc" />



    The best way to check to make sure you have everything is to rt-click the page and View Source.  Look for the <script element that has "YourSvcFile.svc/js" or "YourSvcFile.svc/jsdebug".  Copy that relative path to the address bar of the browser (if your svc file and page are at the root, simply replace the YourPage.aspx with YourService.svc.  If you are prompted with a dialog to save the proxy file (it is javascript), you are in business.  if not, Houston, there is a problem.

  3. wormster says:

    Thanks, Rob.

    The service file js indicated that the proxy was using the Interface, IXDomainService in the name space  – I didn’t realise that. Changing the proxy to…

    var proxy = new WCFServices.IXDomainService();

    …resolved the issue.

    Thanks again


  4. Anonymous says:

    As some of you know, I am in the midst of a blog series on REST in WCF. Further, I have been hard at

  5. Anonymous says:

    In Part V of this blog series I completed the service operation exposed via HTTP GET in a HI-REST manner.

  6. Anonymous says:

    A common scenario you may encounter when designing your RESTful services is supporting clients that only

  7. Anonymous says:

    The series blog post on REST in WCF REST in WCF – Part I (REST Overview) REST in WCF – Part II (AJAX

  8. Anonymous says:

    One of the key enabling factors of the browsable web was the use of a standard representation format:

  9. It’s a very nice explained article about REST-WCF integration.

    Thanks a lot Rob, it helped me out.

Comments are closed.

Skip to main content