???????Webservice???????????:
????Webservice????1:???????????????URL???????????????????????????????
????http://localhost/WebService/MyService.asmx?op=MyAction
????Webservice????2:html??????????????????
<form id="form1" runat="server" action="http://10.15.223.56/WebService/MyService.asmx/MyAction">
<input type="text" name="strXml" value="<a ObjID="9"></a>" />
<input type="text" name="strData" value="ContactSign|990011|???????" />
<input type="submit" value="Send" />
</form>
????Webservice????3:??C#?з???HttpPost??????????WebService?е?MyAction?????????????£?
void UpdateContactSign()
{
string ServerPage ="http://localhost/WebService/MyService.asmx";
try
{
//ServerPage += "?op=TangramAction";
ServerPage += "/MyAction";//MyAction??WebService?е????
string strXml="<a ObjID="9"></a>"??;//?????????
string strData="ContactSign|990011|???????";//?????????
string res = HttpConnectToServer(ServerPage?? strXml?? strData);
//MessageBox.Show(res);
}
catch (Exception ex)
{
}
}
//???????????????
public string HttpConnectToServer(string ServerPage??string strXml??string strData)
{
string postData = "strXml=" + strXml+"&strData="+strData;
byte[] dataArray = Encoding.Default.GetBytes(postData);
//????????
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(ServerPage);
request.Method = "POST";
request.ContentLength = dataArray.Length;
request.ContentType = "application/x-www-form-urlencoded";
//??????????
Stream dataStream = null;
try
{
dataStream = request.GetRequestStream();
}
catch (Exception)
{
return null;//????????????
}
//????????
dataStream.Write(dataArray?? 0?? dataArray.Length);
dataStream.Close();
//??????????
string res = string.Empty;
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream()?? Encoding.UTF8);
res = reader.ReadToEnd();
reader.Close();
}
catch (Exception ex)
{
return null;//????????????
}
return res;
}