我程序代码如下:
string cid = textBox1.Text.Trim();
string strId = textBox2.Text.Trim();
string strPassword = textBox3.Text.Trim();
string postData = "<?xml version='1.0' encoding='iso-8859-1'?><!DOCTYPE jds SYSTEM '/home/httpd/html/dtd/jds2.dtd'><jds><account acid='" + cid + "'loginid='" + strId + "' passwd='" + strPassword + "'><change_pwd>NEW_PASSWORD</change_pwd></account></jds>";
//string postData = "<account acid='" + cid + "'loginid='" + strId + "' passwd='" + strPassword + "'><change_pwd>NEW_PASSWORD</change_pwd></account>";
Encoding encoding = Encoding.UTF8;
byte[] data = encoding.GetBytes(postData);
System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("https://smsmgr.three.com.hk/servlet/corpsms.jdsXMLClient2");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentType = "text/XML";//SOAP
req.ContentLength = data.Length;
System.IO.Stream newStream = req.GetRequestStream();
// 发送数据
newStream.Write(data, 0, data.Length);
System.Net.HttpWebResponse res = (System.Net.HttpWebResponse)req.GetResponse();
MessageBox.Show(res.StatusDescription.ToString());
newStream.Close(); //// 获取响应
HttpWebResponse myResponse = (HttpWebResponse)req.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
string content = reader.ReadToEnd();
//Response.Write(content);
textBox4.Text = content;要求发送的xml格式如下:
<!ELEMENT change_pwd (#PCDATA)>Example:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE jds SYSTEM "/home/httpd/html/dtd/jds2.dtd">
<jds>
<account acid="account id" loginid="login id" passwd="password">
<change_pwd>NEW_PASSWORD</change_pwd>
</account>
</jds>
现在的问题是 得到的服务器返回来的数据不正确! 告诉解答
string cid = textBox1.Text.Trim();
string strId = textBox2.Text.Trim();
string strPassword = textBox3.Text.Trim();
string postData = "<?xml version='1.0' encoding='iso-8859-1'?><!DOCTYPE jds SYSTEM '/home/httpd/html/dtd/jds2.dtd'><jds><account acid='" + cid + "'loginid='" + strId + "' passwd='" + strPassword + "'><change_pwd>NEW_PASSWORD</change_pwd></account></jds>";
//string postData = "<account acid='" + cid + "'loginid='" + strId + "' passwd='" + strPassword + "'><change_pwd>NEW_PASSWORD</change_pwd></account>";
Encoding encoding = Encoding.UTF8;
byte[] data = encoding.GetBytes(postData);
System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("https://smsmgr.three.com.hk/servlet/corpsms.jdsXMLClient2");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentType = "text/XML";//SOAP
req.ContentLength = data.Length;
System.IO.Stream newStream = req.GetRequestStream();
// 发送数据
newStream.Write(data, 0, data.Length);
System.Net.HttpWebResponse res = (System.Net.HttpWebResponse)req.GetResponse();
MessageBox.Show(res.StatusDescription.ToString());
newStream.Close(); //// 获取响应
HttpWebResponse myResponse = (HttpWebResponse)req.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
string content = reader.ReadToEnd();
//Response.Write(content);
textBox4.Text = content;要求发送的xml格式如下:
<!ELEMENT change_pwd (#PCDATA)>Example:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE jds SYSTEM "/home/httpd/html/dtd/jds2.dtd">
<jds>
<account acid="account id" loginid="login id" passwd="password">
<change_pwd>NEW_PASSWORD</change_pwd>
</account>
</jds>
现在的问题是 得到的服务器返回来的数据不正确! 告诉解答
还有textBox1 这类东东是啥
更不知道你程序的需求是啥,报告啥错误啦