User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:adminmanual:businessmappings:webservicecall [2019/12/16 00:58]
joebordes
en:adminmanual:businessmappings:webservicecall [2021/03/22 18:11] (current)
joebordes [wsconfig]
Line 25: Line 25:
   * wsuser and wspass in case the service uses these   * wsuser and wspass in case the service uses these
   * wsheader contain keyname and keyvalue pairs with information that must be sent in the header of the call   * wsheader contain keyname and keyvalue pairs with information that must be sent in the header of the call
 +    * header keyvalue will be processed in search of the command **getContext(variable_name)** or **getSetting(variable_name)** (note that there are no quotes around the variable name). This expression will search for the variable_name in the workflow context or the coreBOS key-value store and use that instead of the hardcoded value which can be set here also.
   * <​wstype>​REST or SOAP</​wstype>​   * <​wstype>​REST or SOAP</​wstype>​
   * <​inputtype>​XML/​URL/​JSON/​URLRESTFUL</​inputtype>​   * <​inputtype>​XML/​URL/​JSON/​URLRESTFUL</​inputtype>​
Line 33: Line 34:
 The **INPUTTYPE** defines how we will send the parameters (fields) to the end-point: The **INPUTTYPE** defines how we will send the parameters (fields) to the end-point:
  
-  * XML and JSON will be set in the body of the call+  * XML and JSON will be set in the body of the call. The XML value will be URL-encoded
   * URL will have the values added in the URL as GET parameters   * URL will have the values added in the URL as GET parameters
   * URLRESTFUL will search the wsurl directive for variables defined in the fields section preceded with a dollar sign. If they are present they will be substituted by the calculated value.   * URLRESTFUL will search the wsurl directive for variables defined in the fields section preceded with a dollar sign. If they are present they will be substituted by the calculated value.
Line 41: Line 42:
  
   * if the Response section has a "​field"​ value for the response then we will save the value received from the call in the indicated field   * if the Response section has a "​field"​ value for the response then we will save the value received from the call in the indicated field
-  * all the Response values received will be put into the workflow context. If no name is given in the Response section for the variable in the context the application will use the name of the variable returned preceded by the text **wsctx\_**+  * all the Response values received will be put into the workflow context. If no name is given in the Response section for the variable in the context the application will use the name of the variable returned preceded by the text **wsctx_**
  
  
Line 47: Line 48:
  
   * <​fields>​block that contains the input parameter fields</​fields>​   * <​fields>​block that contains the input parameter fields</​fields>​
-  * <​fieldname>​input parameter for REST/SOAP call(in the block fields)</​fieldname>​ +  * <​fieldname>​input parameter for REST/SOAP call</​fieldname>​ 
-  * <​OrgfieldName>​fieldname in CoreBOS ​where we get the input parameter value</​OrgfieldName>​+  * <​OrgfieldName>​fieldname in coreBOS ​where we get the input parameter value</​OrgfieldName>​ 
 + 
 +this section is processed by the same engine that is used in the [[en:​adminmanual:​businessmappings:​mapping|Field Mapping Business Map]] so we can use all the options that we have there like Expressions and Rules 
  
 ====== Response ====== ====== Response ======
  
-  * <​Response>​block that contains the response fields</​Response>​ +  * <​Response>​ block that contains the response fields ​coming from the call and where we have to save the values ​</​Response>​ 
-  * <​fieldname>​the value we get back from web service call (in the block Response)</​fieldname>​ +  * <​fieldname>​ the value we get back from web service call </​fieldname>​ 
-  * <OrgfieldName>​fieldname in coreBOS to update/​insert ​the WS response</​OrgfieldName>+  * <destination><​field> fieldname in coreBOS to update ​with the WS response </field></​destination>​ this directive is optional. If it is not given or is set to an empty value, the field will not be updated. 
 +  * <​destination><​context>​ the name to use to set this value in the workflow context </​context></​destination>​ if none is given we will use **wsctx_{fieldname}**
  
 ====== Examples ====== ====== Examples ======
  
-An example of Map for SOAP Call:+=====An example of Map for SOAP Call:=====
  
 <code XML> <code XML>
Line 126: Line 131:
 </​code>​ </​code>​
  
-   +=====An example of Map for REST Call:=====
  
 +<code XML>
 +<map>
 +<​originmodule>​
 +<​originname>​Accounts</​originname>​
 +</​originmodule>​
 + 
 +<​wsconfig>​
 +<​wsurl>​http://​localhost/​facturascripts/​api/​3/​divisas/​$coddivisa</​wsurl>​
 +<​wshttpmethod>​GET</​wshttpmethod>​
 +<​methodname>​divisas</​methodname>​
 +<​wsresponsetime></​wsresponsetime>​
 +<​wsuser></​wsuser>​
 +<​wspass></​wspass>​
 +<​wsheader>​
 +<​header> ​
 +<​keyname>​Content-type</​keyname> ​
 +<​keyvalue>​application/​json</​keyvalue> ​
 +</​header>​
 +<​header> ​
 +<​keyname>​token</​keyname> ​
 +<​keyvalue>​0WXmP4nVDIGNHKysuceA</​keyvalue> ​
 +</​header>​
 +</​wsheader>​
 +<​wstype>​REST</​wstype>​
 +<​inputtype>​URLRESTFUL</​inputtype>​
 +<​outputtype>​JSON</​outputtype> ​
 +</​wsconfig>​
 + 
 +<​fields>​
 +<​field>​
 +<​fieldname>​coddivisa</​fieldname>​
 +<​Orgfields>​
 +<​Orgfield>​
 +<​OrgfieldName>​tickersymbol</​OrgfieldName>​
 +<​OrgfieldID></​OrgfieldID>​
 +</​Orgfield>​
 +<​delimiter></​delimiter>​
 +</​Orgfields>​
 +</​field>​
 +</​fields>​
 + 
 +<​Response>​
 +<​field>​
 +<​fieldname>​descripcion</​fieldname>​
 +<​destination>​
 +<​field>​ownership</​field>​
 +</​destination>​
 +</​field>​
 +</​Response>​
 +</​map>​
 +</​code>​
  
 +Note how the $coddivisa variable in the URL <​code><​wsurl>​http://​localhost/​facturascripts/​api/​3/​divisas/​$coddivisa</​wsurl></​code>​ will be substituted by the actual value that we have in coreBOS as defined in the fields section. In this case, the value of the tickersymbol field in the Account will be read and $coddivisa will be substituted with that value.
  
 +=====An example of two tasks passing context=====
 +
 +This first map executes an authentication call and loads the authorization token into the workflow context and the second task uses that value to make an operation call.
 +
 +<code xml>
 +<map>
 +<​originmodule>​
 +<​originname>​Accounts</​originname>​
 +</​originmodule>​
 +
 +<​wsconfig>​
 +<​wsurl><​![CDATA[http://​localhost/​corebostsolucio/​webservice.php?​operation=testcontext&​id=2355]]></​wsurl>​
 +<​wshttpmethod>​GET</​wshttpmethod>​
 +<​methodname>​wslogin</​methodname>​
 +<​wsresponsetime></​wsresponsetime>​
 +<​wsuser></​wsuser>​
 +<​wspass></​wspass>​
 +<​wsheader>​
 +<​header>​
 +<​keyname>​Content-type</​keyname>​
 +<​keyvalue>​application/​json</​keyvalue>​
 +</​header>​
 +<​header>​
 +<​keyname>​Authorization</​keyname>​
 +<​keyvalue>​9192929383834</​keyvalue>​
 +</​header>​
 +</​wsheader>​
 +<​wstype>​REST</​wstype>​
 +<​inputtype>​JSON</​inputtype>​
 +<​outputtype>​JSON</​outputtype>​
 +</​wsconfig>​
 +
 +<​fields>​
 +</​fields>​
 +
 +<​Response>​
 +<​field>​
 +<​fieldname>​result</​fieldname>​
 +<​destination>​
 +<​context>​token</​context>​
 +</​destination>​
 +</​field>​
 +</​Response>​
 +</​map>​
 +</​code>​
 +
 +<code xml>
 +<map>
 +<​originmodule>​
 +<​originname>​Accounts</​originname>​
 +</​originmodule>​
 +
 +<​wsconfig>​
 +<​wsurl>​http://​localhost/​corebostsolucio/​webservice.php?​operation=testcontext2</​wsurl>​
 +<​wshttpmethod>​POST</​wshttpmethod>​
 +<​methodname>​wspost</​methodname>​
 +<​wsresponsetime></​wsresponsetime>​
 +<​wsuser></​wsuser>​
 +<​wspass></​wspass>​
 +<​wsheader>​
 +<​header>​
 +<​keyname>​Content-type</​keyname>​
 +<​keyvalue>​application/​json</​keyvalue>​
 +</​header>​
 +<​header>​
 +<​keyname>​Authorization</​keyname>​
 +<​keyvalue>​getContext(token)</​keyvalue>​
 +</​header>​
 +</​wsheader>​
 +<​wstype>​REST</​wstype>​
 +<​inputtype>​JSON</​inputtype>​
 +<​outputtype>​JSON</​outputtype>​
 +</​wsconfig>​
 +
 +<​fields>​
 +<​field>​
 +<​fieldname>​token</​fieldname>​
 +<​Orgfields>​
 +<​Orgfield>​
 +<​OrgfieldName>​accountname</​OrgfieldName>​
 +<​OrgfieldID></​OrgfieldID>​
 +</​Orgfield>​
 +<​delimiter></​delimiter>​
 +</​Orgfields>​
 +</​field>​
 +</​fields>​
 +
 +<​Response>​
 +<​field>​
 +<​fieldname>​description</​fieldname>​
 +<​destination>​
 +<​field>​accountname</​field>​
 +</​destination>​
 +</​field>​
 +</​Response>​
 +</​map>​
 +</​code>​
  
 +==== Related Articles ====
  
 +  * [[https://​blog.corebos.org/​blog/​runwswftask|Run Web Service Workflow Task]]
 +  * [[https://​blog.corebos.org/​blog/​runwswftaskchange|Run Web Service Workflow Task Change]]