4

I am working in a JSONRPC webservice and I am trying to send the request to the server end to get the response. Basically I am trying to send the following details in the request

methodname//example 899
Language code
Transaction code
User ID
Password
number
Amount

Now there is the host which I need to submit the request.If I telnet the host and the port its getting connected successfully.But when I try to submit the request through the browser I am getting some net::ERR_CONNECTION_CLOSED.I am not sure why its happening.

I am not sure about the request that I am submitting but here is the request that I am submitting.And I am submitting request using the Javascript

<Script>
    JSONTest = function() {


        $.ajax({
            url : "https://domain.com:port/",
            type : 'GET',
            data : {
                "jsonrpc" : "2.0",
                "method" : "904",
                "id" : "1",
                "params": [ "en", "69", "2123129930", "4371232483", "50", "" ]
            },
            dataType : "json",
            success : function(result) {
                //alert("result"+result[0]);
                switch (result) {
                case true:
                    processResponse(result);
                    break;
                default:
                    resultDiv.html(result);
                }
            },
        /*   error: function (xhr, ajaxOptions, thrownError) {
          alert(xhr.status);
          alert(thrownError);
          } */
        });
    };
</script>

<button type="button" onClick="JSONTest()">JSON</button>

Based on the above script I am tryiing to find the answers for the following questions.

  1. Is the request that I am submitting above is valid or not ?
  2. How can I provide the URL value if the above declaration is wrong?
  3. Is the type that I have provided above is fine ?
  4. Please validate all the parameters and let me know whether all of the parameters positions as valid or not.
  5. What is the hierarchy of the parameters that I have provided above ?

Really appreciate your help on this.

gen_Eric
  • 223,194
  • 41
  • 299
  • 337
zulu
  • 63
  • 1
  • 5

1 Answers1

1

Does your jsonrpc-server take HTTP GET-requests? If your jsonrpc-server supports http at all, the more normal approach is using POST to transfer the jsonrpc request-data.

Have you considered cross-domain restrictions from your browser?

I would guess you should make a POST-request. The data looks correct, but all this depends on the jsonrpc-server. There are ususal ways to transport jsonrpc over http, but it is not part of the protocol itself.

Make sure that the server accepts http post, and outputs the Access-Control-Allow-Origin header; see http://en.wikipedia.org/wiki/Cross-origin_resource_sharing

If you're making more than one simple post, I'd suggest a js-lib for handling the jsonrpc, like: https://github.com/Textalk/jquery.jsonrpcclient.js

fiddur
  • 1,768
  • 15
  • 11