Kinson Sa
Posts: 0
Joined: Sun Mar 22, 2015 9:40 pm

Query in an XML file restAPI?

Hi to all,
first sorry about my english as it is so pour.

I have a problem and I would like if someone can help me.

I have a rest to an XML, everything is correct, I get all information. And I show in a list

The main problem is when I want to make a query. As my salesman have a code and when they get in customer page, I just want they see their customers. AND XML file have all customers inside. I want to make query by salesman.

I check all documentation and everything works in JSON and in Appery DB,( I can make queries) but in a XML file I try it and nothing at all.

Is there any way to do it easily, as I'm not an expert.

Thanks in advance.

Kinson Sa
Posts: 0
Joined: Sun Mar 22, 2015 9:40 pm

Query in an XML file restAPI?

Dear friends,

Nothing to do? I will have to do it in Java I supouse. But my Java is in just nearly zero.

If anyone can help me to do it It will be so apreciate.

Thanks

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Query in an XML file restAPI?

Hi Kinson,

Im not sure i've understand your problem correctly.

Here is how i undrestand it:

  1. You have external XML api(returns some XML).

  2. This XML api can not filter items(did you check it with this API provider, may be there is some request parameters that you should to add to get it filtering)

  3. You want to filter this XML file content by some logic.

    If so - best way to do it on API side.(please contact API provider and ask about this functionalitiy you need).

    If this functionality could not be implemented with API parameters - you can transform returned object with your own client-side logic.

    For this goal - you need to add "Success" event handler. And order this handler to be BEFORE the mapping event handler.
    Details: http://prntscr.com/6lg42v/direct

    Then you should modify request object passed to the event handler as "data" variable in way you need.

    Regards.

Kinson Sa
Posts: 0
Joined: Sun Mar 22, 2015 9:40 pm

Query in an XML file restAPI?

Dear Yurii, thanks for your reply.

I'm the api provider, what I do is just make SQL sentence to the ERP database and make and XML file posted in my cloud hosting, then From Appery I call to this XML to get all data. So I can make what ever I want with the XML file. SO if you have any web that explain how to include filter in the xml, I have check some but as I've not a lot of idia about that.It is hard to me. If you told to me the simple way to make filter is in the XML I can do, just I need to know what I have to include in the XML file.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Query in an XML file restAPI?

Hi Kinson,

Sorry for late response.

Okay, you need to show only their customers(items).

For this goal you should have:

  1. current salesman "id"(or other unique identifier).

  2. in customers table you should have "salesman_id" field.

  3. able to retrieve request parameters to this HTTP-handler(that returns your XML).

    -------------------

  4. Then you can pass current salesman "id" as request parameter:
    4.1. Open service.
    4.2. Navigate to "request" tab.
    4.3. Open "query string" tab.
    4.4. Add "sales_man_id" request parameter.

  5. On needed page pass certain value to "sales_man_id" service request parameter.
    5.1. Open needed page.
    5.2. Navigate to "Data" tab.
    5.3. Click "before send" mapping for the needed datasource.
    5.4. Pass needed value to "sales_man_id" request parameter(you can do it from some storage or page component value).

    Regards.

Kinson Sa
Posts: 0
Joined: Sun Mar 22, 2015 9:40 pm

Query in an XML file restAPI?

Dear Yurri,

Thanks for the information I'm on it. Let's see if it is better to able the request parameters or just try to make a filter (as I have all customers in a model) before send them to the list with a simple JS.

I will tell you something soon, maybe I will need a litle help on the filtering the model.

Thanks

Kinson Sa
Posts: 0
Joined: Sun Mar 22, 2015 9:40 pm

Query in an XML file restAPI?

Dear Yurii,

Please I think it will be imposible to make query in the xml file. So about the other way to do it with JS. I need litle bit help as I'm not very proffesional.

The way is I make model and storage for customers, that means I have all customers in a model.

ListaCliente, with Name, Adress, vendor.

Now when my vendor login I get his number for example 21. So I need just to get from the model the customers that has 21 in the vendor parameter of the model.

Can you help me please, as all my app will be with this problem.

Thanks in advance.

Pedro

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Query in an XML file restAPI?

Hi Kinson,

Yes you can filter it on the client part.

Here is a brief plan to achieve this goal:

  1. Add service datasource success event handler.

  2. Order this event handler to be before "mapping".
    Details: http://prntscr.com/6rf3vv/direct

  3. In this event handler - you can edit(filter service response).

    Regards.

Kinson Sa
Posts: 0
Joined: Sun Mar 22, 2015 9:40 pm

Query in an XML file restAPI?

Dear Yurii,

Yes I underestand that here I can make JS, but How I filter this handle.

It is possible to have an example.

If from this XML I have node/node1/customer_name and node/node1/vendor as a response, what I have to but in the JS to filter just with vendor = 21

Thanks.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Query in an XML file restAPI?

Hi Kinson,

Please show us example of your service.

Regards.

Return to “Issues”