Moqui - 将RESTful sendJSONRequest()发送到远程URL?
如何使用Moqui将JSON请求发送到远程URL?
Moqui中是否存在内置方法,或者我需要做什么?我是否需要直接使用JsonBuilder和JsonSlurper groovy类,simpleHttpStringRequest()方法和直接CURL语句来编写脚本? (我是Java和Groovy的初学者。)
E.g。需要的服务:
<service verb="create" noun="RcSupplier">
<!-- 1. Parse my service's in-parameters and the corresponding remote application parameter field names to needed JSON request body. Also include correct header, authorisation, method, etc.
<!-- 2. POST JSON to remote application https://api.xxxxxxxxxxxx.com/api/v1/Suppliers ("Create" Supplier) -->
<!-- 3. Check response is ok and handle errors -->
<!-- 4. GET the Supplier ("find" Supplier) just created on the remote app, to retrieve the primary key (id) that was generated for it by the remote system (either append $filter=code eq 'partyId' or else retrieve all Suppliers as a list to perform our own query) -->
<!-- 5. Parse the JSON response body received to a map that will be utilised to update my corresponding entity (field: externalId) with the remote primary key value. (note: probably better to use EntityDataLoader to do this later on for check and other functionality?) -->
</service>
答案 0 :(得分:0)
请查看Example folder中的示例,并在此处查看REST examples,但对您来说最有帮助的是Authorize.net的现有应用程序,其中有一个工作示例使用XML进行远程服务调用,因此切换到JSON不应该太困难