Hi All,
I've just written a small program to use a locally hosted webservice
which works fine.
However I've also written a SOAPExtension for the client and I'm having
trouble with the configuration (getting a ConfigurationException
complaining about a valid type name).
The following is the coded DebugExtension which extends SoapExtension
public class DebugExtension : SoapExtension {
Stream oldStream;
Stream newStream;
public DebugExtension(){}
public override Stream ChainStream(Stream stream){
oldStream = stream;
newStream = new MemoryStream();
return newStream;
}
public override object GetInitializer(Type t){
return null;
}
public override object GetInitializer(LogicalMethodInfo l,
SoapExtensionAttribute sea){
return null;
}
public override void Initialize(object o){
//do nothing
}
public override void ProcessMessage(SoapMessage message) {
// This won't execute if deployed on the service side.
if (message is SoapClientMessage)
{
Display d;
switch (message.Stage)
{
case SoapMessageStage.BeforeSerialize:
break;
case SoapMessageStage.AfterSerialize:
d = new Display();
d.showSOAP(message);
break;
case SoapMessageStage.BeforeDeserialize:
d = new Display();
d.showSOAP(message);
break;
case SoapMessageStage.AfterDeserialize:
break;
default:
throw new Exception("invalid stage");
}
}
}
[AttributeUsage(AttributeTargets.Method)]
public class DebugExtensionAttribute : SoapExtensionAttribute
{
private int priority;
public override Type ExtensionType
{
get { return typeof(DebugExtension); }
}
public override int Priority
{
get { return priority; }
set { priority = value; }
}
}
}
I have the following app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="microsoft.web.services2"
type="Microsoft.Web.Services2.Configuration.WebSer vicesConfiguration,
Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
</configSections>
<microsoft.web.services2>
<diagnostics />
</microsoft.web.services2>
<system.web>
<webServices>
<soapExtensionTypes>
<add type="DebugExtension"
priority="1"
group="0" />
</soapExtensionTypes>
</webServices>
</system.web>
</configuration>
When running the program I get the following error:
"An unhandled exception of type
'System.Configuration.ConfigurationException' occurred in system.dll
Additional information: The 'type' attribute must be set to a valid
type name."
However commenting out the System.web node and all it's children
elimnates the error (the extension doesn't run of course). I've also
tried adding a type of type="Debug.DebugExtension" were Debug is the
namespace in which the entire project resides.
Any input appreciated,
Cameron