I have problems with the configuration of a SoapExtension (not with the implementation). First of all, I've already read all these posts (among others), related in some way with SoapExtensions:
- Intercept SOAP messages from and to a web service at the client
- https://www.codeproject.com/Articles/34381/Efficient-Tracing-Using-SOAP-Extensions-in-NET
- https://social.msdn.microsoft.com/Forums/en-US/d8d6fe09-74be-4210-91bb-a8924a742e8c/how-to-log-soap-message-which-is-going-out-of-my-web-application?forum=ncl
- http://www.seanmcilvenna.com/2010/08/20/logging-full-soap-messages/
- How to create a web.config file to get SoapExtension loading?
- Intercept messages in a WCF Client
- https://msdn.microsoft.com/en-us/library/esw638yk(VS.85).aspx
- https://social.msdn.microsoft.com/Forums/en-US/1ba267b8-c08d-4c30-a1e1-792bac92fc87/soapextension-does-not-work-in-client-side?forum=netfxnetcom
- SoapExtension not loading
The scenario is as follow:
I'm consumming a 3rd party WS(SOAP) from a Library (dll) project: connectors.dll
In this project i've a web-reference to the 3rd party WS(SOAP). I generated the proxy with VS (adding a web-reference, and pointing to the wsdl).
In the other hand , I've a web-application (indeed is a REST-service), with a reference to a class (we could call it Connector-A) of connectors.dll
(until here, I call a rest service, over my REST-Service webapp, call the connector-A and this do a last call to proxy service of the 3rdParty. I receive a response, but it has an invalid character (0x1F at position 1), and this is why I'm trying to use SoapExtension -> to delete it before deserialization take place)
- I implement the SoapExtension (XmlCleanupSoapExtension.cs) as a separate library Backend.SoapExentensions ( based on this: https://blogs.technet.microsoft.com/stefan_gossner/2009/08/26/how-to-deal-with-invalid-characters-in-soap-responses-from-asp-net-web-services/)
The last step, to configure: * add a reference (VS->Add Reference) in my REST-Service (webapp) to Backend.SoapExtnsions.dll and
- register the soapExtension in web.config :
`
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxUrlLength="4000" />
<authentication mode="None" />
<webServices>
<soapExtensionTypes>
<add type="Backend.SoapExtensions.XmlCleanupSoapExtension, Backend.SoapExtensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=66269ab3fc862c8f" priority="1" group="0" />
</soapExtensionTypes>
</webServices>
<globalization uiCulture="auto:es" culture="auto:es-ES" enableClientBasedCulture="true" />
</system.web>
`
When I call a rest-service that, at the end,it calls the WS-Soap i'm getting now a runtime exception, which makes me crazy:
The value of the property 'type' cannot be parsed. The error is: Could not load type 'Offidesk.Backend.SoapExtensions.XmlCleanupSoapExtension' from assembly 'Offidesk.Backend.SoapExtensions'.
I think I've tried all possible combinations for this line:
<add type="Backend.SoapExtensions.XmlCleanupSoapExtension, Backend.SoapExtensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=66269ab3fc862c8f" priority="1" group="0" />
- with and without assembly name
- with and without namespace
- with and without Version, Culture and PublicToken
- Group="0" and Group="High"
Actually, I'm completely frustated with this runtime exception. I though that perhaps the position of block inside could affect, but all my tries get the same exception...
Any idea??
thanks in advance.
Note: I also tried other tecniques to clean the server-response overriding the SoapHttpClientProtocol (in a extended class) method: GetReaderForMessage but don't work for me neither (don't know why).
EDIT
Finally the problem with the invalid character 0x1F was not such. I didn't realize that the response was coming compressed with gzip, and the proxy-client tried to parse a compressed response as XML, which obviously, was rising an exception at runtime.
However, I'm very insterested yet in knowing the reason why my web.config, with the soap extension, don't work (sooner or later we would need this configuration....so it's better to prevent).