.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

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

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :WPF

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" 

View Complete Post

More Related Resource Links

Send object from one page to another



I want to create object in 1.aspx, and then send it to 2.aspx. This methods are bad, because:

1)Send object with url, like this:


This is not confidential.


Session["field1"] = "12345"; // set
Object foo = Session["field1"]; // get

This is bad too, because in 2.aspx this fields send to textboxes, and if user go to 2.aspx without 1.aspx, he'll see old data. 

MSMQ and .NET: Send MSMQ Messages Securely Across the Internet with HTTP and SOAP


When creating a distributed system you frequently need to provide for communication between two entities that are not in sync. Microsoft Message Queue Server (MSMQ) provides the kind of store-and-forward messaging in a pre-built infrastructure that can help you address these kinds of messaging needs. In the past, MSMQ was accessed using a COM wrapper. Now there's a .NET wrapper that lets you accomplish your messaging goals easily from your Framework-based code. To illustrate the use of the wrapper, the author builds a messaging application, sends MSMQ messages over the Web, and discusses messaging security.

David S. Platt

MSDN Magazine December 2003

send data in class object from one page to another using session


hello everybody

now i hav stored all data like user name, data fatched from database of that user

and i stored that data and user name such as:

string strUserName="user name"

dataset ds =new dataset();// data of that user

now i wan yo send d whole data from my login page to user profile page

can anybody help me for that...................

and plz tell me that how much is this way is benifitial to send data from one page to another page

plz........kindly waiting for positive rply

Web Service that will receive xml request and send xml response


I am trying to create a web service that can do the following functionality:

Request XML 

<?xml version="1.0" encoding="UTF-8"?>
<Authentication UserName="test" Password="test" MyId="0987">

Response XML - After authenticating request xml from client send them back the following response:

<?xml version="1.0" encoding="UTF-8"?>
   <Test MyId="0987">
       <TestType id="11"></TestType>
       <TestType id="22"></TestType>

How can I create web service to do this.

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?

Cannot send List inside of Dictionary

List<string> receivers = new List<string>(); foreach (object item in listBoxControl1.SelectedItems) receivers.Add((string)item); Dictionary<string, object> inArgs = new Dictionary<string, object>(); inArgs.Add("Receivers", receivers); inArgs.Add("Sender", client.name); inArgs.Add("Message", memoEdit2.Text); inArgs.Add("IsGuaranteedDelivery", true); inArgs.Add("DataType", TransmitToClientDataType.ChatMessage); if (service != null) service.AddTask("orion_send", inArgs); There is an error with serialization at last string because List<string> object. I tryed to send List<T> object via WCF, it's succesfull. But why there are problems with List<T> included to Dictionary?

Service for reading custom DLQ in WCF MSMQ 4.0

Hi folks, i want to write the web service that will be read messages from DLQ.   As i understand if the message can not be delivered(there are other cases such as timeout, authentication etc.) from Client to Service, then message will be placed to DLQ(in this case i use custom DLQ), and DLQ Service will be called automatically.  I wrote the 3 services: client, service and DLQ Service, but  when i turn off the service(server) and make client calling service, then message is not placed to DLQ(appropriate methods not called in DLQ Service). But when i turn on service messages are delivered to service.  My code below :  // server app.config  <?xml version="1.0" encoding="utf-8" ?> <configuration>   <system.web>     <compilation debug="true" />   </system.web>   <!-- When deploying the service library project, the content of the config file must be added to the host's    app.config file. System.Configuration does not support config files for libraries. -->   <system.serviceModel>     <services>       <service name="Service.MyService" behaviorConfiguration="Service.Service1Behavior">         <host>   

WCF Routing service with Backup List not working with MSMQ

Hi I developed routing service for round robin routing. I added backup lists to this routing service in round robin pattern in config file. My configuration is as below. <services>       <service behaviorConfiguration="routingConfiguration" name="System.ServiceModel.Routing.RoutingService">         <host>           <baseAddresses>             <add baseAddress="net.tcp://localhost/FDPRoutingService/router"/>           </baseAddresses>         </host>         <!--Set up the inbound endpoints for the Routing Service-->         <!--first create the general router endpoint-->         <endpoint address="" binding="netTcpBinding"                   name="NetTcpBinding_IFDService" contract="System.ServiceModel.Routing.ISimplexDatagramRouter"/>       </service>     </services>  &nbs

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

How to Listen to MSMQ and Database table from a single WCF service

Hi, I have one WCF service which is listenibg to MSMQ. Once message is added to MSMQ, it will start processing the business logic. But my requirement is to make this WCF service to listen to one database table also. If any message is logged to this table or any message added to MSMQ, the WCF service should start processing the business logic. Could you please let me know if it's feasible using WCF service. It would be great if you can tell me the alternate approaches to implement this functionality. Ram.  .NET related discussions

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 ?

Send/open timeouts on WAS-hosted WCF service with named pipe orTCP binding, per-call instancing

We have a client that sends requests to a per-call WCF service (WAS hosted, NP binding, same machine) in a loop. The WCF service calls an external EXE to process requests. The operations on the service can take a few seconds, or a few hours. To combat this, we have sendTimeout=00:05:00, receiveTimeout=00:05:00 and a built-in circuit-breaker on the service that kills the external process after 00:05:00. Any service-side errors are returned to the client as FaultExceptions.  On the client, FaultExceptions are logged and the client proxy is aborted (proxy.Abort()). The client has configurable multithreading. In this example, it is running 3 threads, each of which creates a proxy, makes a call, and closes the proxy (or aborts it if an exception was received). Since the service is instanced as per-call, and it never receives more than 3 simultaneous calls (each of which being followed by a .Close() or .Abort() on the proxy), I would not expect the client to be getting timeouts during the send, but I am. In fact, the send timeouts I am receiving would seem to imply that the WCF service is hitting the default session limit, even though the class is explicitly marked with [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]. I put some trace logging on the client and I can see that the timeout is occurring when the proxy is being created. sendTimeout seems to

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.

How to send binary data ( ogg audio file) using a web service?


Hi folks, I would appreciate any help or guidance on this topic:

How can I receive binary data (specifically an ogg audio file) using a WCF4 service?

The general idea is to define and host a WCF service inside IIS that returns an audio file (ogg file)

I have read some info related with using ByteStreamMessageEncodingBindingElement class to achieve this, also I read some topic related on using MTOM to attach a binary file. It seems that it can be several ways or approaches to achieve this.

So any guidance on the themes and/or examples for the better way to solve this point would be very appreciated.

Thanks in advance.



400 Bad Request when trying to send large file to service using basichttp streaming.


Hi All,


I am trying to send the large file (approx 1.5GB) to the WCF service for upload using basic http streaming.

I have increased all the timeouts and quotas in the server and client's config files to quite large values, but still I am getting Bad Request error on the client.


Also the Bad request message is returned always in 1 minute 30 seconds after sending the request to server.


What the most unusual thing is when I use Fiddler or Charles to debug communication, everything works fine. Is it something like fiddler is pinging the IIS or service and hence its not getting timeouted or like that?




Following are the details:

Server Config:


 <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

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
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