Package com.thetransactioncompany.jsonrpc2.client

Examples of com.thetransactioncompany.jsonrpc2.client.JSONRPC2Session


      throw new JSONRPC2SessionException(msg, JSONRPC2SessionException.UNEXPECTED_CONTENT_TYPE);
    }

    // Parse and return the response
    JSONRPC2Response response = null;

    try {
      response = JSONRPC2Response.parse(rawResponse.getContent(),
                            options.preservesParseOrder(),
                options.ignoresVersion(),
                options.parsesNonStdAttributes());

    } catch (JSONRPC2ParseException e) {

      throw new JSONRPC2SessionException(
          "Invalid JSON-RPC 2.0 response",
          JSONRPC2SessionException.BAD_RESPONSE,
          e);
    }

    // Response ID must match the request ID, except for
    // -32700 (parse error), -32600 (invalid request) and
    // -32603 (internal error)

    Object reqID = request.getID();
    Object resID = response.getID();

    if (reqID != null && resID != null && reqID.toString().equals(resID.toString()) ) {
      // ok
    } else if (reqID == null && resID == null) {
      // ok
    } else if (! response.indicatesSuccess() && ( response.getError().getCode() == -32700 ||
           response.getError().getCode() == -32600 ||
           response.getError().getCode() == -32603    )) {
      // ok
    } else {
      throw new JSONRPC2SessionException(
          "Invalid JSON-RPC 2.0 response: ID mismatch: Returned " +
          resID + ", expected " + reqID,
View Full Code Here

TOP

Related Classes of com.thetransactioncompany.jsonrpc2.client.JSONRPC2Session

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.