110,534
社区成员
发帖
与我相关
我的任务
分享
string soap = @"
<?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>
<Register xmlns=""http://tempuri.org/"">
<id>123</id>
<data1>string</data1>
</Register>
</soap:Body>
</soap:Envelope>";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://192.168.1.102/WebServiceTest/WebServiceTest.asmx");
req.Headers.Add("SOAPAction", "\"http://tempuri.org/Register\"");
req.ContentType = "text/xml;charset=\"utf-8\"";
req.Accept = "text/xml";
req.Method = "POST";
using (Stream stm = req.GetRequestStream())
{
using (StreamWriter stmw = new StreamWriter(stm))
{
stmw.Write(soap);
}
}
WebResponse response = req.GetResponse();
Stream responseStream = response.GetResponseStream();
string soap = @"POST http://192.168.1.102/WebServiceTest/WebServiceTest.asmx HTTP/1.1
Host: 192.168.1.102
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: ""http://tempuri.org/Register""
<?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>
<Register xmlns=""http://tempuri.org/"">
<id>123</id>
<data1>string</data1>
</Register>
</soap:Body>
</soap:Envelope>";
this._socket = new System.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
try
{
_socket.Connect(new IPEndPoint(IPAddress.Parse("192.168.1.102"), 80));
_socket.Send(Encoding.UTF8.GetBytes(soap));
BeginReceiving();
}
catch (Exception ex)
{
}