0

I am trying to make a call to a Json enabled endpoint.

The usage is http://xxxxxxxxxx.com/Service.svc/Json/{{NAME_OF_METHOD}}?param1=value1&param2=value2

I have:

<service verb="call" noun="MSTService" type="remote-json-rpc" location="http://xxxxxxxxxx.com/Service.svc/Json" authenticate="false" method="GetTestString">
 <in-parameters>
        <parameter name="theString" type="String" />
 </in-parameters>
 </service>

So I want that parsed into a http GET request like http://xxxxxxxxxx.com/Service.svc/Json/GetTestString?thestring=testString (assuming I input "testString" to the service.)

The response to this request would be: {"d":"testString ABC"}

I have edited RemoteJsonRpcServiceRunner.groovy as follows:

static Map<String, Object> runJsonService(String serviceName, String location, String method,
                                           Map<String, Object> parameters, ExecutionContext ec) {

  String params = "theString=${parameters?.theString}" // Inserted Line
  String jsonRequest = "${method}?${params}"           // Inserted Line

/* Commented following out: 
 *       Map jsonRequestMap = [jsonrpc:"2.0", id:1, method:method, params:parameters]
 *       JsonBuilder jb = new JsonBuilder()
 *       jb.call(jsonRequestMap)
 *       String jsonRequest = jb.toString()
 */
    String jsonResponse =     StupidWebUtilities.simpleHttpStringRequest(location, jsonRequest, "application/json")

But the connection is timing out. Any help appreciated.

Ronan Keane
  • 189
  • 8
  • What is the target of the service call? The 'remote-json-rpc' type services are for calls via JSON-RPC, not something like JSON over REST (for that use the REST client). This can be used to talk to other Moqui servers, or other JSON-RPC servers as long as the service definition matches up. – David E. Jones Aug 12 '16 at 08:51
  • My mistake. Ok, I have the javadoc for the RestClient interface. I'll give this another go and revert. Thanks David. – Ronan Keane Aug 12 '16 at 16:12

0 Answers0