using WCF service in mvc with csla

using WCF service in mvc with csla

Old forum URL:

Narvesh posted on Friday, February 14, 2014

I have a WCF service Provided by csla. I want to consume this service in my MVC Project.I have create a object of service like below:

ServiceReference2.WcfPortalClient obj = new ServiceReference2.WcfPortalClient();

 Application App = new Application();

 var AppType = App.GetType();

 ApplicationCriteria Criteria = new ApplicationCriteria {ApplicationName = "application" };

 ServiceReference2.FetchRequest Fetch1 = new ServiceReference2.FetchRequest();

 CslaTest.ServiceReference2.DataPortalContext context = new ServiceReference2.DataPortalContext();

 Fetch1._context = context;

 Fetch1._objectType= AppType;

 Fetch1._criteria = Criteria;

 var list = obj.Fetch(Fetch1);
Getting error as:
Type 'CslaTest.BusinessLibrary.ApplicationCriteria' with data contract name 'ApplicationCriteria:' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'

JonnyBee replied on Sunday, February 16, 2014

You got this all wrong. You should rather use the DataPortal and configure the DataPortal to use WCF as transport channel if you want to use N-Tier deployment.

So to fetch a "root" object you just call:

public static Order GetOrder(int id)
  return DataPortal.Fetch<Order>(id);

and this will use the WCF channel when properly configured, f.ex:

    <add key="CslaDataPortalProxy" value="Csla.DataPortalClient.WcfProxy, Csla"/>
    <add key="CslaDataPortalUrl" value="http://localhost:21647/WcfPortal.svc"/>

Look at the NET\cs\SimpleNTier sample in the Samples folder. This sample shows a how to use N-Tier deployment with different UI technologies, including ASP.NET MVC.


AdrianSegovia replied on Wednesday, February 26, 2014

Hello JonnyBee,

Could you help me with this?
I have my mvc app working properly in IIS Express but I'm having a hard time deploying in my test server. I'm pretty sure it's related to my WcfAppServer.
How do you go about deploying your's with WCF?
My test server has IIS 7.5 in it and I deployed the service in it but my mvc cannot see it.



Copyright (c) Marimer LLC