Get Details out of Fault-Exception doesn't show full Details

484 Views Asked by At

I have a xml-file of the following format:

<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Body>
    <soap:Fault>
      <soap:Code>
        <soap:Value>soap:Receiver</soap:Value>
      </soap:Code>
      <soap:Reason>
        <soap:Text xml:lang="en">Cannot create order</soap:Text>
      </soap:Reason>
      <soap:Detail>
        <ComplianceViolationInfos xmlns="http://aaim.sungard.com/order/service/v1_0" xmlns:ns10="http://aaim.sungard.com/issuer/schema/v2011_06_01" xmlns:ns2="http://aaim.sungard.com/datatypes/schema/v2011_06_01" xmlns:ns3="http://aaim.sungard.com/order/schema/v2011_06_01" xmlns:ns4="http://aaim.sungard.com/fxorder/schema/v2011_06_01" xmlns:ns5="http://aaim.sungard.com/portfolio/schema/v2011_06_01" xmlns:ns6="http://aaim.sungard.com/transaction/schema/v2011_06_01" xmlns:ns7="http://aaim.sungard.com/compliance/schema/v2011_06_01" xmlns:ns8="http://aaim.sungard.com/user/schema/v2011_06_01" xmlns:ns9="http://aaim.sungard.com/instrument/schema/v2011_06_01">
          <ns7:violationInfo>
            <ns7:RuleType>REQ_OVERRIDE</ns7:RuleType>
            <ns7:RuleName> Name </ns7:RuleName>
            <ns7:Diagnostic> data </ns7:Diagnostic>
          </ns7:violationInfo>
          <ns7:violationInfo>
            <ns7:RuleType> rule </ns7:RuleType>
            <ns7:RuleName> data </ns7:RuleName>
            <ns7:Diagnostic>1. data </ns7:Diagnostic>
          </ns7:violationInfo>
          <ns7:violationInfo>
            <ns7:RuleType>WARNING</ns7:RuleType>
            <ns7:RuleName> name </ns7:RuleName>
            <ns7:Diagnostic> data </ns7:Diagnostic>
          </ns7:violationInfo>
        </ComplianceViolationInfos>
      </soap:Detail>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

In the case of a Fault, I want to access all the data which is in the between the details flag, process it further and later return it to the user. I am working on a .NET Core Application, thus I cannot use SoapExceptions. For achieving this I have a try-catch-blog in my code, which catches a Faultexception:

 try
        {
            //..//
        }
        catch (FaultException e)
        {
            MessageFault messagefault = e.CreateMessageFault();
            var xmlElement = messagefault.GetReaderAtDetailContents();
            string test = xmlElement.ReadContentAsString();
            throw e;
        }

The code above doesn't return the data between the detail-flags. I also allready tried:

string xmlElement = messagefault.GetDetail<XmlElement>().Value

This returned an empty string.

I think the reason is an error in my wcf of that service which I can't figure out. The classes for serializations are:

[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://aaim.sungard.com/compliance/schema/v2011_06_01")]
public partial class ComplianceViolationInfo
{
     private ViolationInfo[] ViolationInfoField;

     [System.Xml.Serialization.XmlArrayAttribute(Order = 0)]
     [System.Xml.Serialization.XmlArrayItemAttribute("violationInfo", IsNullable = false)]
     public ViolationInfo[] ViolationInfo
     {
         get
         {
             return this.ViolationInfoField;
         }
         set
         {
             this.ViolationInfoField = value;
         }
     } 

}

[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://aaim.sungard.com/compliance/schema/v2011_06_01")]
public partial class ViolationInfo
{
    private string ruleTypeField;

    private string ruleNameField;

    private string diagnosticField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Order = 0)]
    public string RuleType
    {
        get
        {
            return this.ruleTypeField;
        }
        set
        {
            this.ruleTypeField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Order = 1)]
    public string RuleName
    {
        get
        {
            return this.ruleNameField;
        }
        set
        {
            this.ruleNameField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Order = 2)]
    public string Diagnostic
    {
        get
        {
            return this.diagnosticField;
        }
        set
        {
            this.diagnosticField = value;
        }
    }
}

It is called like this:

[System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")]
    [System.ServiceModel.FaultContractAttribute(typeof(OrderService.ComplianceViolationInfo), Action="", Name="ComplianceViolationInfos", Namespace="http://aaim.sungard.com/order/service/v1_0")]
    [System.ServiceModel.FaultContractAttribute(typeof(OrderService.FaultInfo), Action = "", Name = "FaultInfo", Namespace = "http://aaim.sungard.com/order/service/v1_0")]
    [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
    System.Threading.Tasks.Task<OrderService.CreateOrderResponse1> CreateOrderAsync(OrderService.CreateOrderRequest request);
0

There are 0 best solutions below