[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webservices

How to log soap messages on client

(Andreas Falck)

12/26/2002 3:35:00 AM

I'm writing a web service client in c#.net. I have interoperability
issues accessing a web service running on Apache.

I would like to log all soap messages on my client. There are examples
on how to do this on the server using
System.Web.Services.Protocols.SoapExtension and
System.Web.Services.Protocols.SoapExtensionAttribute.

Is it possible to log soap messages on the client in the same or other
ways?

Andreas
--
4 Answers

Simon Trew

12/10/2002 5:23:00 PM

0

Yes, you can use the same extension on the client-- just mark the proxy
methods with those attributes. Unfortunately this has to be done in the
auto-generated code so if you regenerate you will lose it.

Alternatively use a tool such as TCPTrace which just traces all TCP traffic.
You redirect your service to its port (by setting the service's Url
property) and then it posts it onwards to the real server, after logging it.
Get it here: http://www.pocketsoap.com...



"Andreas Falck" <andreas1234567@hotmail.com> wrote in message
news:87a3ba8f.0212060358.525b6a2a@posting.google.com...
> I'm writing a web service client in c#.net. I have interoperability
> issues accessing a web service running on Apache.
>
> I would like to log all soap messages on my client. There are examples
> on how to do this on the server using
> System.Web.Services.Protocols.SoapExtension and
> System.Web.Services.Protocols.SoapExtensionAttribute.
>
> Is it possible to log soap messages on the client in the same or other
> ways?
>
> Andreas
> --


(Andreas Falck)

12/26/2002 3:36:00 AM

0

"Simon Trew" <strew@orange.net> wrote in message news:<#Fee2hGoCHA.2448@TK2MSFTNGP12>...
> Yes, you can use the same extension on the client-- just mark the proxy
> methods with those attributes. Unfortunately this has to be done in the
> auto-generated code so if you regenerate you will lose it.
>
> Alternatively use a tool such as TCPTrace which just traces all TCP traffic.
> You redirect your service to its port (by setting the service's Url
> property) and then it posts it onwards to the real server, after logging it.
> Get it here: http://www.pocketsoap.com...

Thanks for your reply Simon,

I've now used tcptrace, and I find it very powerful and useful.

However, I'm writing a web service consumer accessing a web service
that is only allows SSL traffic. I therefore have to look into your
first alternative. I'm stuck trying to figure out how to implement
soap extensions on my client (== web service consumer).

I have added a SoapLogger class, and I apply the [SoapLogger]
attribute to the method Whose messages I want to log. Should not this
suffice?

[System.Web.Services.Protocols.SoapRpcMethodAttribute("",
RequestNamespace="urn:myService", ResponseNamespace="urn:myService")]
[return: System.Xml.Serialization.SoapElementAttribute("myMethodReturn")]
[SoapLogger]
public string myMethod(string myVal)
{
object[] results = this.Invoke("myMethod", new object[] {
myVal});
return ((string)(results[0]));
}

The error stack:

Exception caught:
System.InvalidCastException: Specified cast is not valid.
at System.Web.Services.Protocols.SoapReflectedExtension.GetInitializer(LogicalMethodInfo
methodInfo)
at System.Web.Services.Protocols.SoapReflectedExtension.GetInitializers(LogicalMethodInfo
methodInfo, SoapReflectedExtension[] extensions)
at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
at SecureServerService..ctor() in c:\temp\visual studio
projects\client\serverproxy.cs:line 29
at TelenorClient6.Form1.bntInvoke_Click(Object sender, EventArgs e)
in c:\temp\visual studio projects\telenorclient6\form1.cs:line 187


The SoapLogger/SoapLoggerAttribute classes:

// File: SoapLogger.cs

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

public class SoapLogger : SoapExtension
{
public void log(string text)
{
FileStream fs = new
FileStream("c:\\winnt\\temp\\soaplog.txt", FileMode.Create,
FileAccess.Write);
StreamWriter w = new StreamWriter(fs);
w.WriteLine(text);
w.Flush();
w.Close();
}

public override void Initialize(object o)
{
log("Initialize");
}
public override object GetInitializer(LogicalMethodInfo m,
SoapExtensionAttribute a)
{
log("GetInitializer 1");
return null;
}
public override object GetInitializer(Type s)
{
log("GetInitializer 2");
return null;
}
public override void ProcessMessage(SoapMessage m)
{
log("ProcessMessage " + m.Stage);
}
}

[AttributeUsage(AttributeTargets.Method)]
public class SoapLoggerAttribute : SoapExtensionAttribute
{
private string filename = "c:\\winnt\\temp\\soaplog.txt";
private int priority = 0;

public override Type ExtensionType
{
get { return typeof(SoapLoggerAttribute); }
}

public override int Priority
{
get { return priority; }
set { priority = value; }
}

public string Filename
{
get { return filename; }
set { filename = value; }
}
}


Any suggestions?


Andreas
--

(Andreas Falck)

12/26/2002 3:37:00 AM

0

andreas1234567@hotmail.com (Andreas Falck) wrote in message news:<87a3ba8f.0212110716.7c6736c2@posting.google.com>...
> "Simon Trew" <strew@orange.net> wrote in message news:<#Fee2hGoCHA.2448@TK2MSFTNGP12>...

> However, I'm writing a web service consumer accessing a web service
> that is only allows SSL traffic. I therefore have to look into your
> first alternative. I'm stuck trying to figure out how to implement
> soap extensions on my client (== web service consumer).

I found a detailed yet simple explanation on soap logging here:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=edO3S%24xACHA.1820%40tkmsftngp02&rnum=15&prev=/groups%3Fq%3DSoapExtension%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26start%3D1...


Andreas
--

(Roman Kiss)

12/26/2002 3:37:00 AM

0

have a look at my article and c# implementation of the SOAP Probe:

http://www.codeproject.com/cs/webservices/WebServic...

Roman








andreas1234567@hotmail.com (Andreas Falck) wrote in message news:<87a3ba8f.0212120058.2ec575e@posting.google.com>...
> andreas1234567@hotmail.com (Andreas Falck) wrote in message news:<87a3ba8f.0212110716.7c6736c2@posting.google.com>...
> > "Simon Trew" <strew@orange.net> wrote in message news:<#Fee2hGoCHA.2448@TK2MSFTNGP12>...
>
> > However, I'm writing a web service consumer accessing a web service
> > that is only allows SSL traffic. I therefore have to look into your
> > first alternative. I'm stuck trying to figure out how to implement
> > soap extensions on my client (== web service consumer).
>
> I found a detailed yet simple explanation on soap logging here:
>
> http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=edO3S%24xACHA.1820%40tkmsftngp02&rnum=15&prev=/groups%3Fq%3DSoapExtension%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26start%3D1...
>
>
> Andreas
> --