Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > How to get the "raw" XML document returned from a web service

Reply
Thread Tools

How to get the "raw" XML document returned from a web service

 
 
Dan Rogers
Guest
Posts: n/a
 
      03-08-2005
It won't give him the SOAP request or the HTTP headers - but it's close.
--------------------
>Message-ID: <(E-Mail Removed)>
>From: Trevor Pinkney <(E-Mail Removed)>
>Subject: Re: How to get the "raw" XML document returned from a web service
>References: <(E-Mail Removed)>
>Content-Type: text/plain; charset=iso-8859-1; format=flowed
>X-Newsreader: JetBrains Omea Reader 439.21
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
>Date: Mon, 21 Feb 2005 11:20:40 -0800
>NNTP-Posting-Host: z-f5-0-0-229-s1.gw1.tor1.sprint-canada.net

206.186.91.250
>Lines: 1
>Path:

TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSF TNGP08.phx.gbl!TK2MSFTNGP1
4.phx.gbl
>Xref: TK2MSFTNGXA02.phx.gbl

microsoft.public.dotnet.framework.aspnet.webservic es:28225
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
>
>This should do what you want.
>
> /// <summary>
> /// Converts an object to its xml representation
> /// </summary>
> public static string ObjectToXml(object objectToConvert)
> {
> MemoryStream memStream = new MemoryStream();
> XmlSerializer serializer = new XmlSerializer(objectToConvert.GetType());
> serializer.Serialize(memStream, objectToConvert);
> StreamReader reader = new StreamReader(memStream);
> memStream.Position = 0;
> return reader.ReadToEnd();
> }
>
>-Trevor
>
>
>
>Hello MikeL,
>
>> Hi, Keenan. Thanks for the response.
>>
>> The problem is on the consumer of the web service. They want the XML
>> document.
>>
>> I don't want to write another WebMethod just for this. I'd like to
>> know how to serialize the returned data to an XML doc. The following
>> code will do it and save it to disk, but ultimately I want not to
>> write it to disk, but rather store it in a "string" variable:
>>
>> System.Xml.Serialization.XmlSerializer s
>> = new
>> System.Xml.Serialization.XmlSerializer(typeof(seRe sults),https://www.s
>> omedomain.com/RatingHub);
>>
>> Stream fs = new
>> FileStream("D:\\stream.txt", FileMode.Truncate );
>>
>> XmlWriter writer = new XmlTextWriter(fs,
>> new UTF8Encoding());
>>
>> s.Serialize(writer, results);
>>
>> Any thoughts?
>>
>> Thanks again,
>>
>> Mike
>>
>> "Keenan Newton" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed) oups.com...
>>
>>> Mike you should be able to pass the XmlElement object without a
>>> problem.
>>>
>>> [WebMethod]
>>> public System.Xml.XmlElement MyMethod()
>>> {
>>> //some code to get XmlElement
>>> return myXmlElement; //System.Xml.XmlElement
>>> }

>


>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Using document.load() to get html NOT xml document icogs Javascript 0 01-31-2008 04:02 AM
InvocationTargetException when calling "new Service()" in Axis web service to call another web service Michael Averstegge Java 0 01-10-2006 11:05 PM
Refer to an XML document from within an XML document Manish Hatwalne XML 1 07-13-2004 10:24 AM
Help on including one XML document within another XML document using XML Schemas Tony Prichard XML 0 12-12-2003 03:18 PM



Advertisments