I have a C# Winforms client that called a Java web service. The service gets invoked correctly and returns the expected results.
I've been trying until I'm blue in the face to add a Soap Extension. It compiles correctly, I have every reason to believe it's getting registered ... but it never gets called. I tried modifying app.config; I tried calling "wss.SoapExtensionTypes.Add(soapInterceptor)": same thing. My SoapException's "Initalize()" and "ProcessMessage()" functions are simply never getting called.
Q: Any suggestions? Any debugging tips?
ClientTraceExtension.cs =>
using System;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Services.Configuration;
using System.IO;
using System.Net;
using System.Reflection;
using System.Security.Permissions;
using GITSearchClient.ServiceReference1;
/*
* REFERENCE:
* http://msdn.microsoft.com/en-US/library/system.web.services.protocols.soapextension%28v=vs.90%29.aspx
*/
namespace GITSearchClient
{
public class ClientTraceExtension : SoapExtension
{
private Stream oldStream;
private Stream newStream;
private string filename = "c:\\temp\\soap_result.txt";
// Custom SoapExtension must override: ChainStream, GetInitializer()x2, Initialize() and ProcessMessage()
public override Stream ChainStream(Stream stream)
{
oldStream = stream;
newStream = new MemoryStream();
return newStream;
}
public override object GetInitializer(Type WebServiceType)
{
// filename = "C:\\temp\\soap_" + WebServiceType.FullName + ".txt";
//return filename;
return null;
}
public override object GetInitializer(LogicalMethodInfo methodInfo, SoapExtensionAttribute attribute)
{
//return filename;
return null;
}
public override void Initialize(object initializer)
{
// filename = (string)initializer;
}
public override void ProcessMessage(SoapMessage message)
{
//int i = 0;
//int j = 1 / i; // DEBUG: Stop here
switch (message.Stage)
{
case SoapMessageStage.BeforeSerialize:
break;
case SoapMessageStage.AfterSerialize:
WriteOutput(message);
break;
case SoapMessageStage.BeforeDeserialize:
WriteInput(message);
break;
case SoapMessageStage.AfterDeserialize:
break;
}
}
...
app.config =>
<?xml version="1.0"?>
<configuration>
<system.web>
<webServices>
<soapExtensionTypes>
<add
type="GITSearchClient.ClientTraceExtension, GITSearchClient"
priority="1"
group="0"/>
</soapExtensionTypes>
</webServices>
</system.web>
<startup>
<supportedRuntime version="v2.0.50727" sku="Client"/>
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
...
Form1.cs =>
try
{
GitSearchServiceSoapClient webService = new GitSearchServiceSoapClient();
RequestOptions requestOptions = new RequestOptions();
resp = webService.GetOosData(requestOptions, edtGroupId2.Text, "2012");
...
I think you are mixing old and new here, i.e ASMX web services with WCF, see this question for a similar issue. Look at the answers by John.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With