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

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

Public properties of collection derived classes are not deserialized in REST wcf service

Posted By:      Posted Date: October 28, 2010    Points: 0   Category :WCF

I have Restful wcf service that returns the following class, but the Total and Count fields become 0 when it reaches the client side. But they have the correct values on the server side.

 public class Groups : List<Group>
private int total;
private int start;

/// <summary>
/// Total number of Groups in the result set irrespective of the paging
/// </summary>

View Complete Post

More Related Resource Links

Multiple services in REST Collection WCF Service?


After I create a "REST Collection WCF Service" project, it contains one service "service.svc". Can I add multiple services to this project? There must be a way to do so. Otherwise, it does not make sense to create one project for each service.


My question is how to add a new service to an existing "REST Collection WCF Service" project?


Thanks a lot.

IEditableObject on classes with collection properties?

I have a question about the IEditableObject interface. In general it makes great sense. But what happens if you have complex classes that have nested objects or collections properties? What level of property changes are you supposed to be able to cancel?For discussion, let's say you have an "Order" class with a "Name" property and a "OrderLineItems" property that's a collection of "OrderLineItem". Each "OrderLineItem" has a "Quantity", "Description", and "Amount" property. Both classes implement IEditableObject.It's straightforward that if you call Order.BeginEdit, change Order.Name, and call Order.CancelEdit, then Order.Name will have it's original value. This is the normal case and why IEditableObject exists.But what if you call Order.BeginEdit, remove Order.OrderLineItems[0], and call Order.CancelEdit? Should the removed OrderLineItem be restored to the collection?What if you modify Order.OrderLineItems[0].Quantity? Should Order.CancelEdit restore that value? Perhaps Order.BeginEdit() should be calling BeginEdit() on each of it's children?I guess I'm wondering just how deep IEditableObject is expected to go? The MSDN documentation doesn't cover any of this. Any thoughts?SBussinger

using ImageSource collection in xaml (getting error Only public classes can be used in markup. 'Bit


Hy everybody, I made a custom control that has a property of type ObservableCollection<ImageSource>.


My problem is that if i use the control as is and set the list of frames from xaml everything works fine, but if I use my control as part of a template (for example a Button template) i get the error


" Only public classes can be used in markup. 'BitmapFrameDecode' type is not public.  "

I have no idea how to fix this..can anyone help me? Thank you very much!

Catalin Toma

using ImageSource collection in xaml (getting error Only public classes can be used in markup. 'Bit


Hy everybody, I made a custom control that has a property of type ObservableCollection<ImageSource>.


My problem is that if i use the control as is and set the list of frames from xaml everything works fine, but if I use my control as part of a template (for example a Button template) i get the error


This is my simplified control:



public partial class MultiFrameImage : UserControl
    public MultiFrameImage()
      ImageSources = new ObservableCollection<ImageSource>();


    public ObservableCollection<ImageSource> ImageSources
        return base.GetValue(ImageSourcesProperty) as ObservableCollection<ImageSource>;
    public DependencyProperty ImageSourcesProperty = DependencyProperty.Register("ImageSources",typeof(ObservableCollection<ImageSource>),typeof(MultiFrameImage));


Now,if I initialize the control like this everything works fine:



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.

Service Station: More On REST


This month's column answers frequently asked questions about implementing REST.

Jon Flanders

MSDN Magazine July 2009

C++ and ATL: Use ATL Server Classes to Expose Your Unmanaged C++ Code as an XML Web Service


Throughout this issue, you'll read all about the promise of Web Services and how the .NET Framework enables Web Service development. Many people will also be building their Web Services atop C++ code and frameworks like ATL Server, particularly when performance is paramount. In this article, the authors show how fully functional Web Services are built using ATL Server and Visual Studio .NET. Beginning with unmanaged C++ classes, they add ATL attributes that make the code work over HTTP.

Kirk Fertitta and Chris Sells

MSDN Magazine December 2002

Windows Services: New Base Classes in .NET Make Writing a Windows Service Easy


Windows services are applications that run outside of any particular user context in Windows NT, Windows 2000, or Windows XP. The creation of services used to require expert coding skills and generally required C or C++. Visual Studio .NET now makes it easy for you to create a Windows service, whether you're writing code in C++, C#, or Visual Basic. You can also write a Windows service in any other language that targets the common language runtime. This article walks you through the creation of a useful Windows service, then demonstrates how to install, test, and debug the service.

Ken Getz

MSDN Magazine December 2001

Looking for a simple Service and Console Client REST sample implementing BASIC authentication


Does anyone know of a C# code sample demonstrating WCF REST services and console test client with OperationContracts (GET and POST) implementing mutiple paramaters using BASIC authentication? Also, perhaps, using Fiddler as a test client as well? I have searched high and low for something like this, but have not had any success.

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.




All data in class properties disappear across WCF service

Hi, I have a class that i share betwee silverlight client and wcf service. I populate properties of the class with real data from the client, to be used in the server. I use debugger to step through the code when the call gets to the server, all the data ara gone and are replaced with null. All DateTime value change to 1/1/1001. But if pass primitive types such as int, string, no problem. This is happening only on one machine, but not on ther machine. Can someone tell me what is going on here? Thanks in advance

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

Trouble assigning properties for multiple CSS classes

Hi Can anyone tell me why the first block of CSS below works, but the second one doesn't? Thanks Block 1: (works) <style type="text/css">  .FB  {      margin-bottom: 0.5in;      margin-left: 0.5in;      text-align: left;      float: left  }  .FB  {      color: Black;  }</style> Block 2: (Doesn't work - all I get for FB is color: Black)<style type="text/css">  .SomeOtherClass, FB  {      margin-bottom: 0.5in;      margin-left: 0.5in;      text-align: left;      float: left  }  .FB  {      color: Black;  }</style>

System.ComponentModel.DescriptionAttribute not showing up in REST service

I am trying to set the description for a REST WCF service, but it doesn't seem to be working. Code is: [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]     [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]     [WebDispatchFormatterConfiguration("application/xml")]     [WebDispatchFormatterMimeType(typeof(WcfRestContrib.ServiceModel.Dispatcher.Formatters.PoxDataContract), "application/xml", "text/xml")]     [WebDispatchFormatterMimeType(typeof(WcfRestContrib.ServiceModel.Dispatcher.Formatters.DataContractJson), "application/json")]     [WebDispatchFormatterMimeType(typeof(WcfRestContrib.ServiceModel.Dispatcher.Formatters.FormUrlEncoded), "application/x-www-form-urlencoded")]     public class PublicAppointmentSchedulerSvc : IPublicAppointmentScheduler     {         IPublicAppointmentScheduler impl = new PublicAppointmentScheduler();         [WebDispatchFormatter]         [Description("Immediate or callback contact request")]         [WebInvoke(UriTemplate = "InitiateContact", Method = Verbs.Post)]  &n

GoDaddy + WCF REST Service

I am newbie when it comes to developing a WCF REST Service. I have been reading up and have worked through hands-on labs/watched videos by Ron Jacobs to help me get a hold of WCF REST.  I have had no problems running my web service on my localhost. However it is now time to upload my "WCF Service Application" (not WCF Library) to GoDaddy's servers and this is where I am running into issues. As per Ron Jacobs tutorials I have removed my endpoints from my web.config file and the markup code in my .svc file now reads: <%@ ServiceHost Language="C#" Debug="true" Service="DealService.Service" CodeBehind="Service.svc.cs" Factory="System.ServiceModel.Activation.WebServiceHostFactory"%> I proceeded to compile and then upload my code to GoDaddy and now am trying to access the web service, but am receiving the following error: Server Error in '/' Application. Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.  Parser Error Message: The CLR Type 'System.ServiceModel.Activation.WebServiceHostFactory' could not be loaded during service compilation. Verify that this type is either defined in a source file located in the application's \App

ASP.Net Client for Php REST Service

 I am writing some code in an asp application that needs to communicate with a PHP REST Service. I have 2 questions. 1.  In my data variable I have to put the POST parameters.  If I needed to put reserved characters like & or ? into the string is there an escape character I can use?  Or would encoding it work?  Or would it totally depend on how the web service works? 2.  Is the code I am using the usual way to make a POST connection to a REST service?  Or is there an easier/faster way? Below is the code I am using Dim uri As New Uri("http://help.domain.com/api/index.php?method=request.create") Dim data As String = "tNote=Testing Code&sEmail=test@test.com" If uri.Scheme = uri.UriSchemeHttp Then Dim request As HttpWebRequest = HttpWebRequest.Create(uri) request.Method = WebRequestMethods.Http.Post request.ContentLength = data.Length request.ContentType = "application/x-www-form-urlencoded" Dim writer As New StreamWriter(request.GetRequestStream) writer.Write(data) writer.Close() Dim oResponse As HttpWebResponse = request.GetResponse() Dim reader As New StreamReader(oResponse.GetResponseStream()) Dim tmp As String = reader.ReadToEnd() oResponse.Close()
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