views:

1238

answers:

4

I have a unique problem and I would like the capability to process an incoming HTTP POST request that contains arbitrary binary data.

I can currently process this data using a standard ASP.NET Page handler or in an ASP web service, but I want to know if its possible to processing INCOMING binary data in a WCF service? Can I drill down into the WCF processing stack to bypass the SOAP processing and handle the raw message in my own code?

I understand that this breaks the 'contract' publishing of WCF (WSDL whatever), but I don't really care about that.

-Jeff

A: 

As long as I know you can configure the service binding: http://www.c-sharpcorner.com/UploadFile/pjthesedays/bindwcf05032009012251AM/bindwcf.aspx

Using the netTcpBinding

Timotei Dolean
First, after reading the mentioned article and others, I don't believe 'binary' encoding is arbitrary binary data. I believe its 'binary' encoding of XML/SOAP. Next, if it is what I'm looking for, Silvelight doesn't support it, which I forgot to mention in a requirement.
Jeff
A: 

You can use straming MSDN

ArsenMkrt
After investigation, I do believe that this might solve the problem. A Streaming contract allows me to just send a chunk of data and doesn't seem to require or use any XML wrapping or encoding. It has some detractors, but it should fit my requirements.
Jeff
A: 

Consider using MTOM. MTOM is a mechanism for transmitting large binary attachments with SOAP messages as raw bytes, allowing for smaller messages. For details see:

http://msdn.microsoft.com/en-us/library/aa395209.aspx

Shiraz Bhaiji
Not currently available in silverlight and I'm trying to avoid any XML encoding.
Jeff
A: 

After spending a few weeks on this problem, I have pretty much a definitive answer:

Can you replace XML/SOAP with a custom binary serialization for WCF?

The short answer: no

The long answer: yes, but you have to rewrite almost all of the transport layer interfaces so you might as well just create a custom IHttpHandler and avoid WCF all together.

Microsoft, in attempting to follow the SOAP standard (and the standard is responsible for this problem in my opinion) breaks one of the simple programming rules -> separation of responsibilities in the layers. WCF/SOAP may appear to be a elegantly layered protocol and transport, but the reality is, is that there are intricate connections between the layers. This means that WCF is an extremely complex communication protocol that provides transport, security, reliability, publishing, serialization and other features that are all interdependent at some level. If all you want is a transport channel, WCF/SOAP adds a tremendous amount of complexity.

I'm sure I could start huge rants about SOAP yes/no, but I finally realized that WCF/SOAP is not what I needed for my application.

-Jeff

Jeff
You're totally wrong. Where do you get this crap? How about the netTcpBinding or the other bindings that use binary? I don't know what research you did, but you did a damned poor job of it.
John Saunders
Ok, apologies... I realize that my OTHER post mentioned silverlight, this one didn't. You are correct John, there are WCF binary bindings IF you are not in Silverlight, my bad. -Jeff
Jeff