Java Webservice没有提供FaultException(C#)

时间:2016-12-21 09:48:25

标签: c# wsdl faultexception

老实说,我不知道为什么我没有得到" InnerException"或者更确切地说是DetailMessage我们的一个FaultException,我不知道为什么。错误确实出现在XML-Response中,但无论出于何种原因,当我访问异常时它都不可用。

ServiceFault级:

public partial class ServiceFault : object, System.ComponentModel.INotifyPropertyChanged {

    private string causeMessageField;

    private int errorCodeField;

    private bool errorCodeFieldSpecified;

    private MessageEvent[] listField;

    private string messageField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
    public string causeMessage {
        get {
            return this.causeMessageField;
        }
        set {
            this.causeMessageField = value;
            this.RaisePropertyChanged("causeMessage");
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)]
    public int errorCode {
        get {
            return this.errorCodeField;
        }
        set {
            this.errorCodeField = value;
            this.RaisePropertyChanged("errorCode");
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public bool errorCodeSpecified {
        get {
            return this.errorCodeFieldSpecified;
        }
        set {
            this.errorCodeFieldSpecified = value;
            this.RaisePropertyChanged("errorCodeSpecified");
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=2)]
    [System.Xml.Serialization.XmlArrayItemAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
    public MessageEvent[] list {
        get {
            return this.listField;
        }
        set {
            this.listField = value;
            this.RaisePropertyChanged("list");
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)]
    public string message {
        get {
            return this.messageField;
        }
        set {
            this.messageField = value;
            this.RaisePropertyChanged("message");
        }
    }

    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

    protected void RaisePropertyChanged(string propertyName) {
        System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
        if ((propertyChanged != null)) {
            propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
        }
    }
}

捕获和处理ServiceFault的代码:

public static string GetFaultExceptionMessages(FaultException<ServiceFault> e)
{
    var msgs = "";
    foreach (var error in e.Detail.list)
    {
        msgs += error.DetailMessage.ToString() + Environment.NewLine;
    }
    return msgs;
}

响应:

<env:Envelope xmlns:env='http://www.w3.org/2003/05/soap-envelope'><env:Header></env:Header>
<env:Body>
    <env:Fault xmlns:env='http://www.w3.org/2003/05/soap-envelope'>
        <env:Code xmlns:env='http://www.w3.org/2003/05/soap-envelope'>
            <env:Value xmlns:env='http://www.w3.org/2003/05/soap-envelope'>env:Receiver</env:Value>
        </env:Code>
        <env:Reason xmlns:env='http://www.w3.org/2003/05/soap-envelope'>
            <env:Text xml:lang='de-DE' xmlns:env='http://www.w3.org/2003/05/soap-envelope'>Fachlicher Fehler:</env:Text>
        </env:Reason>
        <env:Detail xmlns:env='http://www.w3.org/2003/05/soap-envelope'>
            <ns2:ServiceFault xmlns:ns2='xxxx>
                <errorCode>0</errorCode>
                <list>
                    <MessageEvent>
                        <MessageInstanceId>-9223372036854775587</MessageInstanceId>
                        <MessageCode>CRM9007</MessageCode>
                        <ShortMessage>Loser Kontakt angelegt</ShortMessage>
                        <DetailMessage>Es wurde ein loser Kontakt angelegt, weil kein Partner identifiziert werden konnte.</DetailMessage>
                        <SeverityType>Warn</SeverityType>
                    </MessageEvent>
                </list>
                <message>Fachlicher Fehler:</message>
            </ns2:ServiceFault>
        </env:Detail>
    </env:Fault>
</env:Body>
</env:Envelope>

进入我的应用程序的唯一东西是MessageInstanceId。无论出于何种原因,其他任何东西都是空的。有人可以告诉我我做错了吗?

0 个答案:

没有答案