Testing WCF services with user credentials and binary endpoints

This article discusses the following error messages that you might receive from a WCF service
  • An error occurred when verifying security for the message
  • HTTP/1.1 415 Cannot process the message because the content type 'application/soap+xml;charset=UTF-8;action="..."' was not the expected type 'application/soap+msbin1'

When doing analysis work on existing services, invoking them in a safe test environment is a handy way of getting an understanding of their operations, especially if the documentation has gone missing (or was never written).

SoapUI is a tool that can be used to test WCF Services, but did you know that Visual Studio also comes with its own set of tools?

Let's start with SoapUI, which is available from http://www.soapui.org/. Its operations are quite straight-forward; however, you might run into issues when trying to access services that are protected by user credentials, or when accessing services with binary endpoints.

If you receive a message saying 'An error occurred when verifying security for the message' when invoking your service, try adding your domain credentials to the SoapUI Request Properties window:


Also, set the WSS-Password Type field to PasswordText.

Moving on, if you instead get a response from your services with a header saying something akin to ...
  • HTTP/1.1 415 Cannot process the message because the content type 'application/soap+xml;charset=UTF-8;action="..."' was not the expected type 'application/soap+msbin1'
... it's because the service in question is using binary serialization, something SoapUI is unable to cope with. At this point, you have two options - either you can create a custom test application for this service, or you can use Microsoft's WCF Test Client, which you'll find in the IDE-directory of your Visual Studio Installation (e.g. C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE).

Now, the reason your service has a binary endpoint could be because it outputs a lot of data. If so, even with Microsoft's test client, you might run into issues with your service outputting more than is configured as the default max received message size. To get around this (again, to analyze an existing service), right-click the Config File node in WcfTestClient (after having loaded (File -- Add) your service, that is) and select Edit with SvcConfigEditor ...

... increase MaxReceivedMessageSize ...


 --> 


... Save & Close. You should now be able to invoke your binary endpoint that outputs a lot of data.

Good luck with your analysis!

Comments

Popular posts from this blog

Auto Mapper and Record Types - will they blend?

Unit testing your Azure functions - part 2: Queues and Blobs