Has anyone got any experience with Web Service Extensions? Been a late day and have spent the past few hours scratching my head trying to make a web service extension from the MS examples.
I have an .net 3.5 web service client, built by adding a reference to the wsdl, via the VS IDE "Project > Add Service Reference". This built my web service client, and all works ok.
I need to intercept the request and response body for my web service client. I have found lots of references to Web Service Extensions, but am having an attack of the tired, and just cant get my extensions to fire.
I've used the MS example from here "How to implement a SOAP extension" ( h ttp://msdn.microsoft.com/en-us/library/7w06t139.aspx) , which builds a logger for the request / response streams.
The related MS article "Soap Message Modification" (http://msdn.microsoft.com/en-us/library/esw638yk(VS.85).aspx) shows how to enable the SOAP extension for the web client:
Implementing the SOAP Extension
There are two ways to run a SOAP extension on either a client or server application. First, you can configure the application to run the extension. To configure your SOAP extension to run for all Web methods on all Web services, especially a vroot, edit the Element section within the Web.config file. The following code shows that the type attribute value must be on one line and include the fully qualified name of the extension, plus the version, culture, and public key token of the signed assembly.
<configuration>
<system.web>
<webServices>
<soapExtensionTypes>
<add type="Contoso.MySoapExtension, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="1" group="0"/>
</soapExtensionTypes>
</webServices>
</system.web>
</configuration>
I've compiled the traceextension into it's own class library, and referenced it in the web.config of the web service project like so:
<add type="TraceExtension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ef8757fac167b8d8" priority="1" group="High"/>
No joy. Nothing is logged, no breakpoints are hit.
I then removed the referenced class, and dropped the source code into the web service project.
I tried to add a reference to it like so (my namespace is ServcieTest001):
<add type="ServiceTest001.TraceExtension" group="High" priority="1" />
I used the following thread as a guide as to enabling me extension "getting-raw-soap-data-from-a-web-reference-client-running-in-asp-net" (h ttp://stackoverflow.com/questions/300674/getting-raw-soap-data-from-a-web-reference-client-running-in-asp-net).
Still no joy. I then copied the code from the above thread, and still cannot get the extension to fire when I make a SOAP request.
Can anyone help with some pointers? I must be missing something really silly! Can anyone point me to a functioning downloadable web service extension demo project, so I can disassemble it and work out what I'm missing?