我正在尝试使用以下代码向终端发送 ISO8583 请求:
try {
XMLParser packager = new XMLParser(this.xmlFile);
final ISOMsg isoMsg = new ISOMsg();
isoMsg.setPackager(packager);
isoMsg.setMTI("0800");
isoMsg.set(3, "xxxxxx");
isoMsg.set(7, "xxxxxxxxxx"); //MMDDhhmmss
isoMsg.set(11, "xxxxxx");
isoMsg.set(12, "084500"); //Time of the message HHmmss
isoMsg.set(13, "0621"); //Date MMDD
isoMsg.set(41, "xxxxxxxx");
isoMsg.set(62,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
isoMsg.set(63,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
BaseChannel channel = new BaseChannel() {};
channel.setLogger(logger, "server-request-channel");
channel.setHeader(isoMsg.pack());
channel.setHost("xx.xx.xx.xx", xxxxx);
ISOMUX isoMux = new ISOMUX(channel) {
@Override
protected String getKey(ISOMsg m) throws ISOException {
return super.getKey(m);
}
};
isoMux.setLogger(logger, "server-request-mux");
new Thread(isoMux).start();
ISORequest req = new ISORequest(isoMsg);
isoMux.queue(req);
req.setLogger(logger, "server-request-logger");
ISOMsg response = req.getResponse(50 * 1000);
if (response != null) {
System.out.println("Req ["+ new String(isoMsg.pack()) + "]");
System.out.println("Res ["+ new String(response.pack()) + "]");
}else{
System.out.println("Timeout");
}
}catch (Exception e) {
e.printStackTrace();
}
}
执行代码后,出现以下异常:
<log realm="server-request-mux" at="Fri Aug 14 00:26:43 WAT 2015.995">
<muxreceiver>
<exception name="null">
java.lang.NullPointerException
at org.jpos.iso.BaseChannel.createISOMsg(BaseChannel.java:561)
at org.jpos.iso.BaseChannel.createMsg(BaseChannel.java:558)
at org.jpos.iso.BaseChannel.receive(BaseChannel.java:585)
at org.jpos.iso.ISOMUX$Receiver.run(ISOMUX.java:263)
at java.lang.Thread.run(Thread.java:856)
</exception>
</muxreceiver>
</log>
我加了断点是为了找出引起异常的那一行,发现只要遇到语句就会异常:
ISORequest req = new ISORequest(isoMsg);
我对 ISO8583 jpos 金融编程比较陌生,我想在 android 平台上构建一个应用程序。
我如何克服这个异常?
最佳答案
您不能创建 BaseChannel 的实例——它是一个抽象类 (see it on GitHub)。
如果您只想将 XML 格式的 ISO-8583 消息发送到端点并等待响应,您可以这样做:
XMLPackager packager = new XMLPackager();
XMLChannel channel = new XMLChannel("localhost", 11000, packager);
channel.setPackager(packager);
channel.setTimeout(30000);
channel.connect();
Date now = new Date();
ISOMsg m = new ISOMsg();
m.setMTI("2100");
m.set("3", "000000");
m.set(new ISOAmount(4, 840, new BigDecimal(10.00)));
m.set("7", ISODate.formatDate(now, "MMddHHmmss"));
m.set("11", "1111");
m.set("12", ISODate.formatDate(now, "yyyyMMddHHmmss"));
m.set("22", "KEY.UNK.ECO.APP");
m.set("26", "5999");
m.set("27", "00100000000000001000000000000000");
m.set("32", "00000000001");
m.set("41", "59991515");
m.set("42", "888000003518");
m.set("43.2", "Shegda Electronics");
m.set("43.4", "Richardson");
m.set("43.5", "TX");
m.set("43.6", "63105");
m.set("43.7", "USA");
m.set("49.1", "1");
m.set("49.3", "121 First Street");
m.set("49.4", "85284");
m.set("104.4", "1");
channel.send(m);
ISOMsg resp = channel.receive();
关于java - 发送 ISO8583 请求时出现 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32000246/
我正在用Ruby编写一个简单的程序来检查域列表是否被占用。基本上它循环遍历列表,并使用以下函数进行检查。require'rubygems'require'whois'defcheck_domain(domain)c=Whois::Client.newc.query("google.com").available?end程序不断出错(即使我在google.com中进行硬编码),并打印以下消息。鉴于该程序非常简单,我已经没有什么想法了-有什么建议吗?/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
在我的Controller中,我通过以下方式在我的index方法中支持HTML和JSON:respond_todo|format|format.htmlformat.json{renderjson:@user}end在浏览器中拉起它时,它会自然地以HTML呈现。但是,当我对/user资源进行内容类型为application/json的curl调用时(因为它是索引方法),我仍然将HTML作为响应。如何获取JSON作为响应?我还需要说明什么? 最佳答案 您应该将.json附加到请求的url,提供的格式在routes.rb的路径中定义。这
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
我需要检查DateTime是否采用有效的ISO8601格式。喜欢:#iso8601?我检查了ruby是否有特定方法,但没有找到。目前我正在使用date.iso8601==date来检查这个。有什么好的方法吗?编辑解释我的环境,并改变问题的范围。因此,我的项目将使用jsapiFullCalendar,这就是我需要iso8601字符串格式的原因。我想知道更好或正确的方法是什么,以正确的格式将日期保存在数据库中,或者让ActiveRecord完成它们的工作并在我需要时间信息时对其进行操作。 最佳答案 我不太明白你的问题。我假设您想检查
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file
rails中是否有任何规定允许站点的所有AJAXPOST请求在没有authenticity_token的情况下通过?我有一个调用Controller方法的JqueryPOSTajax调用,但我没有在其中放置任何真实性代码,但调用成功。我的ApplicationController确实有'request_forgery_protection'并且我已经改变了config.action_controller.consider_all_requests_local在我的environments/development.rb中为false我还搜索了我的代码以确保我没有重载ajaxSend来发送
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
我只想对我一直在思考的这个问题有其他意见,例如我有classuser_controller和classuserclassUserattr_accessor:name,:usernameendclassUserController//dosomethingaboutanythingaboutusersend问题是我的User类中是否应该有逻辑user=User.newuser.do_something(user1)oritshouldbeuser_controller=UserController.newuser_controller.do_something(user1,user2)我
什么是ruby的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht