コード例 #1
0
        private static Soap12FaultCode DeserializeSoapFaultCode(XmlReader reader)
        {
            const int depth = 4;

            var faultCode = new Soap12FaultCode();

            if (reader.IsEmptyElement || !reader.MoveToElement(depth, faultCodeValueName))
            {
                throw new InvalidQueryException($"SOAP 1.2 Fault Code must have `{faultCodeValueName}` element.");
            }
            faultCode.Value = DeserializeFaultCodeValue(reader);

            var success = reader.MoveToElement(depth);

            if (success && reader.IsCurrentElement(depth, faultCodeSubcodeName))
            {
                faultCode.Subcode = DeserializeFaultCodeSubcode(reader, depth + 1);
                success           = reader.MoveToElement(depth);
            }

            if (success)
            {
                throw new InvalidQueryException($"Unexpected element `{reader.GetXName()}` in SOAP 1.2 Fault Code element.");
            }

            return(faultCode);
        }
コード例 #2
0
        private static void WriteSoapFaultCode(XmlWriter writer, Soap12FaultCode faultCode)
        {
            writer.WriteStartElement(faultCodeName);

            writer.WriteStartElement(faultCodeValueName);
            WriteSoapFaultValueEnum(writer, faultCode.Value);
            writer.WriteEndElement();

            WriteSoapFaultSubcode(writer, faultCode.Subcode);

            writer.WriteEndElement();
        }