Created
November 21, 2016 03:49
-
-
Save oscarkuo/63fe9ae8664ec0a38f34a653fbfa4509 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected static WebRequest CreateRequest(string url, string secret) | |
{ | |
var xml = @" | |
<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:ns=""https://service/1/0""> | |
<soapenv:Header/> | |
<soapenv:Body> | |
<ns:Request> | |
<ns:FirstName>XXX</ns:FirstName> | |
<ns:LastName>YYY</ns:LastName> | |
</ns:Request> | |
</soapenv:Body> | |
</soapenv:Envelope>"; | |
var c = Encoding.UTF8.GetBytes(xml); | |
var wr = (HttpWebRequest)WebRequest.Create(url); | |
wr.ProtocolVersion = HttpVersion.Version11; | |
wr.ContentType = "text/xml;charset=utf-8"; | |
wr.ContentLength = xml.Length; | |
wr.Accept = "text/xml"; | |
wr.Headers.Add("SOAPAction", "\"\""); | |
wr.Headers.Add("Secret", secret); | |
wr.Method = "POST"; | |
wr.GetRequestStream().Write(c, 0, c.Length); | |
return wr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment