银企直联前置机企业接入Javasocket

编程

银企直联一般都是通过前置机与银行服务进行通信,企业服务 前置机 银行三者关系如下 

在企业应用在这里就相当于客户端,前置机就相当服务端
ERP 与 CT 之间的交易数据报文采用 TCP/IP 协议的 Socket 同步短连接方式。

这里有个ERP 与 CT 通信的简单的demo

import java.io.*;

import java.net.Socket;

import java.net.UnknownHostException;

/**

* @Title:

* @Description: 接收第三方--->发送前置机--->接收前置机--->发送第三方 等步奏

* @Created by yangjie on 2020/5/19/14:23.

*/

public class SocketDemo {

public static void main(String[] args) {

Socket socket = null;

OutputStream outputStream = null;

InputStream inputStream = null;

BufferedReader bufferedReader = null;

try {

socket = new Socket("192.168.13.51", 10010);

String reqNo = "ly0000"+ DateUtil.getDateStr();

String pay_acno = ""; // 付款账号

String pay_acname = ""; // 付款户名

String xml01 = "<ap>n" +

" <head>n" +

" <tr_code>416B300002</tr_code>n" +

" <cms_corp_no></cms_corp_no>n" +

" <req_no>"+reqNo+"</req_no>n" +

" <tr_acdt>"+ DateUtil.getDateStrNoSSS() +"</tr_acdt>n" +

" <tr_time>"+DateUtil.getTimeStrSSS()+"</tr_time>n" +

" <channel>5</channel>n" +

" <sign>1</sign>n" +

" <file_flag>0</file_flag>n" +

" <Reserved1></Reserved1>n" +

" <Reserved></Reserved>n" +

" </head>n" +

" <body>n" +

" <pay_acno>"+pay_acno+"</pay_acno>n" +

" <vir_acno></vir_acno>n" +

" <vir_acname></vir_acname>n" +

" <batch_no>"+reqNo+"</batch_no>n" +

" <supply_item>1001</supply_item>n" +

" </body>n" +

"</ap>";

System.out.println("请求报文:rn" + xml01);

outputStream = socket.getOutputStream();

outputStream.write(xml01.getBytes());

outputStream.flush();

inputStream = socket.getInputStream();

bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"GBK") );

String readData = null;

System.out.println("响应报文:rn");

while ((readData = bufferedReader.readLine()) != null) {

System.out.println(readData);

}

} catch (UnknownHostException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

} finally {

try {

if (outputStream != null)

outputStream.close();

if (bufferedReader != null)

bufferedReader.close();

if (inputStream != null)

inputStream.close();

if (socket != null)

socket.close();

} catch (IOException exception) {

exception.printStackTrace();

}

}

}

}

 

以上是 银企直联前置机企业接入Javasocket 的全部内容, 来源链接: utcz.com/z/516837.html

回到顶部