REST web-services support

2,249 views
Skip to first unread message

norber...@multimageweb.com

unread,
Dec 5, 2014, 2:04:14 AM12/5/14
to idem...@googlegroups.com
hi,

i found support for REST web-services was added in 2013. here: https://idempiere.atlassian.net/browse/IDEMPIERE-1182

we looking for some docs describe how to use it.

norbert

This e-mail is confidential and may contain legally privileged information. It is intended only for the addressees and may not be reviewed or used in any way by other recipients. If you have received this e-mail in error, kindly notify us immediately by telephone or e-mail and delete the message and any attachments thereto from your system.

Tomáš Švikruha

unread,
Dec 9, 2014, 4:15:01 AM12/9/14
to idem...@googlegroups.com
Hi guys,

I want to share my idea - what if parameters can be send in URL in case of REST web services? e.g. http://localhost:8080/ADInterface/services/rest/model_adservice/create_data?serviceType=C_BPartner&Value=ws815&NamE=WS815-Name... like when you are sending some requests on public API. I think that REST should be more simple than SOAP...current REST implementation not too much different than SOAP, in both cases you have to send XML message with login information etc.

On Saturday, 6 December 2014 17:56:31 UTC+1, Deepak Pansheriya (Logilite.com) wrote:
Norbert,

Please note that iDempiere rest service use XML document not the json.

Below are sample request and url. Hope that will help
You need to use post request

 Create Data
URL: http://localhost:8080/ADInterface/services/rest/model_adservice/create_data
REST request:
<_0:ModelCRUDRequest xmlns:_0="http://idempiere.org/ADInterface/1_0">
            <_0:ModelCRUD>
               <_0:serviceType>1000000</_0:serviceType>
               <_0:TableName>C_BPartner</_0:TableName>
               <!--Optional:-->
               <_0:Action>Create</_0:Action>
               <!--Optional:-->
               <_0:DataRow>
                  <_0:field column="Value">
                        <_0:val>ws815</_0:val>
                      </_0:field>
                  <_0:field column="Name">
                        <_0:val>ws815-name</_0:val>
                      </_0:field>
                  <_0:field column="IsCustomer">
                        <_0:val>Y</_0:val>
                      </_0:field>
                  <_0:field column="IsVendor">
                        <_0:val>Y</_0:val>
                      </_0:field>
            </_0:DataRow>
            </_0:ModelCRUD>
            <_0:ADLoginRequest>
               <_0:user>WebService</_0:user>
               <_0:pass>password</_0:pass>
               <_0:lang>en_US</_0:lang>
               <_0:ClientID>11</_0:ClientID>
               <_0:RoleID>50004</_0:RoleID>
               <_0:OrgID>11</_0:OrgID>
               <_0:WarehouseID>103</_0:WarehouseID>
            </_0:ADLoginRequest>
         </_0:ModelCRUDRequest>
         
 Composite service
URL: http://localhost:8080/ADInterface/services/rest/composite_service/composite_operation
REST Request:
<_0:CompositeRequest xmlns:_0="http://idempiere.org/ADInterface/1_0">
  <_0:ADLoginRequest>
    <_0:user>WebService</_0:user>
    <_0:pass>password</_0:pass>
    <_0:lang>en_US</_0:lang>
    <_0:ClientID>11</_0:ClientID>
    <_0:RoleID>50004</_0:RoleID>
    <_0:OrgID>11</_0:OrgID>
    <_0:WarehouseID>103</_0:WarehouseID>
  </_0:ADLoginRequest>
  <_0:serviceType>SyncOrder</_0:serviceType>
  <_0:operations>
    <_0:operation>
      <_0:TargetPort>createUpdateData</_0:TargetPort>
         <_0:ModelCRUD>
      <_0:serviceType>CreateUpdateUser</_0:serviceType>
      <_0:TableName>AD_User</_0:TableName>
      <_0:RecordID>1000181</_0:RecordID>
      <_0:Action>CreateUpdate</_0:Action>
      <!--Optional:-->
      <_0:DataRow>
         <_0:field column="Name">
            <_0:val>rest-user-1</_0:val>
         </_0:field>
         <_0:field column="EMail">
            <_0:val>rest-user-1@rest.com</_0:val>
         </_0:field>
         <_0:field column="C_BPartner_ID">
            <_0:val>1000286</_0:val>
         </_0:field>
         <_0:field column="Phone">
            <_0:val>5252552553</_0:val>
         </_0:field>
      </_0:DataRow>
   </_0:ModelCRUD>
    </_0:operation>
    <_0:operation preCommit="false" postCommit="false">
      <_0:TargetPort>createUpdateData</_0:TargetPort>
         <_0:ModelCRUD>
      <_0:serviceType>CreateUpdateUser</_0:serviceType>
      <_0:TableName>AD_User</_0:TableName>
      <_0:RecordID>1000181</_0:RecordID>
      <_0:Action>CreateUpdate</_0:Action>
      <!--Optional:-->
      <_0:DataRow>
         <_0:field column="Name">
            <_0:val>rest-user-1</_0:val>
         </_0:field>
         <_0:field column="EMail">
            <_0:val>rest-user-2@rest.com</_0:val>
         </_0:field>
         <_0:field column="C_BPartner_ID">
            <_0:val>1000286</_0:val>
         </_0:field>
         <_0:field column="Phone">
            <_0:val>5252552555</_0:val>
         </_0:field>
      </_0:DataRow>
   </_0:ModelCRUD>
    </_0:operation>
  </_0:operations>
</_0:CompositeRequest>

norber...@multimageweb.com

unread,
Dec 9, 2014, 5:51:38 AM12/9/14
to idem...@googlegroups.com
hi,

I found this - for me looks interesting.


at this moment our goal is: send notification message from amazon aws/sns to idempiere, where message format generated by amazon SNS is given so we need parse it. But in first step to catch call without reading Json would be also helpful.


norbert

Deepak Pansheriya (Logilite.com)

unread,
Dec 6, 2014, 11:56:31 AM12/6/14
to idem...@googlegroups.com

Gerald O'Sullivan

unread,
Sep 14, 2017, 2:02:35 AM9/14/17
to iDempiere
Hi Norbert

Did you have any luck using REST web services? To be honest, there does not seem to be any difference to SOAP requests when it comes to use-of-use. Everything is still XML. 

Best
Gerald

Vasanth s

unread,
Sep 14, 2017, 2:43:51 AM9/14/17
to iDempiere
Hi Gerald,

I have used idempiere REST web services successfully in an Ionic project. if you are using client side technologies like angular, typescript, jquery, js, it is easier to consume the REST than SOAP. 
the XML format of the request and responses are same like SOAP, the protocol is different.

sample typescript code in GitHub

norber...@multimageweb.com

unread,
Sep 14, 2017, 9:33:19 AM9/14/17
to iDempiere
hi,

ATM we are doing the next
1. we have AWS Lambda jar which transform SOAP to JSON then route to AWS API GW -> this api is true rest/json
2. we have improved replication engine able to produce JSON instead XML. we are able to produce/consume JSON to/from replication - actually we use AWS SQS messaging service or we are able with a special replication process start to generate json then return back to SOAP request where body= JSON. (will be parsed/transformed by lambda well)
3. we create an oauth2 process with ATK, RTK mechanism according to spec - atm our token generator is AWS Cognito/STS. this allow to use authenticated webservice.

some people using nginx for api gw building instead write a new rest service.
probably this is not the best way, however help us understand what we require for build a serious API gateway. 

there are lot requirements some of them... 1. able to define proxy/api version 2. ability to define export/import format including export format version (like in existing replication IMHO can be reused or can be a good starting point) 3. ability to define HTTP Codes/reqexp by response content (what when etc... http://www.restapitutorial.com/lessons/httpmethods.html) 4. how to run processes well and much more. 

In my opinion a new API gateway must be implemented with serious really modern javascript approach. this is because lot js libraries require really native/true json format - including datatypes.
in our case we are writing an ionic client for our clients. our js developer reject work with SOAP in js/ts.

i have a design in my mind and if we found funds/time then we can define project and realise this really important feature - this will touch core - we need community support.

there are some concepts on the internet like jersey rest library - for me the biggest challenge is how to make the implementation generic.

norbert

Gerald O'Sullivan

unread,
Sep 14, 2017, 11:39:58 AM9/14/17
to iDempiere
Hi Vasanth

Many thanks for the prompt response and it is encouraging to hear that it worked well in your Ionic project. We are also using Javascript frameworks, mainly Angular and Apache Cordova, which is why we were interested in the RESTful approach. 

I am looking forward to digging into your typescript code and will give feedback accordingly.

Kind regards
Gerald

Gerald O'Sullivan

unread,
Sep 14, 2017, 12:01:14 PM9/14/17
to iDempiere
Hi Norbert

Thanks for the pointers. I totally agree with you that iDempiere will benefit from a new API gateway and I would be very happy to devote time and energy to that initiative. I played around with Dropwizard (which is based on Jersey) to generate the endpoints, which is fine for simple queries, but any serious solution needs deep integration with the core to re-use the functionality and business logic embedded in the core classes (run processes, initiate workflow, implement role-based access control and so on). 

I would be interested in taking this further as there seems to be enough interest to work on a generic solution.

Kind regards
Gerald

Habib Salhi

unread,
Sep 8, 2018, 7:00:55 AM9/8/18
to iDempiere
HI Tomas... did u ever manage to create a REST webservice with parameters like you suggested ?
Reply all
Reply to author
Forward
0 new messages