Code
XmlDocument vXmlDoc = new XmlDocument();
FileStream vStream = new FileStream(@"Soap.xml", FileMode.Open, FileAccess.Read);
vXmlDoc.Load(vStream);
string vPostData = vXmlDoc.OuterXml;
byte[] vPostBytes = System.Text.Encoding.ASCII.GetBytes(vPostData);
Uri vUri = new Uri(this.txtUri.Text);
HttpWebRequest vRequest = (HttpWebRequest)HttpWebRequest.Create(vUri);
vRequest.Method = "POST";
vRequest.ContentType = "text/xml;charset=utf-8";
vRequest.ContentLength = vPostBytes.Length;
vRequest.Headers.Add(string.Format("SOAPAction: \"http://tempuri.org/{0}\"", this.txtMethodName.Text));
vRequest.Timeout = 5000;
Stream vRequestStream = vRequest.GetRequestStream();
vRequestStream.Write(vPostBytes, 0, vPostBytes.Length);
vRequestStream.Flush();
vRequestStream.Close();
HttpWebResponse vResponse = (HttpWebResponse)vRequest.GetResponse();
Stream vResponseStream = vResponse.GetResponseStream();
StreamReader vReader = new StreamReader(vResponseStream);
string vResult = vReader.ReadToEnd();
vReader.Close();
vResponseStream.Close();
vResponse.Close();
MessageBox.Show(vResult);
XmlDocument vXmlDoc = new XmlDocument();
FileStream vStream = new FileStream(@"Soap.xml", FileMode.Open, FileAccess.Read);
vXmlDoc.Load(vStream);
string vPostData = vXmlDoc.OuterXml;
byte[] vPostBytes = System.Text.Encoding.ASCII.GetBytes(vPostData);
Uri vUri = new Uri(this.txtUri.Text);
HttpWebRequest vRequest = (HttpWebRequest)HttpWebRequest.Create(vUri);
vRequest.Method = "POST";
vRequest.ContentType = "text/xml;charset=utf-8";
vRequest.ContentLength = vPostBytes.Length;
vRequest.Headers.Add(string.Format("SOAPAction: \"http://tempuri.org/{0}\"", this.txtMethodName.Text));
vRequest.Timeout = 5000;
Stream vRequestStream = vRequest.GetRequestStream();
vRequestStream.Write(vPostBytes, 0, vPostBytes.Length);
vRequestStream.Flush();
vRequestStream.Close();
HttpWebResponse vResponse = (HttpWebResponse)vRequest.GetResponse();
Stream vResponseStream = vResponse.GetResponseStream();
StreamReader vReader = new StreamReader(vResponseStream);
string vResult = vReader.ReadToEnd();
vReader.Close();
vResponseStream.Close();
vResponse.Close();
MessageBox.Show(vResult);
Soap.xml
Code
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetHello xmlns="http://tempuri.org/">
<pWord>string</pWord>
</GetHello>
</soap:Body>
</soap:Envelope>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetHello xmlns="http://tempuri.org/">
<pWord>string</pWord>
</GetHello>
</soap:Body>
</soap:Envelope>