/// <summary> /// Send a SOAP request to the specified endpoint and return the result. /// </summary> /// <param name="payload">Message payload</param> /// <param name="destination">Destination endpoint</param> /// <param name="clientCertificates">Client certificates to offer to the server.</param> /// <returns>Response.</returns> public static XmlElement SendSoapRequest( string payload, Uri destination, IEnumerable <X509Certificate2> clientCertificates) { if (destination == null) { throw new ArgumentNullException(nameof(destination)); } switch (destination.Scheme) { case "http": case "https": break; default: throw new ArgumentException("The Uri scheme " + destination.Scheme + " is not allowed for outbound SOAP messages. Only http or https URLs are allowed."); } var message = CreateSoapBody(payload); using (var client = new ClientCertificateWebClient(clientCertificates)) { client.Headers.Add("SOAPAction", "http://www.oasis-open.org/committees/security"); var response = client.UploadString(destination, message); return(ExtractBody(response)); } }
public static XmlElement SendSoapRequest(string payload, Uri destination, X509Certificate2 signingServiceCertificate, X509Certificate2 artifactResolutionTlsCertificate) { AssertDestinationIsValid(destination); using (var client = new ClientCertificateWebClient(artifactResolutionTlsCertificate)) { client.Headers.Add("SOAPAction", "http://www.oasis-open.org/committees/security"); var message = BuildSoapMesssage(payload, signingServiceCertificate); var response = client.UploadString(destination, message); return(ExtractBody(response)); } }