c# 获取JAVA WSDL 接口数据 soap:Envelope

   <soapenv:Envelope xmlns:imp="http://imp.bank.ws.manager.cdxt.com/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header /><soapenv:Body><imp:GetRegDateList><arg0>&lt;Request&gt;&lt;DistrictId&gt;&lt;/DistrictId&gt;&lt;RegDate&gt;2021-09-12&lt;/RegDate&gt;&lt;OrgId&gt;&lt;/OrgId&gt;&lt;UserId&gt;pufa001&lt;/UserId&gt;&lt;/Request&gt;</arg0></imp:GetRegDateList></soapenv:Body></soapenv:Envelope>
    

 public static string GetSOAPReSource(string url, string strMethodName, Hashtable Pars)
    {
        try
        {

            XmlDocument doc = new XmlDocument();
            XmlElement root = (XmlElement)doc.AppendChild(doc.CreateElement("soapenv", "Envelope", "http://schemas.xmlsoap.org/soap/envelope/"));
            root.SetAttribute("xmlns:imp", "http://imp.bank.ws.manager.com/");
            XmlElement header = (XmlElement)root.AppendChild(doc.CreateElement("soapenv", "Header", "http://schemas.xmlsoap.org/soap/envelope/"));
            XmlElement soapBody = (XmlElement)root.AppendChild(doc.CreateElement("soapenv", "Body", "http://schemas.xmlsoap.org/soap/envelope/"));
            XmlElement soapMethod = (XmlElement)root.AppendChild(doc.CreateElement("imp", strMethodName, "http://imp.bank.ws.manager.com/"));
            foreach (string k in Pars.Keys)
            {
                XmlElement soapPar = doc.CreateElement(k);
                soapPar.InnerXml = ObjectToSoapXml(Pars[k]);
                soapMethod.AppendChild(soapPar);
            }
            soapBody.AppendChild(soapMethod);
            doc.DocumentElement.AppendChild(soapBody);
            Uri uri = new Uri(url);
            WebRequest webRequest = WebRequest.Create(uri);
            webRequest.ContentType = "text/xml; charset=utf-8";
            webRequest.Method = "POST";
            using (Stream requestStream = webRequest.GetRequestStream())
            {
                byte[] paramBytes = Encoding.UTF8.GetBytes(doc.InnerXml);
                requestStream.Write(paramBytes, 0, paramBytes.Length);
            }
            WebResponse webResponse = webRequest.GetResponse();
            using (StreamReader myStreamReader = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8))
            {
                string result = "";
                return result = myStreamReader.ReadToEnd();
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

    }

<Response><ResultCode>0</ResultCode><ResultMsg>成功</ResultMsg><Item><RegDate>2021-09-12</RegDate><RegWeekDay>星期日</RegWeekDay></Item><Item><RegDate>2021-09-13</RegDate><RegWeekDay>星期一</RegWeekDay></Item><Item><RegDate>2021-09-14</RegDate><RegWeekDay>星期二</RegWeekDay></Item><Item><RegDate>2021-09-15</RegDate><RegWeekDay>星期三</RegWeekDay></Item><Item><RegDate>2021-09-16</RegDate><RegWeekDay>星期四</RegWeekDay></Item><Item><RegDate>2021-09-17</RegDate><RegWeekDay>星期五</RegWeekDay></Item><Item><RegDate>2021-09-18</RegDate><RegWeekDay>星期六</RegWeekDay></Item><Item><RegDate>2021-09-19</RegDate><RegWeekDay>星期日</RegWeekDay></Item></Response>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值