locked
Can't access webget methods on custom custom dataservice RRS feed

  • Question

  • I am creating a custom dataservice (i.e. not based an Entity Model) so I can return named complex types. When I browse the service via a URL I can access the lst function (see below). When I connect to the service via code I can't see the lst function. What am I doing wrong? Regards, Chris.

     

     

    Public Class dsCustom
        ' TODO: replace [[class name]] with your data class name
        Inherits DataService(Of CustomTypes.MyType)

        ' This method is called only once to initialize service-wide policies.
        Public Shared Sub InitializeService(ByVal config As IDataServiceConfiguration)
            ' TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
            ' Examples:
            config.SetEntitySetAccessRule("*", EntitySetRights.AllRead)
            config.SetServiceOperationAccessRule("lst", ServiceOperationRights.All)
        End Sub
        Dim ctx As New Advice2008Model.Advice2008Entities

        <WebGet()> _
        Public Function lst() As IQueryable(Of CustomTypes.MyType)
            Dim g = (From j In ctx.Jobs _
                     From w In ctx.WorkQueueItems _
                    From js In ctx.JobsSummary _
                    Select New CustomTypes.MyType With {.JobId = j.JobId, _
                    .DateCreated = js.DateLastAction}).Take(10)

            Return g.AsQueryable
        End Function
    End Class

     

    Monday, September 29, 2008 1:54 PM

Answers

  • Can you do a $metadata and see if the service operation shows up? When you explore the service, it only shows the top-level entity set and not service operations. Also, trying doing a request to the service operations and see if it succeeds or not.

     

    Thanks

    Pratik

    Tuesday, September 30, 2008 5:28 PM
    Moderator

All replies

  • What do you see or what error happens when you access your service from the code? Since you are able to see the ServiceOperation from the browser, i can't see any reason why you can't see from the code?

     

    Thanks

    Pratik

    Monday, September 29, 2008 4:56 PM
    Moderator
  •  

    Basically my dataservice class Inherits DataService(Of CustomTypes.MyType) which is my custom type. When I create the service reference when I open up the service to explore it the only thing I can see is MyType. As a result when I create the data context the only things I can see are the properties of MyType. It's like the data service is exposing MyType not itself. I suspect I am doing somthing very obvious wrong. Regards, Chris.

    Monday, September 29, 2008 6:38 PM
  • Can you do a $metadata and see if the service operation shows up? When you explore the service, it only shows the top-level entity set and not service operations. Also, trying doing a request to the service operations and see if it succeeds or not.

     

    Thanks

    Pratik

    Tuesday, September 30, 2008 5:28 PM
    Moderator
  • The method shows up in the metadata as GetWorkItems but when I do -

     

    http://localhost:1987/Advice2008DataService/CustomDataService.svc/GetWorkItems I get an "An error occurred while processing this request."

     

     

     

      <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
    - <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
    - <edmxBig SmileataServices>
    - <Schema Namespace="CustomTypes" xmlnsBig Smile="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
    - <EntityType Name="WorkItemsCount">
    - <Key>
      <PropertyRef Name="ID" />
      </Key>
      <Property Name="ID" Type="Edm.Int32" Nullable="false" />
      </EntityType>
    - <EntityType Name="WorkQueueItem">
    - <Key>
      <PropertyRef Name="ID" />
      </Key>
      <Property Name="ID" Type="Edm.Int32" Nullable="false" />
      <Property Name="CustomerID" Type="Edm.Int32" Nullable="false" />
      <Property Name="FlagInternal" Type="Edm.Boolean" Nullable="false" />
      <Property Name="NOC" Type="Edm.String" Nullable="true" />
      <Property Name="DueOn" Type="Edm.DateTime" Nullable="false" />
      <Property Name="JobID" Type="Edm.Int32" Nullable="false" />
      <Property Name="UserName" Type="Edm.String" Nullable="true" />
      </EntityType>
      </Schema>
    - <Schema Namespace="CustomCollections" xmlnsBig Smile="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
    - <EntityContainer Name="lstWorkItems" m:IsDefaultEntityContainer="true">
      <EntitySet Name="WorkItemCount" EntityType="CustomTypes.WorkItemsCount" />
      <EntitySet Name="WorkItems" EntityType="CustomTypes.WorkQueueItem" />
      <FunctionImport Name="GetWorkItems" EntitySet="WorkItems" ReturnType="Collection(CustomTypes.WorkQueueItem)" m:HttpMethod="GET" />
      </EntityContainer>
      </Schema>
      </edmxBig SmileataServices>
      </edmx:Edmx>

    Wednesday, October 1, 2008 8:21 AM
  • Hi I have got the URL access work so I have reposted -  "Web Get Function does not appear as service operation"

    Wednesday, October 1, 2008 9:21 AM