如何在Java 1.6中获得Apache XML-RPC 3.1.3合规性(ISO日期格式以及时区) [英] How to get Apache XML-RPC 3.1.3 compliance (ISO date format along with time zone) in Java 1.6

查看:226
本文介绍了如何在Java 1.6中获得Apache XML-RPC 3.1.3合规性(ISO日期格式以及时区)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用Apache XML-RPC 3.1.3与Air计费解决方案进行通信。在文档中,它提到apache xml-rpc跟随日期格式为java.util.Date'19980717T14:08:55',但我们的供应商实现日期为'yyyyMMdd'T'HH:mm:ssZ'添加时区:(

We are using Apache XML-RPC 3.1.3 to communicate with Air billing solution. In documentation its mentioned that apache xml-rpc follow date format as java.util.Date '19980717T14:08:55' but our vendor implemented date as 'yyyyMMdd'T'HH:mm:ssZ' addition with time zone :(

审阅文档后,我们知道,我们需要开发自定义数据类型以使用ISO不同的日期格式。
http://ws.apache.org/xmlrpc/faq.html#nonstandard_date_format
我们试图继续提供的例子,但最终有两个错误

After reviewing documentation we come to know that, we need to develop custom data type to work with ISO different date format. http://ws.apache.org/xmlrpc/faq.html#nonstandard_date_format We tried to continue with provided example but end up with two errors

1 - 在MyTypeFactory.java类中找不到pFormat变量

1 - pFormat variable not found in MyTypeFactory.java class

2 - 在客户端类中指定这些更改时找不到构造函数
client.setTypeFactory(new MyTypeFactory());

2 - no constructor found while pointing these changes in client class client.setTypeFactory(new MyTypeFactory());

如果我们缺少任何内容,有人可以更正我们或共享任何其他方式在Apache XML-RPC 3.1.3中实现自定义数据类型

Can someone please correct us if we are missing anything or share any other way to implement custom datatypes in Apache XML-RPC 3.1.3

我们的客户端类代码是



Our client class code is

XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
        config.setServerURL(new URL("http://10.x.x.x:1234/Air"));
        config.setEnabledForExceptions(true);
        config.setBasicUserName("myUser");
        config.setBasicPassword("myPassword");
        config.setEncoding(XmlRpcClientConfigImpl.UTF8_ENCODING);

        config.setReplyTimeout(3 * 1000);
        config.setUserAgent("ITIVR/4.3/1.0"); //3.1 or 4.3
        client.setConfig(config);

        XmlRpcClient client = new XmlRpcClient();
        XmlRpcSunHttpTransport http = (XmlRpcSunHttpTransport) new XmlRpcSunHttpTransportFactory(client).getTransport();            

        Hashtable request = new Hashtable();
        request.put("originNodeType", new String("IVR"));
        request.put("originHostName", new String("ITIVR"));
        request.put("originTransactionID", new String(new SimpleDateFormat("ddMMyyyyHHmmss").format(new Date())));
        request.put("originTimeStamp", new Date());
        request.put("subscriberNumber", "0111111111");

        Vector v = new Vector();
        v.add(request);

        HashMap o =    (HashMap) http.sendRequest(new XmlRpcClientRequestImpl(config, "GetBalanceAndDate", v));

在这段代码中,我们收到错误'数据超出范围',因为我们没有传递日期无效格式。

In this code we are getting error 'Data out of bounds' because we are not passing date in invalid format.

推荐答案

在审阅文档后,我们来了解其日期格式相关问题。 Apache XML-RPC默认日期格式没有时区,Air计费解决方案(爱立信CS 5.1)同时接收日期。

After reviewing documentations we come to know that, its date format related issue. Apache XML-RPC default date format is without time zone and Air billing solution(Ericsson CS 5.1) accept date along with time zone.

我们已经解决了上述两个问题

We have fixed above both problems

错误1 - 通过在SimpleDateFormat中添加新格式,并在MyTypeFactory类中将newFormat()替换为pFormat class

Error 1 - By adding new format in SimpleDateFormat and replacing pFormat with newFormat() in MyTypeFactory class

错误2 - 通过在构造函数中传递XmlRpcClient对象,因为XmlRpcClient是XmlRpcServer和XmlRpcClient的低音类:)
eg

Error 2 - By passing XmlRpcClient object in constructor, because XmlRpcClient is bass class of XmlRpcServer and XmlRpcClient :) e.g.

client.setTypeFactory(new MyTypeFactory(client));

这篇关于如何在Java 1.6中获得Apache XML-RPC 3.1.3合规性(ISO日期格式以及时区)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆