Streaming web service response as byte array..dtd error. - XML SOAP

This is a discussion on Streaming web service response as byte array..dtd error. - XML SOAP ; Hi, the following calls a webservice and returns the XML as a byte array which I convert to a stream first. The 'xml' variable has XML, however, when I try to load the XML into the XmlDocument, it can't find ...

+ Reply to Thread
Results 1 to 3 of 3

Streaming web service response as byte array..dtd error.

  1. Default Streaming web service response as byte array..dtd error.

    Hi, the following calls a webservice and returns the XML as a byte array
    which I convert to a stream first. The 'xml' variable has XML, however, when
    I try to load the XML into the XmlDocument, it can't find the .dtd file. See
    error below....any ideas what I need to modify? Thanks, Dave.

    System.IO.MemoryStream stm = new
    System.IO.MemoryStream(SomeWebServiceProxyclass.GetDataAsByteArray);

    stm.Position = 0;
    System.IO.StreamReader sr = new System.IO.StreamReader(stm);
    string xml = sr.ReadToEnd();

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.LoadXml(xml); <!---ERROR...

    Message: "Could not find file 'C:\\Program Files\\Microsoft Visual Studio
    8\\Common7\\IDE\\SomeWebServiceProvider.dtd'."



  2. Default Re: Streaming web service response as byte array..dtd error.

    Dave wrote:
    > Hi, the following calls a webservice and returns the XML as a byte array
    > which I convert to a stream first. The 'xml' variable has XML, however, when
    > I try to load the XML into the XmlDocument, it can't find the .dtd file. See
    > error below....any ideas what I need to modify? Thanks, Dave.
    >
    > System.IO.MemoryStream stm = new
    > System.IO.MemoryStream(SomeWebServiceProxyclass.GetDataAsByteArray);
    >
    > stm.Position = 0;
    > System.IO.StreamReader sr = new System.IO.StreamReader(stm);
    > string xml = sr.ReadToEnd();
    >
    > XmlDocument xmlDoc = new XmlDocument();
    > xmlDoc.LoadXml(xml); <!---ERROR...
    >
    > Message: "Could not find file 'C:\\Program Files\\Microsoft Visual Studio
    > 8\\Common7\\IDE\\SomeWebServiceProvider.dtd'."


    The solution depends on whether you want to load the DTD or not. If you
    don't want to load the DTD then you should be able to solve the problem
    simply by setting
    xmlDoc.XmlResolver = null;
    before you call Load or LoadXml.
    Otherwise you need to implement a custom XmlUrlResolver that loads the
    DTD from a location you control.

    Also note that once you have a MemoryStream there is no need to use a
    StreamReader first to get a string, you can simply pass the MemoryStream
    to the Load method of XmlDocument.


    --

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

  3. Default Re: Streaming web service response as byte array..dtd error.

    Thanks!

    "Martin Honnen" wrote:

    > Dave wrote:
    > > Hi, the following calls a webservice and returns the XML as a byte array
    > > which I convert to a stream first. The 'xml' variable has XML, however, when
    > > I try to load the XML into the XmlDocument, it can't find the .dtd file. See
    > > error below....any ideas what I need to modify? Thanks, Dave.
    > >
    > > System.IO.MemoryStream stm = new
    > > System.IO.MemoryStream(SomeWebServiceProxyclass.GetDataAsByteArray);
    > >
    > > stm.Position = 0;
    > > System.IO.StreamReader sr = new System.IO.StreamReader(stm);
    > > string xml = sr.ReadToEnd();
    > >
    > > XmlDocument xmlDoc = new XmlDocument();
    > > xmlDoc.LoadXml(xml); <!---ERROR...
    > >
    > > Message: "Could not find file 'C:\\Program Files\\Microsoft Visual Studio
    > > 8\\Common7\\IDE\\SomeWebServiceProvider.dtd'."

    >
    > The solution depends on whether you want to load the DTD or not. If you
    > don't want to load the DTD then you should be able to solve the problem
    > simply by setting
    > xmlDoc.XmlResolver = null;
    > before you call Load or LoadXml.
    > Otherwise you need to implement a custom XmlUrlResolver that loads the
    > DTD from a location you control.
    >
    > Also note that once you have a MemoryStream there is no need to use a
    > StreamReader first to get a string, you can simply pass the MemoryStream
    > to the Load method of XmlDocument.
    >
    >
    > --
    >
    > Martin Honnen --- MVP XML
    > http://JavaScript.FAQTs.com/
    >


+ Reply to Thread

Similar Threads

  1. Error: "Byte array truncation to a length of 8000"
    By Application Development in forum ADO DAO RDO RDS
    Replies: 1
    Last Post: 10-16-2007, 10:50 AM
  2. How to convert a byte array from ActiveX control to an Array object
    By Application Development in forum Javascript
    Replies: 1
    Last Post: 09-07-2007, 07:20 PM
  3. Streaming a PDF as a byte() from the browser to a webserver using AJAX ?
    By Application Development in forum Adobe Acrobat
    Replies: 0
    Last Post: 12-21-2006, 04:38 PM
  4. Streaming a PDF as a byte() from the browser to a webserver using AJAX ?
    By Application Development in forum Adobe Acrobat
    Replies: 0
    Last Post: 12-20-2006, 04:30 PM
  5. Error calling an EJB method passing a large byte array
    By Application Development in forum Java
    Replies: 2
    Last Post: 06-06-2006, 03:27 AM