J
JTrigger
I have created a soap extension to globally handle errors in my webservice.
For some reason the extension is not executing. What is wrong?
Here is my web.config entry to wire the extension to the service:
<webServices>
<soapExtensionTypes>
<add type="EDS.RemedyServices.SoapExtensions.ErrorExtension,
RemedywebService" priority="1" group="0"/>
</soapExtensionTypes>
</webServices>
Here is my code:
using System;
using System.Web.Services.Protocols;
using System.Diagnostics;
using System.Configuration;
using System.IO;
using EDS.RemedyServices;
namespace EDS.RemedyServices.SoapExtensions
{
[AttributeUsage(AttributeTargets.Method)]
public class ErrorExtensionAttribute : SoapExtensionAttribute
{
private int priority;
public override Type ExtensionType
{
get { return typeof(ErrorExtension); }
}
// User can set priority of the 'SoapExtension'.
public override int Priority
{
get
{
return priority;
}
set
{
priority = value;
}
}
}
public class ErrorExtension : SoapExtension
{
public override object GetInitializer(LogicalMethodInfo methodInfo,
SoapExtensionAttribute attribute)
{
return null;
}
public override object GetInitializer(Type WebServiceType)
{
return null;
}
public override void Initialize(object initializer)
{
}
public override void ProcessMessage(SoapMessage message)
{
if (message.Stage == SoapMessageStage.AfterSerialize)
{
if (message.Exception != null)
{
WriteOutput( message );
}
}
}
public void WriteOutput( SoapMessage message )
{
#region process error
try
{
System.Exception SoapError = message.Exception;
EDS.RemedyServices.ErrorHandler.ProcessError(SoapError);
}
catch(Exception e)
{
throw(e);
}
#endregion
}
}
}
For some reason the extension is not executing. What is wrong?
Here is my web.config entry to wire the extension to the service:
<webServices>
<soapExtensionTypes>
<add type="EDS.RemedyServices.SoapExtensions.ErrorExtension,
RemedywebService" priority="1" group="0"/>
</soapExtensionTypes>
</webServices>
Here is my code:
using System;
using System.Web.Services.Protocols;
using System.Diagnostics;
using System.Configuration;
using System.IO;
using EDS.RemedyServices;
namespace EDS.RemedyServices.SoapExtensions
{
[AttributeUsage(AttributeTargets.Method)]
public class ErrorExtensionAttribute : SoapExtensionAttribute
{
private int priority;
public override Type ExtensionType
{
get { return typeof(ErrorExtension); }
}
// User can set priority of the 'SoapExtension'.
public override int Priority
{
get
{
return priority;
}
set
{
priority = value;
}
}
}
public class ErrorExtension : SoapExtension
{
public override object GetInitializer(LogicalMethodInfo methodInfo,
SoapExtensionAttribute attribute)
{
return null;
}
public override object GetInitializer(Type WebServiceType)
{
return null;
}
public override void Initialize(object initializer)
{
}
public override void ProcessMessage(SoapMessage message)
{
if (message.Stage == SoapMessageStage.AfterSerialize)
{
if (message.Exception != null)
{
WriteOutput( message );
}
}
}
public void WriteOutput( SoapMessage message )
{
#region process error
try
{
System.Exception SoapError = message.Exception;
EDS.RemedyServices.ErrorHandler.ProcessError(SoapError);
}
catch(Exception e)
{
throw(e);
}
#endregion
}
}
}