Is there something in WCF that can simulate http streaming like IHttpHandler can do?
I want a way to constantly write bytes to my http response non stop to my client until there is nothing left to write using WCF and was just wondering if this is possible?
Thanks
WCF allows streaming by setting the TransferMode property of the binding to 'Streamed', 'StreamedRequest' or 'StreamedResponse', depending on your needs.
Check the following MSDN articles for more information on it:
Streaming Message Transfer
Large Data and Streaming
Related
I have an endpoint that connects to SQL and returns a result set to the client. The WCF Service sets the MaxReceivedMessageSize to a low value and therefore the endpoint does not return a result set.
I fixed the issue by increasing the MaxReceivedMessageSize value. However, I need to see just how much data is coming from the endpoint to the client.
I tried using Postman but that's not working. What's the best way to capture what the endpoint is returning to the client?
Thank you
You can inspect or modify the incoming or outgoing messages across a WCF client by implementing a System.ServiceModel.Dispatcher.IClientMessageInspector and inserting it into the client runtime.
Inspect messages not only implements the inspector on the client side, but also manipulates the endpoint behavior.
I need to streaming a large content with WCF and deferred execution (using NetTcpBinding), in other words, return a list of person (can be anything) from a database through a WCF service without consume all memory in the server side.
I have tried the solution in this post: Streaming large content with WCF and deferred execution
Using BasicHttpBinding it works like a charm, but when using NetTcpBinding....well...not working.
Can anyone help me with this??
Tks!
Project here: WCF Streaming IEnumerable
Here is guidance on transferring large data with streaming.
http://msdn.microsoft.com/en-us/library/ms733742.aspx
At the bottom of the page is a link to some samples, one of which shows using TCP.
http://msdn.microsoft.com/en-us/library/ms789010.aspx
If this doesn't help, then perhaps you could provide more detail on how it is failing (error message)?
I want to log every request xml message in my WCF service project to database. Please suggest me which is the best and preferred approach.
1) Using idispatchmessageinspector interface
http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.idispatchmessageinspector(v=VS.90).aspx
OR
2) writing Custom SQL database trace listener?
You would have to write a custom WCF Trace Listener.
Look here for some help: http://www.enusbaum.com/blog/2007/05/19/creating-a-custom-listener-for-your-wcf-application-in-c/ and http://weblogs.thinktecture.com/cweyer/2009/06/custom-tracelistener-writing-trace-messages-to-the-net-services-service-bus.html
The best approach usually depends on various factors, but in your case it seems that using message inspectors would be a preferred approach as this is what it was build for i.e to capture WCF messages and do whatever you want do with them.
SQL trace is to trace SQL messages (communication between SQL server and SQL client applications) and not WCF messages.
I think using idispatchmessageinspector interface and use ThreadPool.QueueUserWorkItem() to read the request and log into database in AfterReceiveRequest event will be better when compared to using Tracing. I feel Tracing may be have some overhead as it is meant for some diagonistic purposes and do not want to enable tracing in prod permanently.
Is there any issues using idispatchmessageinspector and ThreadPool.QueueUserWorkItem() for logging the request message to database?
Thanks!
Bala
Is there a way to intercept the raw data that's being sent over a TCP WCF endpoint? I have implemented IClientMessageInspector but I am not sure if that's what's actually being sent over the wire.
My goal is to measure the performance of different serializers. I know there is some information out there but I would like to take a closer look at how they behave in my app.
Enable Message Logging in your configuration. To see the raw messag you want to log at Transport level.
You probably want to look into the built-in tracing capabilities of WCF. I don't have a link handy, but search for WCF tracing.
With traditional ASMX web services synchronous request, the client connects, makes a request and waits for the entire message body to be returned.
I was wondering if its possible to have chunks of data flushed back to the client instead with WCF?
This way I can display some progress to the client app during the operation.
With WCF you can use streaming for download/upload. Check this links:
WCF Streaming in MSDN
File Transfer Progress example in CodeProject
Using WCF you can either use streaming or duplex messages to achieve that. Using streaming you are restricted to returning a single stream object. using duplex duplex messaging you pass a callback channel to the server and it can use that channel to make as many calls as you like to the client.