Esempio n. 1
0
 private static byte[] EncodeParamsToSoap(Hashtable paras, String xmlNS, String methodName) {
     XmlDocument doc = new XmlDocument();
     doc.LoadXml("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"></soap:Envelope>");
     XmlDeclaration decl = doc.CreateXmlDeclaration("1.0", "utf-8", null);
     doc.InsertBefore(decl, doc.DocumentElement);
     XmlElement soapBody = doc.CreateElement("soap", "Body", "http://schemas.xmlsoap.org/soap/envelope/");
     XmlElement soapMethod = doc.CreateElement(methodName);
     soapMethod.SetAttribute("xmlns", xmlNS);
     if (!(paras.IsNull() || paras.Count == 0)) {
         foreach (string k in paras.Keys) {
             XmlElement soapPar = doc.CreateElement(k);
             soapPar.InnerText = paras[k].ToString();
             soapMethod.AppendChild(soapPar);
         }
     }
     soapBody.AppendChild(soapMethod);
     doc.DocumentElement.AppendChild(soapBody);
     return Encoding.UTF8.GetBytes(doc.OuterXml);
 }
Esempio n. 2
0
 /// <summary>
 /// GET方式调用WebService
 /// </summary>
 /// <param name="url">server接口</param>
 /// <param name="methodName">方法名</param>
 /// <param name="parms">参数</param>
 /// <returns></returns>
 public static string GetWebService(string url, string methodName, Hashtable parms) {
     string param = parms.IsNull() || parms.Count == 0 ? string.Empty : ("?" + parms.ToUrl());
     return GetWebService(url, methodName, param);
 }