工行API查询接口 JAVA

Senge880711 2013-04-25 03:57:00
最近调个工行的API查询,工行提供了个JKS证书,同时提供了4个JAVA类,我运行JAVA类里面的main方法,但是报了个错Untrusted Server Certificate Chain(证书不被信任),然后我在浏览器上装了相关证书,用form表单提交,就能够收到返回信息,但是通过main方法运行还是不行。工行的联调人员也说不出个所以然。求哪位大神做过工行的API查询的进来下,帮忙看看.
FROM提交,只要装上工行提供的PFX,CRT证书就可以查询
<Form id=form1 action="https://corporbank3.dccnet.com.cn/servlet/ICBCINBSEBusinessServlet" method=post>
<input type=hidden name="APIName" value="EAPI">
<input type=hidden name="APIVersion" value="001.001.001.001">
<input type=hidden name="MerReqData" value="<?xml version='1.0' encoding='GBK' standalone='no'?><ICBCAPI><in><orderNum>2013041237549012</orderNum><tranDate>20130502</tranDate><ShopCode>1202EC13482192</ShopCode><ShopAccount>1202020419900157535</ShopAccount></in></ICBCAPI>">
<input type="submit" value="查询">
</Form>
main方法也是工行提供
public static void main(String[] args) throws Exception {
String path = "file:"
+ ICBCUtil.class.getClassLoader().getResource("icbc/my.jks")
.getPath();
Protocol authhttps = new Protocol("https",
new AuthSSLProtocolSocketFactory(new URL(path), "12345678",
new URL(path), "12345678"), 8443);
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost("corporbank3.dccnet.com.cn", 443,
authhttps);
PostMethod httpget = new PostMethod("/servlet/ICBCINBSEBusinessServlet");
httpget.setParameter("APIName", "EAPI");
httpget.setParameter("APIVersion", "001.001.001.001");
httpget
.setParameter(
"MerReqData",
"<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"no\" ?><ICBCAPI><in><orderNum>2013041237549012</orderNum><tranDate>20130502</tranDate><ShopCode>1202EC13482192</ShopCode><ShopAccount>1202020419900157535</ShopAccount></in></ICBCAPI>");
client.executeMethod(httpget);
String str = java.net.URLDecoder.decode(httpget
.getResponseBodyAsString(), "GB2312");
System.out.println("server responding code :"
+ httpget.getStatusLine().toString());
System.out.println("server responding body :"
+ httpget.getResponseBodyAsString());
System.out.println("server responding body :" + str);
}
}

但是报错
Exception in thread "main" javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Untrusted Server Certificate Chain
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1591)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:187)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:181)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1035)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:124)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1096)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:623)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:502)
at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1973)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
at com.ai.tss.util.icbc.SSLSendAndRec.main(SSLSendAndRec.java:52)
Caused by: java.security.cert.CertificateException: Untrusted Server Certificate Chain
at com.sun.net.ssl.X509TrustManagerJavaxWrapper.checkServerTrusted(SSLSecurity.java:600)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1027)
... 17 more


...全文
790 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
huasuoworld 2014-09-03
  • 打赏
  • 举报
回复
这个不是API的问题吧,你注册下Protocol.registerProtocol("https", authhttps);
jiaxuyx 2014-09-03
  • 打赏
  • 举报
回复
也在为这个问题纠结,工行的接口实在受不了了,问他们技术人员什么都不知道。
Meng_Dabao 2014-08-28
  • 打赏
  • 举报
回复
我也是遇到这个问题来着...你们的都是怎么解决的呢?
h羁绊y 2014-06-11
  • 打赏
  • 举报
回复
您好,请问你这个问题解决了吗?我最近做他们的接口也遇到这个问题了!
zhang7816266 2013-09-22
  • 打赏
  • 举报
回复
支付的代码可以借我看看吗? 谢谢啦。 我的邮箱是 xiaojie.zhang@lefu8.com
老杨与小冬冬 2013-07-24
  • 打赏
  • 举报
回复
我也遇到这个问题,请问解决了没有,楼主
eva841205 2013-07-23
  • 打赏
  • 举报
回复
你好,我也遇到了这个问题,根证书和pfx证书都导入了,使用HTTPClient访问工行API查询接口,返回CertificateException: Untrusted Server Certificate Chain。 请问你这个问题解决了吗?
Senge880711 2013-04-25
  • 打赏
  • 举报
回复
912649326 可加我QQ

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧