MaarchWSClient est un module permettant de transférer dans MaarchCourrier les documents traités par MaarchCapture.
Il utilise le protocole REST pour verser les documents via webservice.
Depuis le fichier de paramétrage général : ./config/Capture.xml.
<step name="SendToMaarch" module="MaarchWSClient" function="processBatch">
<input name="WS">MaarchRestWS</input>
<input name="Process">MaarchRestWSProcessFromMail</input>
<input name="CatchError">true</input>
<input name="configFile">MaarchWSClient_standard_sample.xml</input>
</step>
La déclaration du module comporte les attributs suivants :
Depuis le fichier de paramétrage de la boite mail à capturer : ./modules/MaarchWSClient/MaarchWSClient_standard_sample.xml.
<?xml version="1.0" encoding="UTF-8"?>
<MaarchWSClient>
<!-- REST FRONTAL -->
<WS name="MaarchRestWS" type="REST" uri="http://superadmin:superadmin@127.0.0.1/MaarchCourrier/rest/" />
<!-- REST SAMPLES -->
<process name="MaarchRestWSProcessFromScan">
<loop xpath="/Batch/Documents/Document">
<call name="/resources" method="POST">
<argument type="entity" name="modelId">1</argument>
<argument type="entity" name="encodedFile" eval="base64_encode(file_get_contents($Element->path))"/>
<argument type="entity" name="format" attribute="extension"/>
<argument type="entity" name="doctype">108</argument>
<argument type="entity" name="chrono">true</argument>
<argument type="entity" name="destination">15</argument>
<argument type="entity" name="priority">2</argument>
<argument type="entity" name="status">INIT</argument>
<return>
<resId metadata="resId" />
</return>
</call>
</loop>
</process>
<process name="MaarchRestWSProcessFromMail">
<loop xpath="/Batch/Documents/Document">
<call name="/resources" method="POST">
<argument type="entity" name="modelId">1</argument>
<argument type="entity" name="encodedFile" eval="base64_encode(file_get_contents($Element->path))"/>
<argument type="entity" name="format" attribute="extension"/>
<argument type="entity" name="status">INIT</argument>
<argument type="entity" name="chrono">true</argument>
<argument type="entity" name="doctype" metadata="type_id"/>
<argument type="entity" name="subject" metadata="subject"/>
<argument type="entity" name="documentDate" metadata="doc_date"/>
<argument type="entity" name="destination" metadata="destination"/>
<argument type="entity" name="initiator" metadata="destination"/>
<argument type="entity" name="priority">2</argument>
<return>
<resId metadata="resId" />
</return>
</call>
<loop xpath="Attachments/Attachment">
<call name="/attachments" method="POST">
<argument type="entity" name="resIdMaster" xvalue="ancestor::Document/Metadata/resId"/>
<argument type="entity" name="type">incoming_mail_attachment</argument>
<argument type="entity" name="encodedFile" eval="base64_encode(file_get_contents($Element->path))"/>
<argument type="entity" name="format" attribute="extension"/>
<argument type="entity" name="title" metadata="filename"/>
<return>
<id metadata="resId" />
</return>
</call>
</loop>
</loop>
</process>
</MaarchWSClient>
<!-- REST FRONTAL -->
<WS name="MaarchRestWS" type="REST" uri="http://superadmin:superadmin@127.0.0.1/MaarchCourrier/rest/" />
<process name="MaarchRestWSProcessFromScan">
<loop xpath="/Batch/Documents/Document">
<call name="/resources" method="POST">
<argument type="entity" name="encodedFile" eval="base64_encode(file_get_contents($Element->path))"/>
<argument type="entity" name="format" attribute="extension"/>
<argument type="entity" name="documentdate" metadata="doc_date"/>
<argument type="entity" name="resIdMaster" xvalue="ancestor::Document/Metadata/resId"/>
<return>
<resId metadata="resId" />
</return>