/// <summary> /// Appends the received <see cref="SoapHeader"/> collection to the existing /// ones in the received <see cref="SoapEnvelope"/>. /// </summary> /// <param name="envelope">The <see cref="SoapEnvelope"/> to append the headers</param> /// <param name="headers">The <see cref="SoapHeader"/> collection to append</param> /// <returns>The <see cref="SoapEnvelope"/> after changes</returns> /// <exception cref="ArgumentNullException"></exception> public static SoapEnvelope WithHeaders( this SoapEnvelope envelope, params SoapHeader[] headers) { if (envelope == null) { throw new ArgumentNullException(nameof(envelope)); } if (headers == null) { throw new ArgumentNullException(nameof(headers)); } if (headers.Length == 0) { return(envelope); } var xElementHeaders = new XElement[headers.Length]; for (var i = 0; i < headers.Length; i++) { xElementHeaders[i] = SoapClientSettings.Default.SerializationProvider.ToXElement(headers[i]); } return(envelope.WithHeaders(xElementHeaders)); }
/// <summary> /// Appends the received <see cref="SoapHeader"/> collection to the existing /// ones in the received <see cref="SoapEnvelope"/>. /// </summary> /// <param name="envelope">The <see cref="SoapEnvelope"/> to append the headers</param> /// <param name="headers">The <see cref="SoapHeader"/> collection to append</param> /// <returns>The <see cref="SoapEnvelope"/> after changes</returns> /// <exception cref="ArgumentNullException"></exception> public static SoapEnvelope WithHeaders( this SoapEnvelope envelope, IEnumerable <SoapHeader> headers) { return(envelope.WithHeaders(headers as SoapHeader[] ?? headers.ToArray())); }