2017年3月10日金曜日

[iDedempiere 2.1] Web Service


 iDempiere 2.1 provide Web Service (WS) interfaces over SOAP and REST. The user can use the WS in order to create, update and view the Records in DB Table.

ModelADService - It can be used for view Records and  Simple Record edition.
CompositeInterface - It can be used for Multiple Record edition.

○ Environment:

[iDempiere]
    Version: 2.1
 [Eclipse]
     Pleiades 4.5 Mars
  [OS]
     Windows 7 SP1

○ Setting Web Service on iDempiere

 The WS is working on iDempiere if iDempiere is installed already. But, "Web Service Security" Record is need to be created to allow the user to access WS on iDempiere. Web Service Security is managed depending on Client as well as other Record in iDempiere. So, Client Admistrator must create Web Service Security Record with the Client in order to allow members in the Client to access WS.
 If you test WS by Garden Client, you don't have to prepare Web Service Security Record by yourself because these exist already. The examples following use
"CreateBPartner".

○SoapUI

 Adempire and iDempiere have test scripts to test WS in org.adempiere.webservice package. Soap UI is the application to test WS over SOAP and REST, which is introduced in Adempiere book in order to execute these test scripts in Adempiere.
 The latest version of Soap UI can be downloaded here. Test scripts in iDempiere are created by former version, but these can be executed by the latest version as well.

○Test WS over SOAP

 Test WS over SOAP can be done by test scripts. 

1. Import SOAP project from the script in iDempiere (%iDempiere_Home%\org.idempiere.webservices\testScripts\iDempiereWebServices-soapui-project.xml)

      


2. Edit SOAP XML.
 Open XML for createData

And edit the following fields under "_0:ADLoginRequest" to fit your environment if it is needed.
  1. _0:user
  2. _0:pass
  3. _0:ClientID
  4. _0:OrgID
  5. _0:WarehouseID
  6. _0:stage

2. Edit SOAP XML.
3.  Click Submit button to execute the test script.


○Test WS over REST

 iDempiere provides REST interfaces also. the REST provided by iDempiere recieves XML as request, not JSON. The request XML is as same as XML request in SOAP request.
 REST request also can be sent by Soap UI. But, there is no test scripts for REST in iDempiere now. The user need to create project and request record in Soap UI by themselves to execute WS over REST test.

1. Create REST project on Soap UI.
   URL: http://localhost:8080/ADInterface/services/rest/model_adservice/create_data




2.  Create new POST method under new REST project.

3.  Create new Request under POST method.


Set Media Type: application/xml
Set XML following as POST data. edit tags under "_0:ADLoginRequest" tag to fit your environment if it is needed as SOAP test.

<_0:ModelCRUDRequest xmlns:_0="http://idempiere.org/ADInterface/1_0">
 <_0:ModelCRUD>
  <_0:serviceType>CreateBPartner</_0:serviceType>
  <_0:TableName>C_BPartner</_0:TableName>
  <!--<_0:RecordID>0</_0:RecordID>-->
  <!--<_0:Action>Create</_0:Action>-->
  <_0:DataRow>
   <_0:field column="Value">
    <_0:val>GlobalQSS</_0:val>
   </_0:field>
   <_0:field column="Name">
    <_0:val>Quality Systems &amp; Solutions</_0:val>
   </_0:field>
   <_0:field column="TaxID">
    <_0:val>830.085.359-4</_0:val>
   </_0:field>
   <_0:field column="IsVendor">
    <_0:val>Y</_0:val>
   </_0:field>
   <_0:field column="IsCustomer">
    <_0:val>N</_0:val>
   </_0:field>
   <_0:field column="IsTaxExempt">
    <_0:val>N</_0:val>
   </_0:field>
   <_0:field column="Name2">
    <_0:val>QSS Ltda. - http://www.globalqss.com</_0:val>
   </_0:field>
   <_0:field column="C_BP_Group_ID">
    <_0:val>104</_0:val>
   </_0:field>
  </_0:DataRow>
 </_0:ModelCRUD>
 <_0:ADLoginRequest>
  <_0:user>WebService</_0:user>
  <_0:pass>WebService</_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:stage>9</_0:stage>
 </_0:ADLoginRequest>
</_0:ModelCRUDRequest>

4.  Click Submit button to execute the test script.



     Response XML is displayed in the right pane.
   

○ Reference:

1. http://ultra00.hatenablog.com/entry/2013/11/18/114542
2. https://groups.google.com/forum/#!topic/idempiere/82cXxgq_Qh4





0 件のコメント:

コメントを投稿