Copied to clipboard

Flag this post as spam?

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


  • ambog36 4 posts 24 karma points
    Oct 05, 2010 @ 22:34
    ambog36
    0

    Using Umbraco's API from WCF

    I need to get data (nodes and properties) from an umbraco installation. I have created a WCF service (a .dll and .svc file) that exposes a GetData() method. In this method i am using Umbraco's API to look up a node and its data. I am hosting the WCF service in the same IIS server that hosts Umbraco (As you would with a traditional webservice). I can see the service and call the method however it is failing on the API call as if the service was hosted seperatly. I have taken the same approach using a web service and it works fine, does anyone know why it is failing in WCF? what do the API calls require in order to "see" Umbraco's data? following are my installation details:

    asp.net 3.5, windows 7, iis 7.5 

     

    thanks,

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 05, 2010 @ 23:05
    Aaron Powell
    0

    I've not seen anyone get a WCF service working in Umbraco, it tends to fail silently.

  • ambog36 4 posts 24 karma points
    Oct 05, 2010 @ 23:42
    ambog36
    0

    Could you give more detail about what exactly "fails"? I can see the service but In my case it is the Umbraco API call that fails, more specifically: Node root = new Node(-1); What configuration is required for the API to work? how do the API calls know where the .config file is that contains the content?

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 06, 2010 @ 08:16
    Aaron Powell
    0

    Looks like I'm wrong about WCF, I'd only ever seen it raised here and left unanswered...

    If you're running your WCF in the same website as Umbraco then you shouldn't have any problems with using the Node API, but if you're running it outside the Umbraco site then you're going to hit problems. You'll need to copy most (if not all) of the /config folder across (I know you need umbracoSettings.config at the very least), as well as the umbraco.config file (generally found in App_Data) and set a web.config appSettings key for the path to the Umbraco data folder (which you can get the exact key name from looking into the web.config on an Umbraco site).

  • ambog36 4 posts 24 karma points
    Oct 06, 2010 @ 18:24
    ambog36
    0

    Are you talking about copying Umbraco's config over to the services config? I believe the way i have the service hosted its using the web.config of Umbraco. I'm not sure what you mean by copy over the config...

    I have taken the following 3 steps:

    • Copied the service .dll into Umbraco installation's bin folder
    • Copied the .svc file to Umbraco installation under /services/myservice.svc
    • Modified Umbraco's web.config file to include the <system.serviceModel> from the wcf service's config file that sets the endpoint for the service.

    is there other settings that need to be configured in order for the service to call the Node API successfully?

    Thanks,

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 06, 2010 @ 23:52
    Aaron Powell
    0

    If it's in the same site as Umbraco then you don't need to do anything, the APIs are all available as per normal.

  • ambog36 4 posts 24 karma points
    Oct 13, 2010 @ 00:50
    ambog36
    0

    Thats what I assumed to begin with but its not working for me. has anyone actually had any success with this?

  • Duncan McDougall 35 posts 62 karma points
    Jan 25, 2011 @ 18:03
    Duncan McDougall
    0

    I'm having the same issue. I've added the dll, the svc and the config but object reference is not set to an instance of an object exception rooting back to umbraco.presentation.UmbracoContext.get_Current(). If you solved the issue yourself or if anyone knows the fix can you do me a favour and jot it down in here.

  • Craig Taylor 29 posts 69 karma points
    Mar 16, 2011 @ 20:24
    Craig Taylor
    0

    This is exactly the problem I'm running into myself. (and actually created a new topic before I found this one)

    -Craig

  • Dominic 1 post 21 karma points
    Oct 05, 2011 @ 12:00
    Dominic
    0

    I'm hitting this problem as well... did anyone ever have any success figuring this out?

    Or is there a better alternative to try?

    ---------

     

    EDIT: So after some muddling I realised that it may have been something to do with WCF failing to get hold of the context. So, to get around that:

     1. In your web.config add:

        <system.serviceModel>

                      <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

    2. On your actual service defition add:

       [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]    

        public class MyService : IService

     

Please Sign in or register to post replies

Write your reply to:

Draft