WCF Dataservice issue

Posts   
 
    
peerke
User
Posts: 23
Joined: 19-Aug-2008
# Posted on: 22-Mar-2012 12:03:40   

I was looking into the new WCF Dataservice (OData) feature of LLBLGen 3.5. I followed the guidelines in the documented 'Creating a WCF Data Services Tutorial'. I have added the data service to a website application, but when I request it in the browser to look at the obtained metadata, it only shows the metadata of one of my generated entities, while I have added 15 entitites to my model in the designer. What am I doing wrong here? Any help is appreciated!

Thank you.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 22-Mar-2012 20:50:11   

Hi peerke,

We can't help you without more relevant information (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7725).

Anyway, this sounds like you have some entities violate one or more of the limitations described in the docs. See the Limitations section of that topic.

David Elizondo | LLBLGen Support Team
Posts: 11
Joined: 20-Mar-2012
# Posted on: 28-Mar-2012 01:29:41   

I have also created a WCF Data Service per the tutorial. I can browse to the service and see the 4 entities that are in my SelfService Library when I go to the .svc.

However, I can't add a service reference because I get this error:

The document at the url httpdisappointed /localhost:3456/PSCustomerService.svc/ was not recognized as a known document type. The error message from each known type may help you fix the problem: - Report from 'XML Schema' is 'The root element of a W3C XML Schema should be <schema> and its namespace should be 'http://www.w3.org/2001/XMLSchema'.'. - Report from 'DISCO Document' is 'Discovery document at the URL httpdisappointed /localhost:3456/PSCustomerService.svc/ could not be found.'. - The document format is not recognized. - Report from 'WSDL Document' is 'There is an error in XML document (2, 2).'. - <service xmlns='http://www.w3.org/2007/app'> was not expected. Metadata contains a reference that cannot be resolved: 'httpdisappointed /localhost:3456/PSCustomerService.svc'. The remote server returned an unexpected response: (405) Method Not Allowed. The remote server returned an error: (405) Method Not Allowed. If the service is defined in the current solution, try building the solution and adding the service reference again.

Here is my svc code:

using System;
using System.Collections.Generic;
using System.Data.Services;
using System.Data.Services.Common;
using System.Linq;
using System.ServiceModel.Web;
using System.Web;
using SD.LLBLGen.Pro.ODataSupportClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
using LLBLDemoOracle.HelperClasses;
using LLBLDemoOracle.Linq;

namespace LLBLWcfDataService
{
    public class PSCustomerService : LLBLGenProODataServiceBase<LinqMetaData>
    {
        public static void InitializeService(DataServiceConfiguration config)
        {

            config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
            config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);

        }

        protected override LinqMetaData CreateLinqMetaDataInstance()
        {
            return new LinqMetaData();
        }

        protected override ITransactionController CreateTransactionControllerInstance()
        {
            return new Transaction(System.Data.IsolationLevel.ReadCommitted, "Trans");
        }

        protected override IUnitOfWorkCore CreateUnitOfWorkInstance()
        {
            return new UnitOfWork();
        }

        protected override string ContainerName
        {
            get
            {
                return "PSCustomerService";
            }
        }
    }
}

I am also unable to browse the metadata.

Here are my details:

LLBL Version: 3.5 Final - TRIAL Runtime: v2.0.50727 DB: Oracle 11g with ODP.NET

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Mar-2012 08:15:13   

How are you adding the Service Reference? Are you sure that no one entity falls into the one of the limitations detailed in the documentation?

David Elizondo | LLBLGen Support Team
Posts: 11
Joined: 20-Mar-2012
# Posted on: 28-Mar-2012 19:09:18   

I've tried this against a SQL-Server table and then just against the customers table in the Northwind DB. I've attached the WcfDataServices project that has my LLBL Generated Adapter project with one Customer entity. None of the limitations seems to indicate that I would not be able to add a service reference. I can't even browse the $metadata.

I am using IIS7 but can replicate this behavior (or lack thereof) on Windows 2003 Server.

Posts: 11
Joined: 20-Mar-2012
# Posted on: 28-Mar-2012 19:11:59   

Here is the Wcf Project that I created.

Posts: 11
Joined: 20-Mar-2012
# Posted on: 28-Mar-2012 19:16:16   

Sorry, I had to remove all the LLBL DLLs to reduce the size.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Mar-2012 08:04:03   

I deleted your attachment, sorry but it contained a lot of dlls. Instead I'm attaching a working example based on yours.

The problem, I think, is that you are using the TwoClasses preset, which I think is a limitation. I have to confirm that though.

If you use the decorator to include exception info ([ServiceBehavior(IncludeExceptionDetailInFaults = true)]) and set the verbose errors on (config.UseVerboseErrors = truewink, you can see the exception:

<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code/>
<message xml:lang="en-US">An error occurred while processing this request.</message>
<innererror>
<message>
The entity type 'Northwind.Linq.CustomerEntity' does not have any key properties. Please make sure the key properties are defined for this entity type.
</message>
<type>System.InvalidOperationException</type>
<stacktrace>
at System.Data.Services.Providers.ResourceType.ValidateType()
 at System.Data.Services.Providers.ResourceType.get_PropertiesDeclaredOnThisType()
 at System.Data.Services.Providers.ResourceType.InitializeProperties()
 at System.Data.Services.Providers.ResourceType.get_EpmIsV1Compatible()
 at System.Data.Services.Providers.ResourceSetWrapper.EpmIsV1Compatible(DataServiceProviderWrapper provider)
 at System.Data.Services.RequestDescription.UpdateAndCheckEpmFeatureVersion(ResourceSetWrapper resourceSet, IDataService service)
 at System.Data.Services.RequestDescription.UpdateAndCheckEpmFeatureVersion(IDataService service)
 at System.Data.Services.RequestUriProcessor.ProcessRequestUri(Uri absoluteRequestUri, IDataService service)
 at System.Data.Services.DataService`1.ProcessIncomingRequestUri()
 at System.Data.Services.DataService`1.HandleRequest()
</stacktrace>
</innererror>
</error>

When using the normal preset (one class per entity) it works.

Attachments
Filename File size Added on Approval
NorthwindDataService.zip 46,139 29-Mar-2012 08:04.23 Approved
David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39897
Joined: 17-Aug-2003
# Posted on: 29-Mar-2012 11:52:03   

Reproduced indeed.

Question, Kevin Raffay, for adapter, you used 2-class scenario as well? If so, please use normal the normal adapter preset for now. We're looking into what causes this.

(edit) the problem is in the property discovery logic. It finds all properties properly, but it excludes inherited properties (of supertypes). This of course excludes all properties which are inherited from the base class of the entity class (in 2-class scenario), which results in 0 properties being discovered.

Working on fix.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39897
Joined: 17-Aug-2003
# Posted on: 29-Mar-2012 12:41:05   

Could you please test the dll attached to see whether it fixes your problem?

Attachments
Filename File size Added on Approval
SD.LLBLGen.Pro.ODataSupportClasses.dll 35,840 29-Mar-2012 12:41.12 Approved
Frans Bouma | Lead developer LLBLGen Pro
Posts: 11
Joined: 20-Mar-2012
# Posted on: 29-Mar-2012 17:35:50   

This new DLL seems to work against SQL-Server with a Self-Serving 2-Class project. I was able to browse to metadata and add an LinqPad connection to the WCF Data Service.

I'll test against Oracle later.

Thanks for your help!