Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Paul Sørensen 304 posts 650 karma points
    Dec 26, 2010 @ 13:34
    Paul Sørensen
    0

    Introducing WCF WebHttp Services in .NET 4 - and Umbraco

     

    Hi

    I have found this interesting sets of articles on Rest.

    http://blogs.msdn.com/b/endpoint/archive/2010/01/06/introducing-wcf-webhttp-services-in-net-4.aspx

    So I thought I would try to implement this in Umbraco. The routing is supposed to be performed in Application_Start

    in Global.asax. I saw somewhere that in Umbraco you could do that creatin a class inheriting from 

    umbraco.BusinessLogic.ApplicationBase.

     

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]  
    public class MsServiceRouter : umbraco.BusinessLogic.ApplicationBase
    {        
    public MsServiceRouter()        
    {
    Helper.LogCustom("PaulS.MsServiceRouter.ctor called");           
    RegisterRoutes();        
    }
    private void RegisterRoutes()
    {
    Helper.LogCustom("PaulS.MsService.RegisterRoutes called");
    RouteTable.Routes.Add(new ServiceRoute("MsService", new WebServiceHostFactory(), typeof(MsService)));

            }
    }

    To ensure that it gets called I have added some logging - logs into UmbracoLog table. 

    This has been added to my web.config

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
    <baseAddressPrefixFilters>
             <add prefix="http://localhost:8080" />
    </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
    <standardEndpoints>
    <webHttpEndpoint>
            <!-- 
                 Configure the WCF REST service base address via the global.asax.cs file
    and the default endpoint  via the attributes on the <standardEndpoint> element below
    -->
             <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true">
             <security>
             <transport proxyCredentialType="None" />
           </security>
           </standardEndpoint>
          </webHttpEndpoint>
    </standardEndpoints>

     

    To avoid Umbraco doing anything to my service calls I also added MsService to the umbracoReservedPaths

     

        <add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/MsService/" />

    My problem is that when I call 

    http://localhost:83/msservice/help

    I get

    HTTP Error 404.0 - Not Found

    The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

    The service works fine when placed outside Umbraco.

     - So where is my call disappearing?

    Thanks
    Paul S

     

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 26, 2010 @ 13:37
    Jan Skovgaard
    0

    Hi Paul

    Maybe you'll also need to add /mssservice/help to umbracoReservedUrls ?

    /Jan

  • Paul Sørensen 304 posts 650 karma points
    Dec 26, 2010 @ 14:47
    Paul Sørensen
    0

    Hi Jan

    It does not fix the problem. My consception of umbracoReservedUrls is that Umbraco does not touch anything her and below.

    /Paul S

  • James Patterson 53 posts 192 karma points
    Feb 02, 2011 @ 18:27
    James Patterson
    0

    I'm having this very issue. I've added my service path to umbracoReservedUrls with no luck - just a 404. 

    Did you ever find a solution to this?

    James

     

    EDIT - Oops... my issue was a spelling mistake in my Route registration. Fixed. :)

  • Paul Sørensen 304 posts 650 karma points
    Feb 02, 2011 @ 21:11
    Paul Sørensen
    0

    I can just add for other readers that I did managed to fix the problem. My problem was that I had set the Managed Pipeline Mode in IIS 7 to Classic - should be Integrated

    Now it works like a charm

    /Paul S

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies