ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Wiedmann <jochen.wiedm...@gmail.com>
Subject Re: generate String data type for dateTime.iso8601 rather than a date
Date Mon, 02 Dec 2013 14:59:20 GMT
Quoting one of the unit tests, namely
org.apache.xmlrpc.test.CustomTypesTest.testCustomDateFormat:

        final DateFormat format = new SimpleDateFormat("yyyy-MM-dd
HH:mm:ss.SSS");
        XmlRpcClient client = pProvider.getClient();
        XmlRpcClientConfigImpl config = getConfig(pProvider);
        client.setConfig(config);
        TypeFactory typeFactory = getCustomDateTypeFactory(client, format);
        client.setTypeFactory(typeFactory);
        Calendar cal1 = Calendar.getInstance();
        XmlRpcRequest request = new XmlRpcClientRequestImpl(config,
"DateConverter.tomorrow", new Object[]{cal1.getTime()});
        final String got = XmlRpcTestCase.writeRequest(client, request);
        final String expect = "<?xml version=\"1.0\"
encoding=\"US-ASCII\"?>"
            + "<methodCall><methodName>DateConverter.tomorrow</methodName>"
            + "<params><param><value><dateTime.iso8601>" +
format.format(cal1.getTime())
            + "</dateTime.iso8601></value></param></params></methodCall>";
        assertEquals(expect, got);

As you can see, the magic is done in client.setTypeFactory.


Jochen


On Sun, Dec 1, 2013 at 5:54 PM, zeyad farouk <zeyadfarouk@gmail.com> wrote:

> Hello Jochen,
> Thanks so much for the quick response, however i couldn't figure out how
> that can help to read the dateTime.iso8601 value as a string at the client
> side (actually we don't have control over the server side).
> Could you please help with an example on how to override the default
> package implementation and read the  dateTime.iso8601 as string rather than
> a date.
>
> Thanks so much in advance
> Zeyad
>  On Dec 1, 2013 6:29 PM, "Jochen Wiedmann" <jochen.wiedmann@gmail.com>
> wrote:
>
>> See
>>  http://ws.apache.org/xmlrpc/advanced.html
>> section on "Custom data types".
>>
>>
>>
>> On Sun, Dec 1, 2013 at 5:08 PM, zeyad farouk <zeyadfarouk@gmail.com>wrote:
>>
>>> Hello gurus,
>>> how can we generate a string data type for dateTime.iso8601 rather than
>>> date data type ? or how to enforce the library to return the  exact XML tag
>>> date value without any timezone change/adaptation to the local timezone ?
>>>
>>> thanks for your quick help,
>>> Zeyad
>>>
>>
>>
>>
>> --
>> "That's what prayers are ... it's frightened people trying to make
>> friends with the bully!"
>>
>> Terry Pratchett. The Last Hero
>>
>>


-- 
"That's what prayers are ... it's frightened people trying to make friends
with the bully!"

Terry Pratchett. The Last Hero

Mime
View raw message