直接分析接口返回内容
public string GetProductID(string spid, string userid, string usertoken)
{
string products = "";
//byte[] bytes = Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope//" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance/" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema/%22%3E%3Csoap:Body%3E%3Cusersubedproducts xmlns=\"http://vas.webservice..shtel.com/%22%3E%3Creq%3E%3Cspid>" + spid + "</SPID><userID>" + userid + "</userID><userToken>" + usertoken + "</userToken></req></userSubedProducts></soap:Body></soap:Envelope>");
byte[] bytes = Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"utf-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope//" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance/" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema/%22%3E%3Csoapenv:Body%3E%3Cusersubedproducts xmlns=\"http://vas.webservice.shtel.com/%22%3E%3Creq%3E%3Cspid>" + spid + "</SPID><userID>" + userid + "</userID><userToken>" + usertoken + "</userToken></req></userSubedProducts></soapenv:Body></soapenv:Envelope>");
HttpWebRequest request = WebRequest.Create("http://iptvauth.online.sh.cn:7001/services/VasServiceSoapImpl") as HttpWebRequest;
request.Method = "POST";
request.ContentType = "text/xml";
request.CookieContainer = new CookieContainer();
request.ContentLength = bytes.Length;
request.AllowAutoRedirect = false;
request.Headers.Add("SOAPAction", "");
using (Stream requestStream = request.GetRequestStream())
requestStream.Write(bytes, 0, bytes.Length);
StreamReader sr = null;
string responseStr = string.Empty;
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
sr = new StreamReader(response.GetResponseStream(), Encoding.Default);
responseStr = sr.ReadToEnd();
}
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(new System.IO.MemoryStream(System.Text.Encoding.GetEncoding("GB2312").GetBytes(responseStr)));
XmlNodeList proList = xmldoc.GetElementsByTagName("productID");
for (int i = 0; i < proList.Count; i++)
{
products += proList[i].InnerText + ";";
}
if (products != "")
products = products.Substring(0, products.Length - 1);
return products;
}