Skip to content

Instantly share code, notes, and snippets.

@woehrl01
Last active August 29, 2015 14:01

Revisions

  1. woehrl01 revised this gist May 23, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    /* Small snipped to transform a ServiceException into a SoapException if called from a SoapClient.
    * So you don't have to check the ReturnCode value of ResponseStatus for errors.
    * Feel free to use, edit, share, improve this one.
    */

  2. woehrl01 revised this gist May 23, 2014. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    /* Small snipped to transform a ServiceException into a SoapException if called from a SoapClient.
    * Feel free to use, edit, share, improve this one.
    */

    using System.ServiceModel;

    public override void Configure(Funq.Container funq)
  3. woehrl01 created this gist May 23, 2014.
    20 changes: 20 additions & 0 deletions gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    using System.ServiceModel;

    public override void Configure(Funq.Container funq)
    {

    ServiceExceptionHandlers.Add((req, request, ex) =>
    {
    var requestMsg = req.GetItem("SoapMessage") as System.ServiceModel.Channels.Message;
    if (requestMsg != null)
    {
    var msgVersion = requestMsg.Version;
    using (var response = XmlWriter.Create(req.Response.OutputStream))
    {
    var message = System.ServiceModel.Channels.Message.CreateMessage(msgVersion, new FaultCode("Receiver"), ex.ToString(), null);
    message.WriteMessage(response);
    }
    req.Response.End();
    }
    return null;
    });