Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'

  1. #1
    Sunil Menon Guest

    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

  2. #2
    Michael Welch Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center