ESB开发环境地址:
http://10.15.22.120:8018
ESB要求各系统提供的传输报文规范
客户端 |
服务端 |
节点名 |
中文意思 |
进一步说明 |
请求 |
SERVICENAME |
ESB服务名 |
||
请求 |
FLOWID |
ESB流ID |
UUID.randomUUID();即可生成 |
|
请求 |
SERVICE_NO |
ESB服务号 |
||
请求 |
USERID |
ESB用户编号 |
||
请求 |
PASSWORD |
ESB密码 |
||
返回 |
ERROR_CODE |
ESB错误代码 |
0000在ESB代表成功 |
|
返回 |
ERROR_MESSAGE |
ESB错误信息 |
ESB各系统测试环境系统名及用户帐号密码
各系统测试环境 | Head协议头系统名 | 用户帐号 | 开发环境用户密码 | 生产环境预设密码 |
appName | <USERID> | <PASSWORD> | <PASSWORD> | |
电销 | telesales | 50000001 | 123456 | 预设为: 123456789 |
网销 | echannel | 50000002 | 123456 | 预设为: 123456789 |
ecargo | ecargo | 50000003 | 123456 | 预设为: 123456789 |
代理平台 | platformproxy | 50000004 | 123456 | 预设为: 123456789 |
ilog | ilog | 50000005 | 123456 | 预设为: 123456789 |
微信 | weixin | 50000009 | 123456 | 预设为: 123456789 |
销管 | salemanage | 50000010 | 123456 | 预设为: 123456789 |
联合保险经纪 | unionpolicy | 50000011 | 123456 | 预设为: 123456789 |
山东意外险风险预警系统 | sdaccident | 50000012 | 123456 | 预设为: 123456789 |
支付平台 | paystation | 50000013 | 123456 | 预设为: 123456789 |
道客 | dk | 60000001 | 预设为: 123456789 | |
汽车超人 | carsuper | 60000002 | 123456 | 预设为: 123456789 |
移动查勘 | Movesurvey | 50000014 | 123456 | 预设为: 123456789 |
移动查勘 | movesurvey | 60000003 | 123456 | 预设为: 123456789 |
v7车承保 | policyvhl | 70000001 | 123456 | 预设为: 123456789 |
v7非车承保 | novhlpolicy | 70000002 | 123456 | 预设为: 123456789 |
v7车理赔 | vhlclaim | 70000003 | 123456 | 预设为: 123456789 |
v7收付系统 | finarp | 70000004 | 123456 | 预设为: 123456789 |
接口系统 | thirdinterface | 80808080 | 123456 | 预设为: 123456789 |
营销系统 | marketing | 70000005 | 123456 | 预设为: 123456789 |
核心系统 | v5core | 70000006 | 123456 | 预设为: 123456789 |
客户端请求报文样例:
<?xml version="1.0" encoding="utf-8"?> <PACKET> <HEAD> <SERVICENAME>policyquery</SERVICENAME> <SYSNAME>电销</SYSNAME> <USERCDE>1006751</USERCDE> <DPTCDE>37</DPTCDE> <SYSCODE>02</SYSCODE> <FLOWID>68123ff5-eb74-4f67-b078-52bf437d4650</FLOWID> <SERVICE_NO>0101020101</SERVICE_NO> <BUSFLOWID/> <REQUEST_TYPE>0355-01</REQUEST_TYPE> <DATA>A</DATA> <TYPE>I</TYPE> <USERID>50000001</USERID> <PASSWORD>123456</PASSWORD> </HEAD> <BODY> <VHL> <VEHICLE_CATEGORY>345039001</VEHICLE_CATEGORY> <EXTENDED_AREA_RADIUS/> <CAR_MARK>*</CAR_MARK> <USE_TYPE>345038001</USE_TYPE> <CHK_CDE/> </VHL> <BASE> <DPT_CDE>33</DPT_CDE> <INSURED_NAME>A君</INSURED_NAME> </BASE> </BODY> </PACKET>
服务端返回报文样例:
<PACKET> <HEAD> <ERROR_CODE>0000</ERROR_CODE> <ERROR_MESSAGE>【保监平台】成功</ERROR_MESSAGE> <REQUEST_TYPE>0355-01</REQUEST_TYPE> <RESPONSE_CODE>1</RESPONSE_CODE> </HEAD> <BODY> <BASE> <CLAIM_SIZE>0</CLAIM_SIZE> <LAST_EFFECTIVE_DATE></LAST_EFFECTIVE_DATE> <LAST_EXPIRE_DATE></LAST_EXPIRE_DATE> <LAST_PRODUCER_CODE></LAST_PRODUCER_CODE> </BASE> <CAR> <BRAND>比亚迪</BRAND> <BRAND_CODE>BYD</BRAND_CODE> <CAR_NAME>西安奥拓QCJ7080B 实用款</CAR_NAME> <CATEGORY_CODE>7</CATEGORY_CODE> <CATEGORY_NAME>轿车</CATEGORY_NAME> <CONFIG_TYPE>UA</CONFIG_TYPE> <DEPT_CODE>0</DEPT_CODE> <DEPT_NAME>国产</DEPT_NAME> <MODEL_CODE>BBYDXBUA0003</MODEL_CODE> <MODEL_ID_CODE>BBYDXBUA000370A1</MODEL_ID_CODE> <NOTICE_TYPE>QCJ7080B</NOTICE_TYPE> <SERIES>西安奥拓</SERIES> <SERIES_CODE>BYDXB</SERIES_CODE> <TRADE_CODE>M0080</TRADE_CODE> <TRADE_NAME>比亚迪汽车有限公司</TRADE_NAME> </CAR> <VHL> <QUERY_CDE>V0101ZSIC340016001458127415676</QUERY_CDE> </VHL> </BODY> </PACKET>
但有的强势第三方系统的报文不可能按我们的要求来,所以也有可能返回时是不规范的.
如支付宝/道客/增值税管理 ... 等系统,将可能直接返回不带<HEAD>和<BODY>体的报文:
<SOAP-ENV> <resultHeader> <resultFLag>N</resultFLag> <resultMsg>出错信息</resultMsg> <recordTotal>记录总数</recordTotal> <pageTotal>总页数</pageTotal> <pageSize>页大小</pageSize> <currentPage>请求页</currentPage> </resultHeader> </SOAP-ENV>
调用java样板http post代码(纯java,不依赖第三方jar包)
package king.client.delete; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.Date; /** * http post发送工具 * @author King * */ public class HttpTool { public static void main(String[] args) throws Exception { String requestUrl = "http://10.15.22.120:8866/4200000001/QueryInputBillAuthenInfo/V1"; // String reqUrl = "http://10.15.22.120:8866/4200000001/CancelInputBillAuthenInfo/V1"; String requestData = readStringFromFile("C:\\Users\\King\\Desktop\\connectANSI.xml","GBK");//有乱码,请修改指定编码 String returnData=sendRequestData("telesales",requestData, requestUrl, 3000,3000); } /** * 发送报文 * * @param appName 应用系统英文名 * @param requestData 请求报文 * @param urlStr 请求地址 * @param connectionTimeout 链接超时时间 1000代表 1秒 * @param readTimeout 读取超时时间 1000代表1秒 * @return * @throws IOException * @author King */ private static String sendRequestData(String appName,String requestData, String urlStr, int connectionTimeout,int readTimeout) throws IOException{ URL url = null; HttpURLConnection conn = null; ByteArrayOutputStream byteOut = null; BufferedReader readInfo = null; StringBuffer strBuilder=new StringBuffer(); OutputStream out = null; try { System.out.println("请求时间:【"+new Date()+"】"); System.out.println("请求地址:【"+urlStr+"】"); System.out.println("请求报文:【"+requestData+"】"); url = new URL(urlStr); conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("SOAPAction", "\"\""); conn.setRequestProperty("Accept", "application/soap+xml, application/dime, multipart/related, text/*"); conn.setRequestProperty("content-type", "text/xml;charset=GBK"); conn.setRequestProperty("User-Agent", "Axis/1.4"); conn.setRequestProperty("Cache-Control", "no-cache"); conn.setRequestProperty("appName", "appName");//各系统需要设置应用系统名 appName,如电销为telesales conn.setUseCaches(false); //忽略缓存 conn.setDoOutput(true); //使用 URL 连接进行输出 conn.setDoInput(true); //使用 URL 连接进行输入 conn.setConnectTimeout(connectionTimeout);//链接超时 conn.setReadTimeout(readTimeout);//读取超时 conn.connect();//建立链接 byteOut = new ByteArrayOutputStream(); byteOut.write(requestData.getBytes("GBK"));//以指定编码发送,如果有乱码,修改之 byte[] buf = byteOut.toByteArray(); out = conn.getOutputStream(); out.write(buf); out.flush(); if (HttpURLConnection.HTTP_OK == conn.getResponseCode()) {//正确返回 readInfo = new BufferedReader(new java.io.InputStreamReader(conn.getInputStream(),"GBK"));//以指定编码读取返回信息,如果有乱码,修改之 String line = null; while ((line = readInfo.readLine()) != null) { strBuilder.append(line); } } else {//没有正确返回 throw new IOException("url请求出现问题,返回编码:" + conn.getResponseCode()); } System.out.println("返回时间:【"+new Date()+"】"); System.out.println("返回报文:【"+strBuilder.toString()+"】"); } catch (UnsupportedEncodingException e) { throw e; } catch (MalformedURLException e) { throw e; } catch (IOException e) { throw e; }finally { try{ if (readInfo != null) { readInfo.close(); } if (byteOut != null) { byteOut.close(); } if (out != null) { out.close(); } if (conn != null) { conn.disconnect(); } }catch(Exception e){ System.out.println("关闭链接出错!"+e.getMessage()); } } return strBuilder.toString(); } /** * * @param filePath 文件绝对路径 * @param encoding 读取文件的编码 * @return * @author King * @throws Exception */ public static String readStringFromFile(String filePath,String encoding) { File file = new File(filePath); System.out.println("文件 "+filePath+"存在与否?: "+ file.exists()+"\n"); String tempLine = null; String retStr = ""; InputStreamReader isr = null;//way1: // FileReader fr = null;//way2 StringBuilder sb = new StringBuilder(); try { if(file.exists()){ isr = new InputStreamReader(new FileInputStream(file),encoding);//way1: // fr = new FileReader(file);//way2 BufferedReader br = new BufferedReader(isr);//way1: // BufferedReader br = new BufferedReader(fr);;//way2: tempLine = br.readLine(); while( tempLine != null ){ sb.append(tempLine); tempLine = br.readLine(); } retStr = sb.toString(); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally{ try{ if(isr!=null) isr.close(); }catch(Exception e){ e.printStackTrace(); } } System.out.println("读到的文件内容如下:"); System.out.println(retStr+"\n"); return retStr; } }
打印结果如下:
文件 C:\Users\King\Desktop\connectANSI.xml存在与否?: true 读到的文件内容如下: <?xml version="1.0" encoding="UTF-8"?><PACKET> <HEAD> <SERVICENAME>policyquery</SERVICENAME> <SYSNAME>电销</SYSNAME> <USERCDE>1006751</USERCDE> <DPTCDE>37</DPTCDE> <SYSCODE>02</SYSCODE> <FLOWID>68123ff5-eb74-4f67-b078-52bf437d4650</FLOWID> <SERVICE_NO>0101020101</SERVICE_NO> <BUSFLOWID></BUSFLOWID> <REQUEST_TYPE>0355-01</REQUEST_TYPE> <DATA>A</DATA> <TYPE>I</TYPE> <USERID>50000001</USERID> <PASSWORD>123456</PASSWORD> </HEAD> <BODY> <VHL> <VEHICLE_CATEGORY>345039001</VEHICLE_CATEGORY> <EXTENDED_AREA_RADIUS></EXTENDED_AREA_RADIUS> <CAR_MARK>*</CAR_MARK> <USE_TYPE>345038001</USE_TYPE> <CHK_CDE></CHK_CDE> </VHL> <BASE> <DPT_CDE>33</DPT_CDE> <INSURED_NAME>A君</INSURED_NAME> </BASE></PACKET> 请求时间:【Tue Jun 07 23:34:37 CST 2016】 请求地址:【http://10.15.22.120:8866/4200000001/QueryInputBillAuthenInfo/V1】 请求报文:【<?xml version="1.0" encoding="UTF-8"?><PACKET> <HEAD> <SERVICENAME>policyquery</SERVICENAME> <SYSNAME>电销</SYSNAME> <USERCDE>1006751</USERCDE> <DPTCDE>37</DPTCDE> <SYSCODE>02</SYSCODE> <FLOWID>68123ff5-eb74-4f67-b078-52bf437d4650</FLOWID> <SERVICE_NO>0101020101</SERVICE_NO> <BUSFLOWID></BUSFLOWID> <REQUEST_TYPE>0355-01</REQUEST_TYPE> <DATA>A</DATA> <TYPE>I</TYPE> <USERID>50000001</USERID> <PASSWORD>123456</PASSWORD> </HEAD> <BODY> <VHL> <VEHICLE_CATEGORY>345039001</VEHICLE_CATEGORY> <EXTENDED_AREA_RADIUS></EXTENDED_AREA_RADIUS> <CAR_MARK>*</CAR_MARK> <USE_TYPE>345038001</USE_TYPE> <CHK_CDE></CHK_CDE> </VHL> <BASE> <DPT_CDE>33</DPT_CDE> <INSURED_NAME>A君</INSURED_NAME> </BASE></PACKET>】 返回时间:【Tue Jun 07 23:34:38 CST 2016】 返回报文:【<SOAP-ENV><resultHeader><resultFLag>N</resultFLag><resultMsg>出错信息</resultMsg><recordTotal>记录总数</recordTotal><pageTotal>总页数</pageTotal><pageSize>页大小</pageSize><currentPage>请求页</currentPage></resultHeader></SOAP-ENV>】
时间: 2024-09-30 07:01:54