Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Accept application/json for components of TramoSeats/X13 processing #4

Open
ghost opened this issue Jan 3, 2017 · 4 comments
Open
Assignees
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Jan 3, 2017

I'm working on a web client for jdemeatra-ws, and I encounter some difficulties while retrieving the components of the X13 processing of a given serie.

When requesting the path '/x13 (POST) if I use application/xml for the Accept header, I will get some data in the results, but if I use application/json, I only get what are I guess the component names:

Accept: application/xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<informationSet xmlns="ec/tss.core">
    <item name="sa">
        <tsdata>
            <freq>12</freq>
            <firstYear>1990</firstYear>
            <firstPeriod>3</firstPeriod>
            <data>0.8253386566564 -0.16513714380520267 ...</data>
        </tsdata>
    </item>
    <item name="t">
        <tsdata>
            <freq>12</freq>
            <firstYear>1990</firstYear>
            <firstPeriod>3</firstPeriod>
            <data>0.2853229133715845 0.2395539843284111 ...</data>
        </tsdata>
    </item>
    <item name="s">
        <tsdata>
            <freq>12</freq>
            <firstYear>1990</firstYear>
            <firstPeriod>3</firstPeriod>
            <data>-0.1830618706564 -0.25789857019479734 ...</data>
        </tsdata>
    </item>
    <item name="i">
        <tsdata>
            <freq>12</freq>
            <firstYear>1990</firstYear>
            <firstPeriod>3</firstPeriod>
            <data>0.5400157432848156 -0.40469112813361374  ...</data>
        </tsdata>
    </item>
    <item name="y_f">
        <tsdata>
            <freq>12</freq>
            <firstYear>2016</firstYear>
            <firstPeriod>1</firstPeriod>
            <data>-0.7340849708684167 0.10910697501201583...</data>
        </tsdata>
    </item>
</informationSet>

Accept: application/json

{
  "item": [{ "name": "sa" }, { "name": "t" }, { "name": "s" }, { "name": "i" }, { "name": "y_f" } ]
}

I guess the information we should expect is what we get with application/xml, but the swagger documentation only mention the names:

swagger

I noticed that some paths that should return the same kind of information (/x13/request and x13/requests) only produce application/xml (application/json is not a valid value for these paths), I thought it might be related.

I tried to investigate it a little, but I'm not a java developer so I got lost very quick. I saw that /tsdata which returns some TsData (but not included in an XmlInformatSet) was able to serialize it to json thanks to the class JsonTs, but I was not able to extend this behaviour to the tsData included in an XmlInformationSet.

Sorry if I misunderstood something, and thank you for your help.

@maggima
Copy link
Collaborator

maggima commented Jan 3, 2017

Hello,

Those methods are part of the old version of the xml schemas (mainly used for tests and demo)
The new version (using more complete xml schemas) are under the x13/request(s) and tramoseats/request(s) and provide only xml as input and output.

You can take a look at the examples under the package test (https://github.com/nbbrd/jdemetra-ws/blob/master/demetra-webapp/src/test/java/ec/nbb/demetra/rest/test/X13Test.java) and at the xsd files describing the xml schemas (https://github.com/jdemetra/jdemetra-core/tree/develop/jtss/src/main/resources)

Don't hesitate if you still have questions.

Mats

@ghost
Copy link
Author

ghost commented Jan 3, 2017

Thank you very much Mats, information about the schemas will be very useful (so is the existing swagger documentation).

I was asking because json is a little bit easier to process from javascript. Any plan on supporting it in the future ?

And what about the "Content-type" headers for these paths ? I updated the code to allow these resources to receive json, and it seemed to work (might need further testing). Is it something you could consider ?

    @POST
    @Path("request")
    @Compress
    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    @Produces(MediaType.APPLICATION_XML)

JB

@romaintailhurat
Copy link
Contributor

Hi all

I think it is indeed simple as adding the JSON media type when needed (both in the Consumes and Produces annotation i guess).

If it's okay with you Matts, JB or i could pull the corresponding code.

R

@ghost
Copy link
Author

ghost commented Jan 4, 2017

I'm not sure: I tried it before and it worked for @Consumes, but not for @Produces (I think that the problem was that in json only the component names were returned, not the data. In fact, the same issue that I mentioned with POST /x13 when requesting json).

@maggima maggima self-assigned this Oct 19, 2017
@maggima maggima added the bug label Oct 19, 2017
@maggima maggima added this to the 2.2.1 milestone Oct 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants