Viewing encoded wcf message - wcf

I am using svc trace viewer and i am able to see the soap message by enabling message logging.
But since http binding uses text encoding and net tcp uses binary encoding,
I enabled trace to view message at service level and at transport level, the message seems to be same with both http and tcp binding.
I would like to know if it is possible to to see the encoded message using svc trace viewer or if any other tool is available .

Related

WCF: Catching Response that is not SOAP

I am have been setting up a WCF Client to connect to a Service that I do not have control of (I think the service is implemented in Java).
The service requires Certificate security and I got all the certificates setup but I get the following error when I connect to the endpoint
An HTTP Content-Type header is required for SOAP messaging and none was found.
I have setup SchemaValidationMessageInspector (http://msdn.microsoft.com/en-us/library/aa717047.aspx) to catch the Request and Response.
I can see that the Request is caught but not the response.
As I understand it is because the response is not of the SOAP format meaning that the Validation method is not triggered.
I expect that the real error is a 404, 403, 500 or something like that.
I have been using Wireshark to inspect the packets but it's all encrypted since it's too early in the "stack". I need the response right after the https decryption have occurred.
How can I catch the none SOAP responses so I can see the error in a clear format?
Use Fiddler or WCF Trace http://blogs.msdn.com/b/madhuponduru/archive/2006/05/18/601458.aspx to see the raw message. If you want to do this from code use a WCF custom messgae encoder http://msdn.microsoft.com/en-us/library/ms751486.aspx.

SOAP not getting encoded as MTOM in a WCF client

I am connecting to a DFS(Documentum Foundation Services) instance from a WCF client.
I am using basicHttpBinding and I have set the messageEncoding="Mtom". However, when I inspect the soap, I see the document within the SOAP envelop. The document part in the SOAP is about 1.33 times the actual doc size. So the message is getting Base64 encoded.
Do I have more settings to change on the WCF side Or is there a MTOM setting that is not enabled on the DFS side?
Does wsoma:OptimizedMimeSerialization have to be there in the WSDL?
Thanks
http://www.w3.org/Submission/WS-MTOMPolicy/
I guess, my question is: does the Java web service WSDL has to have this wsoma:OptimizedMimeSerialization element, otherwise it implies that the web service does not support MTOM?
Which also implies that if the Java based web service did support MTOM and then if I add a service reference using the WSDL, Visual Studio should automatically create the appropiate binding with messageEncoding="Mtom"??

SSL and WCF Transport Security

I have an IIS-hosted WCF service which is configured to use basicHttpBinding with transport security.
I have configured IIS with a certificate and I'm using an https endpoint to call the service.
Now, I have enabled message logging on the service at transport level - however, the messages I'm seeing are in clear text. Is this right? If so, why? Is there a way to see the encrypted messages?
Thank you in advance,
Fabio
This is correct behavior. Transport layer handles its decryption before it passes message to upper layer api like WCF so WCF always get message decrypted and it can't intercept the process - transport security is outside of WCF. Encrypted message on transport layer is logged only if you use message security because in such case transport layer just passes the message as is to WCF to deal with it.
Use Fiddler and don't enable SSL decryption in the options. It will allow you to inspect the message traffic as it is on the wire.
Also, worth reading is Debugging Localhost Traffic with Fiddler, a common gotcha for those new to Fiddler. Then check out the info page on HTTPS decryption, if you're interested in using that feature later.

WCF netTcpBinding MaxReceivedMessageSize and Custom UsernamePasswordValidation

I'm building a WCF Service that uses Custom Username/Password validation on netTcpBinding with message level security. I've been researching MaxReceivedMessageSize settings and I've got a query of a rather technical nature. I've noticed that when you specify a custom username validator that it gets called deep inside the plumbing of WCF (during handshaking I suppose).
If I have a relatively large MaxReceivedMessageSize of 1MB, will WCF read the entire message off the line and then do authentication, or will it first do the authentication and somehow discard the rest of the message?
The reason for my query is DoS attacks. I am hoping that due to the authentication the service would be immune to large message DoS attacks.
I believe that full message is loaded. The message is first processed by transport channel which doesn't have any information about message security. So the channel reads the whole message with using selected encoder and creates Message instance. This instance is passed to futher processing including message security checking. The only exception is when you use Streamed transfer mode. In that case only message headers are read in receiving channel and placed to buffer.
To prove this you can also turn message logging which is able to log messages on transport level and at service level. Transport level is message received from transport, service level is message received at service (after all security processing). So the message is already read at transport level.

See what XML is being serialized down the wire for a WCF Service

I have a WCF service that I pass a lit of objects down from the server to the client, what I would like to do is to know what exactly is getting passed down to the client.
How can I see the unecrypted serialized payload that is sent over the wire?
WCF has very extensive tracing support which allows you to capture and later view and analyze all messages going over the wire.
Check out the MSDN docs and other sources for great information:
Configuring WCF Tracing
WCF Service Trace Viewer Tool
WCF Tracing FAQ
WCF Tracing and Message Logging
Use Fiddler on the client machine. It acts as a local proxy and allows you to inspect the HTTP traffic.
Note that there are some limitations with HTTPS traffic, but since you are testing your own WCF service, you can temporarily switch to HTTP for inspection of the packets payload, even if you intend to deploy it as HTTPS in production.