小弟最近在从事智能设备软件的开发,在数据采集器上运行,通过调用webserivce达到效果。 但是webserivce要求能够动态的。也就是说可以自己配置webserivce(当然是在正确的前提下)。我先前是直接将webserivce引用到项目中的。但是要动态的话这样就不可以了。网上有说用WebClient 但是 我的开发环境里根本就引用不进来。请各位大侠指教!
问题补充:
要是感觉分少了 可以提。只要有 一定加!
IniFileAction NewIni = new IniFileAction(filename);
string url = NewIni.IniReadValue("ClientSet", "RemoteServer");
string username = superclass.JieMi(NewIni.IniReadValue("ClientSet", "LoginServerUser"));
string password = superclass.JieMi(NewIni.IniReadValue("ClientSet", "LoginServerPass"));
string strId = username;
string strPassword = password;
Stream stream1 = null;
Encoding encoding = Encoding.GetEncoding("gb2312");
HttpWebRequest myRequest = null;
string postData = "username=" + strId;
postData += ("&password=" + strPassword);
byte[] data = encoding.GetBytes(postData);
//byte[] data = new byte[postData.Length];
myRequest = (HttpWebRequest)WebRequest.Create("http://192.168.0.2:86/SHRemoteShutdownWebSerivce/Service.asmx?op=shutdown");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded; charset=gb2312";
myRequest.ContentLength = data.Length;
stream1= myRequest.GetRequestStream();
// Send the data.
stream1.Write(data, 0, data.Length);
stream1.Close();
HttpWebResponse response = (HttpWebResponse)myRequest.GetResponse();
Stream stream2 = response.GetResponseStream();
StreamReader reader = new StreamReader(stream2,encoding);
string str = reader.ReadToEnd();
後浪
|
小虾三级
|
园豆:
830
提问于:2010-12-15 19:50