Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / October 2006

Tip: Looking for answers? Try searching our database.

Soap Fault in Policy Assertion

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Erikst - 16 Jun 2006 09:48 GMT
I'm building a custom policy assertion, that I want to use to evaluate my
soap message and return a soap fault if there is something wrong. But how do
I return a soap fault from a SoapFilter ProcessMessage method? I tried
throwing a Exception, but that crashes my host application. I also tried
changing SoapFilterResult.Continue to SoapFilterResult.Terminate, but that is
also no solution, because it just terminates, nothing else.
Can anyone help me with this?
Erikst - 16 Jun 2006 14:58 GMT
Okay, I’ve been testing some solutions today and I came up with something
that works, but it is very ugly.

Turns out that when I set the soap.Fault in the output channel filter it
will send the fault to the client. So if I want to have a input channel that
tests my message and sends a soap fault back to the client, I need to save
the exception in the Context.OperationState of the message and catch that in
the outputchannel to put it in the soapmessage. But now the requested service
still gets executed. So I have to create a bogus service that does nothing
and redirect my inputchannel to that service by creating an instance of
SoapFilterResult and setting the TargetMethod to my bogus service (and
returning that as the ProcessMessage result.

Inputchannel filter code:
public override SoapFilterResult ProcessMessage(SoapEnvelope envelope)
{
    Exception e = new Exception("This is the exception i want to throw");
    envelope.Context.OperationState.Set<Exception>(e);
   
    Type s = typeof(ISRA.Services.BogusService);
    SoapServerMethod method = new SoapServerMethod(s, new
LogicalMethodInfo(s.GetMethod("BogusExecute")));
    SoapFilterResult res = new SoapFilterResult(method);
    return res;
}

outputchannel filter code:
public override SoapFilterResult ProcessMessage(SoapEnvelope envelope)
{
    Exception e = envelope.Context.OperationState.Get<Exception>();
    if (e != null)
    {
        envelope.Fault = e;
    }
    return SoapFilterResult.Continue;
}

Is there someone with a better idea?

Thanks in advance,
Erik

> I'm building a custom policy assertion, that I want to use to evaluate my
> soap message and return a soap fault if there is something wrong. But how do
[quoted text clipped - 3 lines]
> also no solution, because it just terminates, nothing else.
> Can anyone help me with this?
Pablo Cibraro - 16 Jun 2006 22:44 GMT
Hi Erik,

What happens if you interrup the service execution returning a
SoapFilterResult.Stop instead of executing a bogus service.
The logic will remain almost equal but you can eliminate the bogus service.

Regards,
Pablo Cibraro.

> Okay, I've been testing some solutions today and I came up with something
> that works, but it is very ugly.
[quoted text clipped - 50 lines]
>> also no solution, because it just terminates, nothing else.
>> Can anyone help me with this?
Erikst - 19 Jun 2006 08:09 GMT
Pablo,

Using SoapFilterResult.Stop is not possible because that is a boolean and I
have to return a SoapFilterResult. Maybe you were thinking of
SoapFilterResult.Terminate? This also doesn’t work, because
SoapFilterResult.Terminate doesn’t have any effect on a input pipeline, only
on an output pipeline.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wse3.0_mref/htm
l/T_Microsoft_Web_Services3_SoapFilterResult.asp
:
“The behavior of the pipeline and its interpretation of the SoapFilterResult
returned from ProcessMessage depends on whether the Soap filter is an input
filter, or an output filter. In the case of an input filter that processes
incoming messages, if the ProcessMessage returns Continue processing will
continue to the next filter in the pipeline. However, if this filter returns
a SoapFilterResult containing a user defined SoapServerMethod then processing
of the pipeline will be transferred to this user defined method, and then
terminated.
If a Soap filter is an output filter that processes outgoing messages and
ProcessMessage returns Terminate, processing will stop, and the next filter
in the pipeline will not be executed.”

If I’m reading this right, it suggests that there is no way to interrupt an
input pipeline and/or create an output pipeline without running a service.

Maybe some other suggestions, everything is welcome?

Thanks in advance,
Erik Steinebach

> Hi Erik,
>
[quoted text clipped - 59 lines]
> >> also no solution, because it just terminates, nothing else.
> >> Can anyone help me with this?
Bob Burger - 31 Oct 2006 20:49 GMT
> I'm building a custom policy assertion, that I want to use to evaluate my
> soap message and return a soap fault if there is something wrong. But how do
[quoted text clipped - 3 lines]
> also no solution, because it just terminates, nothing else.
> Can anyone help me with this?

Tried your method to interrupt the SOAP chain and bypass the original web service and it worked fine.  Thanks much!  Have you had any further thoughts on this?

Posted from http://www.topxml.com/renntp using reNNTP: the website based NNTP reader.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.