• 处理soapUI特殊返回报文 【原】


    String message ="<?xml version="1.0" encoding="UTF-8"?>"
          
          + "<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">"
          + "<soap:Body>"
          +  "   <SetBxInfoTest xmlns="http://tempuri.org/">  "
          +  "        <jkxlh>C33D61EF17</jkxlh>  "
          +  "         <WriteXml> <![CDATA[<?xml version="1.0" encoding="UTF-8"?>"
          +  "       <Data> "
          +  "        <value> "
          +  "             <Hphm/>  "
          +  "            <Cjh>QWSDEFRTGVFEDSWER</Cjh>  "
          +  "          <Bdh>63008080120150000001</Bdh>  "
          +  "            <Pdh>23008135920150000001</Pdh>  "
          +  "           <Jqxbf>1100.00</Jqxbf>  "
          +  "           <Qbrq>2015-05-21</Qbrq>  "
          +  "           <Zbrq>2016-05-20</Zbrq>  "
          +  "            <Bbxr>张</Bbxr>  "
          +  "          <Bbxrsfz>441225198006022516</Bbxrsfz>  "
          +  "           <Jqxzt>1</Jqxzt>  "
          +  "            <Scrq>2015-05-20 15:32:35</Scrq>  "
          +  "           <Ccsqk>4</Ccsqk>  "
          +  "           <Ccsje/>  "
          +  "           <Ccspzhm/>  "
          +  "            <Ccssbh/>  "
          +  "           <Ccsnsrq/>  "
          +  "            <Ccsnsqsrq/>  "
          +  "           <Ccsnszzrq/>  "
          +  "            <BdImg/> "
          +  "        </value> "
          +  "      </Data>]]> </WriteXml> "
          +  "      </SetBxInfoTest> "
          +  "  </soap:Body> "
          +  "</soap:Envelope>";
            HttpClient httpclient = HttpClients.createDefault();
            HttpPost httppost = new HttpPost("http://10.15.22.120:8866/5700000002/ZHJDCBXSJAddCxSj/V1");//请求地址
            StringEntity content =new StringEntity(message, Charset.forName("UTF-8"));// 第二个参数,设置后才会对,内容进行编码
            content.setContentType("application/soap+xml; charset=UTF-8");//设置UTF-8编码
            content.setContentEncoding("UTF-8");
            httppost.setEntity(content);
            
            HttpResponse responses = null;
            Document doc = null;
            String queryResReceiveXml = null;
            String sentity = null;
            try {
                responses = httpclient.execute(httppost);//执行发送
                HttpEntity resEntity = responses.getEntity();
                if (resEntity != null) {
                    sentity = EntityUtils.toString(resEntity, "UTF-8");//接受返回报文数据
                    System.out.println("返回2报文:"+sentity);
                    doc = XmlTool.getDocument(sentity, "UTF-8");//转换格式化
                    Element eRoot = doc.getRootElement();
                    Element body = eRoot.getChild("Body", eRoot.getNamespace());
                    Element resp = (Element) body.getChildren().get(0);
                    Element returnele = (Element) resp.getChildren().get(0);
                    if(returnele != null){
                        queryResReceiveXml = returnele.getText().toString();
                    }
                }
            } catch (ClientProtocolException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                System.out.println("返回报文:
    " + queryResReceiveXml);
            }
  • 相关阅读:
    xiaopiu产品原型设计与团队实时协作平台
    asp.net webform过滤器(注意我们可以在拦截请求的同时设置回调函数)
    wdScrollTab
    pageoffice实现网页打开编辑保存word文档(基于SSM框架)
    ESB企业服务总线
    JRebel for IntelliJ
    dtcms 手机浏览
    maven仓库添加jar架包
    shell脚本实现FTP自动上传文件
    mysql创建数据库指定字符集
  • 原文地址:https://www.cnblogs.com/hmhhz/p/9663037.html
Copyright © 2020-2023  润新知