We help IT Professionals succeed at work.

Hoist the colors! We’ve added location flags to usernames sitewide, so it's easier to connect with the global community on EE. View My Profile


Problems when performing HTTP Post to WCF Service (Error 415: Cannot process the message because of content type mismatch)

nkewney asked
Last Modified: 2012-05-11
Hi Everyone,

I'm having real problems posting data to a WCF service. I would be very grateful if anybody could help me diagnose the error I'm receiving below.

The remote server returned an error: (415) Cannot process the message because the content type 'application/x-www-form-urlencoded' was not the expected type 'text/xml; charset=utf-8'..

I'm sending data to the service via a simple HTTP post as content type = "application/x-www-form-urlencoded".

My WCF interface and config is pasted below.
public interface ITextService
[WebInvoke(UriTemplate = "invoke", Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest)]
string PostData(Stream input);

public string PostData(Stream input)

<?xml version="1.0"?>
<add name="HttpPost" />
<compilation debug="true"/>
<customErrors mode="Off">

<!-- 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. -->
<binding name="WebConfiguration"
<binding name="StreamedHttp" transferMode="Streamed" maxBufferSize="2147483647" MaxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<service name="SimFreeGateway.TextService" behaviorConfiguration="SimFreeGatewayBehavior">
<endpoint address="" binding="basicHttpBinding" contract="SimFreeGateway.ITextService" bindingConfiguration="StreamedHttp" bindingNamespace="xxx" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
<behavior name="WebBehavior">
<webHttp />
<behavior name="WebBehavior">
<serviceDebug httpHelpPageEnabled="false" httpsHelpPageEnabled="false" />
<serviceMetadata />
<behavior name="SimFreeGatewayBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="true" />
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

Open in new window

Watch Question

Carlos VillegasFull Stack .NET Developer

Hello, I think that you need to use a WebHttpBinding endpoint instead of BasicHttpBinding, I did that some time agon, more info:

The Web Programming Model allows developers to expose Web services through HTTP requests that use "plain old XML" (POX) style messaging instead of SOAP-based messaging. For clients to communicate with a service using HTTP requests, an endpoint of the service must be configured with the WebHttpBinding that has the WebHttpBehavior attached to it. The WCF Web Programming Model also requires that the individual service operations are annotated with the WebGetAttribute or WebInvokeAttribute attributes. This defines a mapping from a URI and HTTP method to the service operation, as well as the format of the messages used to call the operation and return the results. Support in for syndication and ASP.AJAX integration are both built on top of the WCF Web Programming Model.
Full Stack .NET Developer
This one is on us!
(Get your first solution completely free - no credit card required)


This solved my problem and was an oversight on my part.

Thanks for your help
Carlos VillegasFull Stack .NET Developer

Good to know buddy

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.