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¶m2=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.