Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello,

I have created a RESTful WCF service. it contain two SVC files. one is located in some folder and other is located outside of the folder with different interfaces and classes.

when i refered a inside folder service method, i am getting below error

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

But outside folder service working fine..what is the difference of those.

Please help me.

Thanks in advance.
Posted

1 solution

The configuration mismatch can be the primary reason here. Please check that the client and server bindings are same in configuration file of service and client.

Regards
Pawan
 
Share this answer
 
Comments
Ramya singam 20-Feb-13 4:36am    
what bindings we have to set for client. i have given bindings only in service web.config file and hosted that service in IIS. i did not set any bindings in client.

Regards,
Ramya.
Rai Pawan 20-Feb-13 6:05am    
how are you using WCF service in your client application? Did you use svcutil to create proxy class along with a config file?
- Pawan
Ramya singam 21-Feb-13 5:40am    
no..I have used the web service like

string url = "http://localhost:9716/PersonService.svc/DeleteRole";
req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/xml; charset=utf-8";
req.Timeout = 30000;
req.Headers.Add("SOAPAction", url);
req.Accept = "application/xml";
var xmlDoc = new XmlDocument { XmlResolver = null };
xmlDoc.Load(Server.MapPath("AssignRole.xml"));
string sXml = xmlDoc.InnerXml;
req.ContentLength = sXml.Length;
var sw = new StreamWriter(req.GetRequestStream());
sw.Write(sXml);
sw.Close();

res = (HttpWebResponse)req.GetResponse();
Stream responseStream = res.GetResponseStream();
var streamReader = new StreamReader(responseStream);

//Read the response into an xml document
var soapResonseXmlDocument = new XmlDocument();
soapResonseXmlDocument.LoadXml(streamReader.ReadToEnd());
lblMessage.Text = soapResonseXmlDocument.InnerXml;
Rai Pawan 21-Feb-13 23:19pm    
please also share the bindings used, for configuring the endpoint on the service itself.
- Pawan

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900