-
Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'
Dear All,
I am getting this error when I call a WebService
An unhandled exception of type 'System.Exception' occurred in system.web.services.dll
Additional information: Client found response content type of 'text/html;
charset=utf-8', but expected 'text/xml'.
The request failed with the error message:
--
<html>
<head>
<title>WriteStartDocument had the XML declaration written.</title>
<style>
I am throwing an exception from my WebMethod where I am creating a XmlNode
Array from a XmlDocument and passing it to the SoapException
[WebMethod]
[SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Bare)]
public void ExportObject2Exp()
{
ClassA myExp = new ClassA();
myExp.setValues("Sunil Menon", 27, "M");
XmlSerializer serializer = new XmlSerializer(typeof(ClassA));
// Serialize the purchase order, and close the TextWriter.
Stream xyz = new MemoryStream();
serializer.Serialize(xyz, myExp);
TextReader reader = new StreamReader(xyz);
XmlDocument doc = new XmlDocument();
xyz.Seek(0, SeekOrigin.Begin);
//Create a reader.
XmlNode[] arrNode = new XmlNode[2];
int nCnt = 0;
XmlTextReader xmreader = new XmlTextReader(reader);
while (xmreader.Read())
{
arrNode[nCnt]= doc.ReadNode(xmreader);
nCnt++;
}
SoapException se = new SoapException("Fault occurred",SoapException.ClientFaultCode,
Context.Request.Url.AbsoluteUri,node,arrNode );
throw se;
}
Does anyone know why?
Thanks a lot in advance
Many Regards
Sunil
-
Re: Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'
Sunil,
"Sunil Menon" <sunil@itb-india.com> wrote:
>
>Dear All,
> I am getting this error when I call a WebService
>
> An unhandled exception of type 'System.Exception' occurred in system.web.services.dll
>Additional information: Client found response content type of 'text/html;
>charset=utf-8', but expected 'text/xml'.
I've gotten that message a lot when I've tried to create my own SoapFaults
and write them to the Response without correctly setting the response.ContentType
to "text/xml".
However, you shouldn't have to worry about this since the runtime should
be generating your SoapFault for you when you throw the SoapException.
Perhaps your use of the SoapDocumentMethod is screwing up the response. Other
than that I don't really have any clue.
Michael
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks