.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Service Operation with Joins between entities

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :WCF
Hello, I have a service operation that queries multiple entities in a data source using joins. However, I can't seem to get to the joined entity, either when browsing the data service in IE, or when consuming the data service in the silverlight client code. With this code in the data service operation method: var query = from o in crmOnline.opportunityopportunities join su in crmOnline.systemusers on o.ownerid.Value equals su.systemuserid select o; Should I not be able to view the data service in a browser and see the systemusers like this (the service operation takes two arguments, userid and org): http://localhost:6246/convoservice.svc/filteredresults?userid='22222222-f3sw-aahh-hy65-nn88dd3333ee'&org='testorg'/systemusers or to consume it in the client like this foreach (opportunity opp in response) { string name = opp.name; string ownername = opp.opportunity_owning_user.fullname; ... ? In either scenario, I'm not having success. When browsing the URL posted above, I get an http 400 "webpage cannot be found" error. I get a null reference exception in the client. Any help would be greatly appreciated! Web: http://invoc.net

View Complete Post

More Related Resource Links

A lengthy operation in an ASP.NET web service


I've built an ASP.NET web service with .NET 2.0 (an asmx file). I invoke a web service method using Ajax. The method takes a substantial amount of time to execute (5 minutes to 1 hour). I believe it's not a good idea to "hang" the web request for so long.
I'm wondering if the web service method could spawn an additional process which in turn would execute the lengthy operation and notify the web service once the operation is completed.
Are there any good practices regarding this kind of functionality?


CRUD Operation should be Part of BO or Service/Manager Classes?



I am developing an application which has a general structure similar to what Scott has described at http://nhibernateasp.codeplex.com

Thanks to Scott for developing such a nice architecture which can be used for most of the projects!

It uses Service Layer which contains service classes (like Product Service) which actually talk to the repository layer (ProductRepository) and these service classes are responsible for CRUD operations while the BO (Product) contains just the data and the validation methods.

As I have read, in OO design, you should design a class which contain both data and behavior, in which case, the BO (Product) should be responsible for doing its own CRUD and it should not be a responsibility of Service classes.

Which approach you think is better design and what could be the reasons?

Any help is this regard is appreiciated.




Serializing Linq to Entities for use in a REST Service

What would be the best approach to send data retrieved from Linq to Entities over a rest service? For example, if you have a Linq to Entities class, say Products from the Northwind database. I want to return a subset of the Products (based on a query on the model) back through a service. First a retrieve a List<Product> from the context, and then i need to serialize the data and send it over the wire. If I use the exact Linq to Entities class, then there is so much "garbage" that it either fails outright (from a circular reference) or you are wasting bandwith. What is a design to overcome this? Create POCO objects for each linq to entities class you want to send and create custom code to tranform each object in the list to the POCO object? This is the only way I can see doing it, although it would be very tedius to create and maintain (unless some custom code generation was created). Is there a better approach? clients

Service Operation - Get proper data when browsing the service, but not when calling the service from

Hello, I recently implemented a service operation in an attempt to pass some filter parameters to a data service (a user guid and an organization, actually, for impersonation of a user on the service's call to the application). I successfully added the service operation to the data service, and I can browse the service and see the data filtered as I expected. However, when I call the service operation from the Silverlight client, I don't get any results, even though I should. Am I missing something? Code below if it's helpful. Thanks! Service Operation Definition: [WebGet] public IEnumerable<opportunity> filteredopps(string userid, string org) { /*Define the connection with the impersonated user*/ CrmConnection crmc = CrmConnection.Parse("Authentication Type=Passport; Server=https://" + org + ".crm.dynamics.com/" + org + "; User ID=myuser; Password=mypassword; Device ID=mydeviceid; Device Password=mydevicepassword"); crmc.ImpersonatedUser = new Guid(userid); var crmOnline = new DataContext(crmc); List<opportunity> uplist = new List<opportunity>(); crmOnline.UsingService(service => { var query = from o in crmOnline.opportunityopportunities select o; foreach (opportunity thisopp in query) { uplist.Add(thisopp);

WF Service using EF4 POCO Entities Issue

Hi I've a WF Service using my EDMX and my Classes generated using a poco t4 template, but on execution when i include navigation properties related to a 1 to many or many to many relationships i got an underlying connection was closed error. I've traced the error and i got 2 exceptions different exceptions depending on which parameters i pass to my context and my ReciveAndSendReply Action. One is the related to that Navigation Property and the fact that it is generating a cyclic reference A.B  B.List<A> or viceversa and cant be serialized. The other changing my context property to enabling/disabling the proxy creation i get a overflow on the max message size or max message on the trace (the cyclic reference is doing an overflow and the entity back from the WF service is not coming back. Hope you can help me guys to figure out whats going on. Thx Pedro

Entity Framework POCO and WCF Data Service - Lazy-loading (expand?) related entities?

I've followed ScottGu article on creating an Entity Framework POCO classes for NerdDinners (right now there are only 2 classes, Dinner and RSVP. I then created a WCF Data Service class, which points to my EF class (NerdDinner), everything is working fine, except I can't lazy-load or expand related entities. For example, I want to get all load all the Dinners and their related RSVPs, something like this throw an error:var result = (from d in db.Dinners.Expand("RSVPs")                      select d);The error is a null reference error:at System.Data.Services.Serializers.SyndicationSerializer.WriteObjectProperties(IExpandedResult expanded, Object customObject, ResourceType resourceType, Uri absoluteUri, String relativeUri, SyndicationItem item, DictionaryContent content, EpmSourcePathSegment currentSourceRoot) at System.Data.Services.Serializers.SyndicationSerializer.WriteEntryElement(IExpandedResult expanded, Object element, ResourceType expectedType, Uri absoluteUri, String relativeUri, SyndicationItem target) ... ... ...Any idea why or what I need to do to load related contents?Thank you very much.

Long Running Service Operation & WCF



I have a requirement where in my service operation is going to be long running process. I dont want to rely on typical duplex call back mechanism cos these service may be used in non wcf technologies as well. can anyone suggest best practices, approach, alternative to achieve the same

Many thanks


Web Service - Different Operation Contracts calling the same method

I would like to know how could I define two operation contracts (JSON, XML) which call to the same method; I have defined web and basic http bindings for all the Operation Contracts in the way that they could be called from HTTP requests (jQuery) and from Silverlight.

This first example works because the methods have different number of input parameters. But I need to add the attribute name to the Operation Contract.

        [WebInvoke(Method = "POST",
            UriTemplate = "1/json/getRegions",
            ResponseFormat = WebMessageFormat.Json)]
        RegionListOutput GetRegionList(int countryID, int other);

        [OperationContract(Name = "getRegionsXML")]
        [WebInvoke(Method = "POST",
            UriTemplate = "1/xml/getRegions",
            ResponseFormat = WebMessageFormat.Xml)]
        RegionListOutput GetRegionList(int countryID);


How to setup a ReceiveReply activity to receive the result of a WCF service operation?


I already figured out what I have to do to send a WCF message to a WCF service developed with .NET, but I could not get the result back to the workflow. I need to know what I have to do to get that result. 

I have a very simple test WCF service with following contract:

[ServiceContract(Namespace = http://www.juergen-bayer.net/samples/wcf)]
public interface IDemoService
  long Add(int value1, int value2);

The client application uses a workflow with a Send and a ReceiveReply activity. The WCF endpoint is configured in the config file:

   name="BasicHttpBinding_IDemoService" />

The Send activity is configured like follows:

Action="http://www.juergen-bayer.net/samples/wcf/IDemoService/Add" => This would also be the default value in my case

The parameters of the WCF message are placed in the content: 


Getting Error When Calling Wrokflow Service - The operation could not be performed because WorkflowI


The scenario .  ..

I have developed a Custom Activity(CA) which has a designer like SEQUENCE.

I created a Workflow Service (XAMLX) and placed my Custom Activity(CA) as the first activity. Then I placed a RECEIVE activity within this CA and provided all the necessary details.

Now if I run the workflow service and call the service operation it is throwing execption.

Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service.

The operation could not be performed because WorkflowInstance 'a74eb5e2-72b4-4cb1-8a4d-daed6f431936' has completed.

Instead if I put the original SEQUENCE activity as first activity and then placed a RECEIVE activity it is working good. But I don't want to use SEQUENCE activity here . .. . I need my custom SEQUENCE like activity to be the first activity and make this as a place holder for other activities.

Please help to get out of these errors.


System.ServiceModel.FaultException: Operation is not currently available on the service.


We have a sequential activity with multiple receive activities. When we call Receive Activity from WCF getting the following error

System.ServiceModel.FaultException: Operation is not currently available on the service.

WCF is hosted in IIS with domain account

WF is hosted in Self host running in the same domain account in which WCF is hosted.

Any idea why this error is coming? But when we run everything in VS 2008 (hosted in develpment server) ,everything is working fine






Consume WCF Data Service Operation from WF4 workflow




I've set up a WCF Data Service with a couple of operations. I've marked the operations with [WebGet] but im not able to get them in my toolbox in Visual Studio when i add a service reference. What are the steps that i need to go through to do this?

When I try to add it as a reference from my workflow project I get "No operations found"


Windows Service Applications Tutorials

You can easily create services by creating an application that is installed as a service. For example, suppose you want to monitor performance counter data and react to threshold values. You could write a Windows Service application that listens to the performance counter data, deploy the application, and begin collecting and analyzing data.

WCF Tip: Using Properties in Service Contracts

you'll notice all of the Service Contracts are implemented with interfaces containing only methods. For the longest time I thought that's all that was supported, until I thought about it a little more. In C# land, properties are simply wrappers around a get method and set method, so why wouldn't we be able to use properties in a service contract? Well the answer is we can.

ASP.NET 4.0 Dynamic Data and Many to Many Entity Framework Entities

I did not play much with Dynamic Data controls in VS2008 and just made a cool discovery in VS2010 Beta 2. This may not even be new, but as I'm sitting 30,000+ feet over the Atlantic ocean, I don't have access to VS2008 at the moment to check.

Realizing a Service-Oriented Architecture with .NET

This article is meant to be a practical discussion guide to building a .NET application in a service-oriented architecture. We will consider real-world goals, real-world obstacles, and experience-based solutions. I quickly concede the approaches discussed here are not exhaustive or infallible. This paper is focused on application development, not application integration. We will specifically consider architectural issues and component design issues.

The Potential of Web Services

Web Service for uploading documents into SharePoint

WS UploadService is a web service written for Microsoft Office SharePoint Server 2007 and Windows SharePoint Services 3.0 and is meant for uploading documents into SharePoint. I have just uploaded the zip file to GotDotNet.com so it will take some time before the zip file appears in the list of downloads. For the time being, you can download the zip file from the following location
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend