I trying to consume a WCF web service using stand alone application. I am able to view this service using Internet Explorer also able to view in Visual studio service references.
This is the error I am getting
The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8).
How do I change this to use the correct content type?
Here is my config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="G2WebServiceSoap11Binding" />
</basicHttpBinding>
<customBinding>
<binding name="G2WebServiceSoap12Binding">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://XXX.XX.XX.XX:XX/janus/services/G2WebService.G2WebServiceHttpSoap11Endpoint/"
binding="basicHttpBinding" bindingConfiguration="G2WebServiceSoap11Binding"
contract="G2ServiceReference.G2WebServicePortType"
name="G2WebServiceHttpSoap11Endpoint" />
<endpoint address="http://XXX.XX.XX.XX:XX/janus/services/G2WebService.G2WebServiceHttpSoap12Endpoint/"
binding="customBinding" bindingConfiguration="G2WebServiceSoap12Binding"
contract="G2ServiceReference.G2WebServicePortType"
name="G2WebServiceHttpSoap12Endpoint" />
</client>
</system.serviceModel>
here is the stack
{System.ServiceModel.ProtocolException: The content type application/xml;charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly.
The first 1024 bytes of the response were: '<Exception>org.apache.axis2.AxisFault: The endpoint reference (EPR) for the Operation not found is /janus/services/G2WebService and the WSA Action = null
at org.apache.axis2.engine.DispatchPhase.checkPostConditions(DispatchPhase.java:89)
at org.apache.axis2.engine.Phase.invoke(Phase.java:333)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:264)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:163)
at org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:136)
at org.apache.axis2.transport.http.util.RESTUtil.processURLRequest(RESTUtil.java:130)
at org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processURLRequest(AxisServlet.java:829)
at org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java:255)
at com.rm.janus.webservice.GroupCallServlet.doGet(GroupCallServlet.java:33)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpSer'. ---> System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at InetgrisG2TestApp.G2ServiceReference.G2WebServicePortType.getStudentData(getStudentDataRequest request)
at InetgrisG2TestApp.G2ServiceReference.G2WebServicePortTypeClient.G2TestApp.G2ServiceReference.G2WebServicePortType.getStudentData(getStudentDataRequest request) in c:\Users\s\Documents\Visual Studio 2012\Projects\G2TestApp\InetgrisG2TestApp\Service References\G2ServiceReference\Reference.cs:line 2981
at InetgrisG2TestApp.G2ServiceReference.G2WebServicePortTypeClient.getStudentData(ServiceRequest serviceReq) in c:\Users\s\Documents\Visual Studio 2012\Projects\G2TestApp\G2TestApp\Service References\G2ServiceReference\Reference.cs:line 2987
at InetgrisG2TestApp.Program.Main(String[] args) in c:\Users\s\Documents\Visual Studio 2012\Projects\G2TestApp\G2TestApp\Program.cs:line 57}
This question is related to
c#
wcf
wcf-binding
In WCF serive project this issue may be due to Reference of System.Web.Mvc.dll 's different version or may be any other DLL's different version issue. So this may be compatibility issue of DLL's different version
When I use
System.Web.Mvc.dll version 5.2.2.0 -> it thorows the Error The content type text/html; charset=utf-8 of the response message
but when I use
System.Web.Mvc.dll version 4.0.0.0 or lower -> That's works fine in my project and not have an Error.
I don't know the reason of this different version of DLL's issue but when I change the DLL's verison which is compatible with your WCF Project than it works fine.
This Error even generate when you add reference of other Project in your WCF Project and this reference project has different version of System.Web.Mvc DLL or could be any other DLL.
In my case it was simply an error in the web.config.
I had:
<endpoint address="http://localhost/WebService/WebOnlineService.asmx"
It should have been:
<endpoint address="http://localhost:10593/WebService/WebOnlineService.asmx"
The port number (:10593) was missing from the address.
When I ran into this error, I spent hours trying to find a solution.
My issue was that when I went to save the file I had accidentally hit the key stroke "G" in the web.config. I had a straggler Character just sittings outside, so the web.config did not know how to interpret the improperly formatted data.
Hope this helps.
Just in case...
If you are using SoapUI Mock Service (as the Server), calling it from a C# WCF:
WCF --> SoapUI MockService
And in this case you are getting the same error:
The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8).
Edit your Mock Response at SoapUI and add a Header to it:
In my scenario, this fix the problem.
This could be an error in the web.config file.
Open up your URL in your browser, example:
http://localhost:61277/Email.svc
Check if you have a 500 Error.
HTTP Error 500.19 - Internal Server Error
Look for the error in these sections:
Config Error
Config File
We use the Url Rewrite extension for IIS for redirecting all HTTP requests to HTTPS. When trying to call a service not using transport security on an http://... address, this is the error that appeared.
So it might be worth checking if you can hit both the http and https addresses of the service via a browser and that it doesn't auto forward you with a 303 status code.
Try browse the WCF in IIS see if it's alive and works normally,
In my case it's because the physical path of the WCF is misdirected.
Source: Stackoverflow.com