我正在尝试生成一个肥皂请求,但无法弄清楚我做错了什么......
以下是有关请求外观的文档: http ://wiki.affiliatewindow.com/index.php/Affiliate_Service_API_v4
这就是我所做的:
StringBuilder reqBuilder = new StringBuilder(1000);
reqBuilder.Append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:ns1=\"http://api.affiliatewindow.com/\">");
reqBuilder.Append("<soapenv:Header>");
reqBuilder.Append("<ns1:UserAuthentication soapenv:mustUnderstand=\"1\" soapenv:actor=\"http://api.affiliatewindow.com\">");
reqBuilder.Append("<ns1:iId>***********</ns1:iId>");
reqBuilder.Append("<ns1:sPassword>**************</ns1:sPassword>");
reqBuilder.Append("<ns1:sType>affiliate</ns1:sType>");
reqBuilder.Append("</ns1:UserAuthentication>");
reqBuilder.Append("</soapenv:Header>");
reqBuilder.Append("<soapenv:Body>");
reqBuilder.Append("<ns1:getTransactionList>");
reqBuilder.Append("<ns1:dStartDate>" + dateTimePickerFrom.Value.ToString("yyyy-MM-dd")+ "</ns1:dStartDate>");
reqBuilder.Append("<ns1:dEndDate>" + dateTimePickerTo.Value.ToString("yyyy-MM-dd") + "</ns1:dEndDate>");
reqBuilder.Append("<ns1:sDateType>transaction</ns1:sDateType>");
reqBuilder.Append("</ns1:getTransactionList>");
reqBuilder.Append("</soapenv:Body>");
reqBuilder.Append("</soapenv:Envelope>");
string strSoapMessage = reqBuilder.ToString();
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(@"http://api.affiliatewindow.com/v4/AffiliateService?wsdl"));
req.ContentType = "text/xml; charset=utf-8";
req.Method = "POST";
req.Accept = "text/xml";
req.Headers.Add("SOAPAction", "getTransactionList");
byte[] reqBytes = System.Text.Encoding.UTF8.GetBytes(strSoapMessage);
req.ContentLength = reqBytes.Length;
Stream reqStream = req.GetRequestStream();
reqStream.Write(reqBytes, 0, reqBytes.Length); reqStream.Close();
HttpWebResponse response = req.GetResponse() as HttpWebResponse;
Stream responsedata = response.GetResponseStream();
StreamReader responsereader = new StreamReader(responsedata);
string response1 = responsereader.ReadToEnd();
string saveFileName = "test.xml";
XmlDocument xmlFile = new XmlDocument();
xmlFile.LoadXml(response1);
xmlFile.Save(saveFileName);
我的回复是 wsdl 服务的内容(http://api.affiliatewindow.com/v4/AffiliateService?wsdl)
任何帮助都将受到欢迎