Exemple #1
0
        /// <summary>
        /// Try to parse the given XML representation of a SOAP header.
        /// </summary>
        /// <param name="SOAPHeaderXML">The XML to be parsed.</param>
        /// <param name="SOAPHeader">The parsed connector type.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement SOAPHeaderXML,
                                       out SOAPHeader SOAPHeader,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                SOAPHeader = new SOAPHeader(

                    SOAPHeaderXML.MapValueOrFail(OCPPNS.OCPPv1_6_CS + "chargeBoxIdentity",
                                                 ChargeBox_Id.Parse),

                    SOAPHeaderXML.ElementValueOrFail(SOAPNS.v1_2.NS.SOAPAdressing + "Action"),
                    SOAPHeaderXML.ElementValueOrFail(SOAPNS.v1_2.NS.SOAPAdressing + "MessageID"),
                    SOAPHeaderXML.ElementValueOrDefault(SOAPNS.v1_2.NS.SOAPAdressing + "RelatesTo"),
                    SOAPHeaderXML.ElementValueOrFail(SOAPNS.v1_2.NS.SOAPAdressing + "From"),
                    SOAPHeaderXML.ElementValueOrFail(SOAPNS.v1_2.NS.SOAPAdressing + "To")

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(DateTime.UtcNow, SOAPHeaderXML, e);

                SOAPHeader = null;
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// Encapsulate the given XML within a XML SOAP frame.
        /// </summary>
        /// <param name="SOAPHeader">A SOAP header.</param>
        /// <param name="SOAPBody">The internal XML for the SOAP body.</param>
        /// <param name="XMLNamespaces">An optional delegate to process the XML namespaces.</param>
        public static XElement Encapsulation(SOAPHeader SOAPHeader,
                                             XElement SOAPBody,
                                             XMLNamespacesDelegate XMLNamespaces = null)

        => Encapsulation(SOAPHeader.ChargeBoxIdentity,
                         SOAPHeader.Action,
                         SOAPHeader.MessageId,
                         SOAPHeader.RelatesTo,
                         SOAPHeader.From,
                         SOAPHeader.To,
                         SOAPBody,
                         XMLNamespaces);
Exemple #3
0
        /// <summary>
        /// Compares two id tag infos for equality.
        /// </summary>
        /// <param name="SOAPHeader">An id tag info to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public Boolean Equals(SOAPHeader SOAPHeader)
        {
            if ((Object)SOAPHeader == null)
            {
                return(false);
            }

            return(ChargeBoxIdentity.Equals(SOAPHeader.ChargeBoxIdentity) &&
                   Action.Equals(SOAPHeader.Action) &&
                   MessageId.Equals(SOAPHeader.MessageId) &&

                   ((RelatesTo == null && SOAPHeader.RelatesTo == null) ||
                    (RelatesTo != null && SOAPHeader.RelatesTo != null && RelatesTo.Equals(SOAPHeader.RelatesTo))) &&

                   From.Equals(SOAPHeader.From) &&
                   To.Equals(SOAPHeader.To));
        }
Exemple #4
0
        /// <summary>
        /// Try to parse the given text representation of a SOAP header.
        /// </summary>
        /// <param name="SOAPHeaderText">The text to be parsed.</param>
        /// <param name="SOAPHeader">The parsed connector type.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(String SOAPHeaderText,
                                       out SOAPHeader SOAPHeader,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                if (TryParse(XDocument.Parse(SOAPHeaderText).Root,
                             out SOAPHeader,
                             OnException))
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                OnException?.Invoke(DateTime.UtcNow, SOAPHeaderText, e);
            }

            SOAPHeader = null;
            return(false);
        }