locked
Actions in WCF Data Services 5.0 RRS feed

  • Question

  • I am trying to use Actions in my WCF Data service

    I have followed the example form the WCF team blog but I am not able to see the action as a FunctionImport in the http://service/$metadata

    I have a method:

    [Action] public IEnumerable<ftInventory> CheckSupplies(ftSupplier supplier, int productId) {            return new List<ftInventory>();        }

    if I use the [WebGet] attribute then the function is seen in the metadata.

            [WebGet]        
            public IEnumerable<ftInventory> CheckSupplies(ftSupplier supplier, int productId)
            {
                return new List<ftInventory>();
            }

    What do I need to do to ensure the the [Action]Attibute will also enable the function to show up in the metadata

    Jawahar

    Wednesday, June 6, 2012 4:14 PM

All replies

  • Hi jawaharrajan,

    Welcome to MSDN Forum.

    Could you please post the link that you followed? This is, so I can help you more effectively.

    Best Regards 


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, June 18, 2012 7:43 AM
    Moderator
  • Hello Thanks for your help; this is the link I I read up on for actions

    http://blogs.msdn.com/b/astoriateam/archive/2012/04/10/actions-in-wcf-data-services-part-1-service-author-code.aspx

    Jawahar

    Wednesday, June 20, 2012 6:20 PM
  • Hi jawaharrajan,

    I will do more research on this issue and come back as soon as possible, thanks for your understanding.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Friday, June 22, 2012 8:18 AM
    Moderator
  • Jawahar,

    Did you expose the action in the service's inInitializeService method?

    config.SetServiceActionAccessRule("*", ServiceActionRights.Invoke);

    Mike

    Friday, June 22, 2012 11:27 AM
  • Yes I do have the setting as:

    config.SetServiceActionAccessRule("*", ServiceActionRights.Invoke);

    Jawahar

    Tuesday, June 26, 2012 12:43 AM
  • Have you implemented an action provider as detailed the next parts of Alex's blog post? The article you wrote is a 3 part series on implementing actions.


    -Ian

    Tuesday, June 26, 2012 11:59 PM
  • Hello

    Yes I believe I have implemented the action provider, just took the code from the example in CodePlex and adapted for my use. I am not sure where the Action methods need to be defined. in the  SErvice class or the model class? or does it make a difference?

    Jawahar

    Wednesday, June 27, 2012 8:13 PM
  • Hey Jawahar,

    On the IDataServiceActionProvider there is a method called CreateInvokable. What do you do there? The reason I ask is that this method is the place where you cooralate a method to actually be executed. I helped test this feature and the code that I wrote would look on the service for a method with the name that I was looking for via reflection, then in my implementation i would pass the MethodInfo and resolve the parameters that come into CreateInvokable and pass these into my implementation of IDataServiceInvokable. This invokable action would be called when SaveChanges is called then.

    My point is that this method needs to be implemented correctly for you to invoke the action that you need to. Perhaps we can review the code in this method along with a small samplet of your service code where you implement a method to see how this matches up. It seems like what you have has got to be pretty close.

    Thanks,

    Chris Robinson - SDET OData


    This posting is provided "AS IS" with no warranties, and confers no rights.

    Friday, June 29, 2012 3:38 PM
    Moderator