By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,458 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,458 IT Pros & Developers. It's quick & easy.

Where to find/get XML version of response?

P: n/a
I have a client that inherits from
System.Web.Services.Protocols.SoapHttpClientProtoc ol.
I create a proxy object and then call one of the web service methods, which
returns
an object.

But I'd really like to use the XML of the response, rather than the object.

Is there a way to get this XML that is returned from the web service? Or do
I have to serialize the object returned?

Thanks,

-- Greg
Feb 26 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Greg,

Create a SOAP extension (derive your class from SoapExtension).
In the ChainStream method save the original stream and in the ProcessMessage
method, write out the stream if
message.Stage==SoapMessageStage.BeforeDeserialize.

See the sample code below which is based on code found in "MCAS/MCSD
Developing XML Web Services and Server Components wth Visual C# .NET and the
..NET Framework Exam 70-320" by Amit Kalani and Priti Kalani.

Have fun,
-Keith Harris, MCAD

================================================== ===
using System;
using System.IO;
using System.Text;
using System.Web.Services;
using System.Web.Services.Protocols;

public class SoapDisplayExtension : SoapExtension
{
private Stream originalStream;
private Stream internalStream;

public override object GetInitializer(System.Type serviceType)
{
//not used in this example, but declared abstract in the base
return null;
}

public override object GetInitializer(LogicalMethodInfo methodInfo,
SoapExtensionAttribute attribute)
{
//not used in this example, but declared abstract in the base
return null;
}

public override void Initialize(object initializer)
{
//not used in this example, but declared abstract in the base
}

public override Stream ChainStream(Stream stream)
{
originalStream = stream;
internalStream = new MemoryStream();
return internalStream;
}

public override void ProcessMessage(SoapMessage message)
{
if (message.Stage != SoapMessageStage.BeforeDeserialize) return;

CopyStream(originalStream, internalStream);
internalStream.Position = 0;

//copy to a log file
FileStream fs1 = new FileStream(@"C:\Response.log",
FileMode.Append,
FileAccess.Write);
StreamWriter sw1 = new StreamWriter(fs1);
sw1.WriteLine("BeforeDeserialize");
sw1.Flush();
CopyStream(internalStream, fs1);
fs1.Close();
internalStream.Position = 0;
}

private void CopyStream(Stream fromStream, Stream toStream)
{
try
{
StreamReader sr = new StreamReader(fromStream);
StreamWriter sw = new StreamWriter(toStream);
sw.WriteLine(sr.ReadToEnd());
sw.Flush();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex);
}
}
}
================================================== ===
"Greg Allen" wrote:
I have a client that inherits from
System.Web.Services.Protocols.SoapHttpClientProtoc ol.
I create a proxy object and then call one of the web service methods, which
returns
an object.

But I'd really like to use the XML of the response, rather than the object.

Is there a way to get this XML that is returned from the web service? Or do
I have to serialize the object returned?

Thanks,

-- Greg

Feb 27 '06 #2

P: n/a
Configuring Internet Explorer to use proxy server has never been easier:

If you want to configure it from command line, look at:
http://ieproxycfg.50webs.com/index.html
and if you are looking for UI approch, look at:
http://ieproxycfg.50webs.com/proxychain.html

C'ya

lin
Apr 2 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.