.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

What's Service Object and how to write my Service Object

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :.NET Framework


I read description of Component.GetService in MSDN and it says that GetService return service object provided by Component or Container.

I want to know how to write a service object and can be retrieved by GetService.


View Complete Post

More Related Resource Links

MCTS 70-503 Practice exam about service object instancing

The question says the default behavior for instancing service object is that each instance is associated with one user-defined service object, but in the book, 'MCTS Self Training Kit', it is said that the default behavior is PerCall. Is this a bug in the practice exam?

How to use return JSON object from web service as a declared Type?

Hi, I just hit the following issue: I am calling a web service that returns a serialized JSON object let's say: __type, FirstName, LastName (.net object Person with properties FirstName and LastName). __type's value is Test.Person I have created a JS object using Type.registerNameSpace/registerClass called Demo.Person and it is registered on the page using the ScriptManager. Everything is working fine; I am able to get data from the server on the call back. Is it possible to make the returned object from the web service be an instance of the declared JavaScript Demo.Person class? The idea would be to call a method like result.getFullName() on the client side without having to copy all the properties. This is just a simple scenario for more complex objects.   Thanks,   Teo

passing messageContract object to a WCF Service method using Soap - not as a method parameter

i want a web application to create a service reference to my WCF service, insert information to the header of the soap call and call my WCF method. my WCF supports soap operations (also there is an endpoint in the config). i read about MessageContract attribute and declared one in the interface file: [ServiceContract] public interface IBasicService { [OperationContract] [WebGet(UriTemplate = "GetData?value={value}")] // Add support for HTTP GET Requests string GetData(int value); } [MessageContract] public class BasicServiceHeader { [MessageHeader] public string myString; } the implementation of the contract : public class BasicService : IBasicService { public string GetData(int value) { return string.Format("You entered: {0}", value); } } i don't want the BasicServiceHeader to be passed as a parameter of GetData function , i want to keep the function signature as it is (without a BasicServiceHeader parameter) and to extract the BasicServiceHeader inside the function, (just like using soapHeader) can i do that ?

passing XMLDocument object as input to WCF service



i have to write a WCF service which accepts XMLDocument object as input.

In my contract, I have defined a function like this:

bool validate(XmlDocument doc);

In my service, the function is implemented llke this:

public bool validate(XMLDocument doc)


code to validate the doc against an XSD file

From my test project i am passing an XML document.

But it says service cannot be found.

Instead if i define XMLDocument doc inside function like this:

public bool validate()


XMLDocument doc= path of document

code to validate the doc against an XSD file

and contract like this:

bool validate();

it works fine.

It validates the XML against an XSD and returns true or false.

Please help.

QuotaExceededException only when service returns a FaultException where T is a rather big object


I receive a QuotaExceededException when the service returns an object via FaultException<T>. If the same object is returned directly as the result of the WCF Operation, then everything works perfectly. Any Idea ?

Here is the stack trace :

---- Exception ----
[QuotaExceededException] The size necessary to buffer the XML content exceeded the buffer quota.

Server stack trace:
   at System.ServiceModel.Channels.BufferedOutputStream.WriteCore(Byte[] buffer, Int32 offset, Int32 size)
   at System.ServiceModel.Channels.BufferedOutputStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Xml.XmlStreamNodeWriter.FlushBuffer()
   at System.Xml.XmlBinaryNodeWriter.FlushBuffer()
   at System.Xml.XmlStreamNodeWriter.GetBuffer(Int32 count, Int32& offset)
   at System.Xml.XmlStreamNodeWriter.UnsafeWriteUTF8Chars(Char* chars, Int32 charCount)
   at System.Xml.XmlBinaryNodeWriter.UnsafeWriteName(Char* chars, Int32 charCount)
   at System.Xml.XmlBinaryNodeWriter.WriteName(String s)
   at System.Xml.XmlBinaryNodeWriter.WriteXmlnsAttribute(String prefix, String ns)
   at System.Xml.XmlBaseWriter.NamespaceManager.DeclareNamespaces(XmlNodeWriter writer)
   at System.Xml.XmlBaseWriter.Wr

Component Service Error; Where is the object?


Has anyone seen this before?

The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID {000C101C-0000-0000-C000-000000000046} to the user QUILNET\SPFarmAccount SID (S-1-5-21-174560267-3847720226-3386768351-2185) from address LocalHost (Using LRPC). This security permission can be modified using the Component Services administrative tool.

I looked for 000C101C-0000-0000-C000-000000000046 in the component services MMC but I couldn't even find any existance of it to change the permissions. any ideas?


Owner, Quilnet Solutions

CreateDocument method in CMIS Object Service raising the Constraint Violation Exception


HI All,

Below are the code snippet for rasing the above exception like  "The operation violates a Repository- or Object-level constraint defined in the CMIS domain model. "


ObjectServicePortClient objectService = new TestCMISWinApp.ObjectService.ObjectServicePortClient("BasicHttpBinding_IObjectServicePort");

objectService.ClientCredentials.Windows.AllowNtlm =



Service returning Object fails when object is complex class


Hi. I have created a WPF client and a self-hosted WCF Service based on an interface, in wich alle methods returns a standard response class. An example of one such method definition is:

Response CreateAccount(AccountCreationParams accountParams);


The response object is defined as:



public class Response



public string ResponseText;


public bool CompletedSuccesfully;



Can add web service reference but cannot see it in object browser or use it


I have added the following wsdl: http://burstons.nexcess.net/mom/mom.wsdl to a console app.  I see it under web references, when I right click to view in object browser it is not present.  If I right click Update Web Reference I get the error: The custom tool MSDISCOCodeGenerator failed.  Unable to import binding 'BlueAcornWebserviceBinding from namespace urn: WSDLMOM...  I can access this WSDL in Foxpro but not in Visual Studio 2008... Am I missing something...


Pass object to web service


I'd like to pass an object (Digital Persona featureset) to a web service.  Can't seem to find a good way to serialize it.

Any suggestions?


error using a custom collection object in a WCF service


I'm relatively new to WCF but have gotten most of my service to work very well. I'm having one "strange" problem: My service makes use of several custom data types, and all of them work fine except for the custom collections. Note...I am NOT trying to pass a collection object to the client...I am simply trying to initalize and use it from the main service object. Here is an example:

<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)> _
Public Class User
    Implements IUser

    Public Memberships As new Memberships   ' this is the collection I am calling!

    Public Function countMemberships() as integer Implements IUser.countMemberships
         return Me.Memberships.count       'this returns an error! Object reference not set to an instance of the object...

    End Function 

End Class

' and here is my custom colection 

Public Class Memberships
    Inherits System.Collections.CollectionBase

    Public Sub Add(ByRef Membership As Membership)
    End Sub


Passing an object with a TimeSpan field to web service resets the TimeSpan to 00:00:00


Hello all,


I have a web service that takes a TaskGroupRecord object as a parameter. This object is defined as:

  public class TaskGroupRecord
    public Guid TaskGroupID { get; set; }
    public string Name { get; set; }
    public DateTime StartDate { get; set; }
    public TimeSpan Duration { get; set; }
    public RepeatSchedule Schedule { get; set; }

    public TaskGroupRecord()
      //TaskGroupID = Guid.Empty;
      //Name = string.Empty;
      //StartDate = DateTime.MaxValue;
      //Duration = new TimeSpan();

Keep object alive on server in a WCF service


Hello all,

              I have to keep a datacontext alive in a WCF service. This object is created on every call to the service, by the way decreasing performance. How could I keep this object alive with WCF.

Thanx a lot !

Passing an exception object to a WCF service


I'm pretty new to WCF , as an experiment I was trying to create a WCF service wrapper over an exception handler class which is using the enterprise library underneath.

I created a simple class with one exception variable, which gets exposed as the data contract

when I try to pass the exception to the WCF service I get the following serialzation error

There was an error while trying to serialize parameter http://tempuri.org/:ex. The InnerException message was 'Type 'System.Collections.ListDictionaryInternal' with data contract name 'ArrayOfKeyValueOfanyTypeanyType:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. 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.'.  Please see InnerException for more details.

I configured the app.config for the calling application by adding Syste.Exception as known type in the DataContractSerializer

        <add type="System.Exception, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <knownType type="System.Exception, mscorlib, Version=, Cult

Best method for typing a custom object thru a web service


I have several web services with a custom business object being used as a parameter (MyNamespace.MyBizObj).

After I create my web references that same  business object gets retyped to whatever web service that is is in Example:

webserviceRef1.MyBizObj, webserviceRef2.MyBizObj, webserviceRef3.MyBizObj


Right now my UI isn't allowing me to retype this object back to the object that I need. In essence I need one unified version of this object that I can use across web services.

How to send an object using MSMQ and WCF service C#?


I'm trying to send an object in a queue:


PurchaseOrder po = new PurchaseOrder();
      po.CustomerId = "somecustomer.com";
      po.PONumber = Guid.NewGuid().ToString();

      PurchaseOrderLineItem lineItem1 = new PurchaseOrderLineItem();
      lineItem1.ProductId = "Blue Widget";
      lineItem1.Quantity = 54;
      lineItem1.UnitCost = 29.99F;

      PurchaseOrderLineItem lineItem2 = new PurchaseOrderLineItem();
      lineItem2.ProductId = "Red Widget";
      lineItem2.Quantity = 890;
      lineItem2.UnitCost = 45.89F;

      po.orderLineItems = new PurchaseOrderLineItem[2];
      po.orderLineItems[0] = lineItem1;
      po.orderLineItems[1] = lineItem2;

      OrderProcessorClient client = new OrderProcessorClient("OrderResponseEndpoint");

      MsmqMessage<PurchaseOrder> ordermsg = new MsmqMessage<PurchaseOrder>(po);

      ordermsg.Label = "MY MESSAGE"

BITS: Write Auto-Updating Apps with .NET and the Background Intelligent Transfer Service API


Both the .NET Framework and Windows have some very interesting APIs for creating applications that are capable of updating themselves automatically over a network. There are many advantages to writing your application to update itself like Windows Update does, including convenience for your users, from easier maintenance to network administration. Automatic updates require attention to factors such as discovery, security, and file replacement. In this article, the author covers the BITS API as well as a number of features of the .NET Framework that take care of these facets of auto-updating using the same facilities that the Windows Update uses.

Jason Clark

MSDN Magazine February 2003

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