SOAP Client in C# without access to a WSDL-file

前端 未结 4 1781
北荒
北荒 2021-02-02 17:17

I\'m working with a third party to integrate some of our systems with theirs and they provide us with a SOAP interface to make certain requests and changes in their connected sy

4条回答
  •  失恋的感觉
    2021-02-02 18:01

    string EndPoints = "http://203.189.91.127:7777/services/spm/spm";
    
    string New_Xml_Request_String = " " + DateTime.Now.ToString("o").Remove(19, 14) + "" + Source + "" + Destincation + "";
    
    
     protected string HttpSOAPRequest_Test(string xmlfile, string proxy)
        {
            try
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.InnerXml = xmlfile.ToString();
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(EndPoints);
                req.Timeout = 100000000;
                if (proxy != null)
                    req.Proxy = new WebProxy(proxy, true);
                req.Headers.Add("SOAPAction", "");
                req.ContentType = "application/soap+xml;charset=\"utf-8\"";
                req.Accept = "application/x-www-form-urlencoded"; //"application/soap+xml";
                req.Method = "POST";
                Stream stm = req.GetRequestStream();
                doc.Save(stm);
                stm.Close();
                WebResponse resp = req.GetResponse();
                stm = resp.GetResponseStream();
                StreamReader r = new StreamReader(stm);
                string myd = r.ReadToEnd();
                return myd;
            }
    
       catch (Exception se)
            {
                throw new Exception("Error Occurred in AuditAdapter.getXMLDocumentFromXMLTemplate()", se);
            }
        }
    

提交回复
热议问题