Grouper
  1. Grouper
  2. GRP-437

Add JSONP support to Grouper-WS

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.1.0
    • Component/s: WS
    • Labels:
      None
    • Environment:
      web

      Description

      It would be nice if grouper-ws supported JSONP for AJAX apps which do not live on the server hosting the grouper-ws-api.

        Activity

        Hide
        Chris Hyzer added a comment -
        Just curious, David, what changes need to happen on the server side to support this?

        Thanks,
        Chris
        Show
        Chris Hyzer added a comment - Just curious, David, what changes need to happen on the server side to support this? Thanks, Chris
        Hide
        David Langenberg added a comment -
        Basically, the server needs to be able to accept a new parameter on all calls
        which return JSON. For this case, let's call the parameter 'callback'. The
        input to this parameter is a single-word string. The server will then take
        the JSON response, and before sending it back to the client will wrap the
        response in the callback value.

        Pseudo Example non-JSONp:

        GET http://server/getStuff

        Returned:

        {foo: bar, baz: qux}

        Pseudo Example JSONp

        GET http://server/getStuff?callback=someQueryResults

        Returned:

        someQueryResults({foo: bar, baz: qux})

        On the client side, a function someQueryResults will exist which will take the
        JSON as a parameter & do things with it.

        Dave
        Show
        David Langenberg added a comment - Basically, the server needs to be able to accept a new parameter on all calls which return JSON. For this case, let's call the parameter 'callback'. The input to this parameter is a single-word string. The server will then take the JSON response, and before sending it back to the client will wrap the response in the callback value. Pseudo Example non-JSONp: GET http://server/getStuff Returned: {foo: bar, baz: qux} Pseudo Example JSONp GET http://server/getStuff?callback=someQueryResults Returned: someQueryResults({foo: bar, baz: qux}) On the client side, a function someQueryResults will exist which will take the JSON as a parameter & do things with it. Dave
        Hide
        David Langenberg added a comment -
        Just curious if there is any movement on this.
        Show
        David Langenberg added a comment - Just curious if there is any movement on this.
        Hide
        Chris Hyzer added a comment -
        This is fixed.

        Note, if you want to disable this functionality, set this in the grouper-ws.properties

        ws.allowJsonWrapper = false


        If this is the request (could be any operation):

        POST /grouper-ws/servicesRest/v2_1_000/subjects?grouperJsonResponseWrapper=something HTTP/1.1
        Connection: close
        Authorization: Basic XXXXXXXX
        User-Agent: Jakarta Commons-HttpClient/3.0
        Host: localhost:8090
        Content-Length: 149
        Content-Type: text/x-json; charset=UTF-8

        {"WsRestGetGroupsRequest":{"subjectAttributeNames":["description"],"subjectLookups":[{"subjectId":"test.subject.0"},{"subjectId":"test.subject.1"}]}}

        Then this is the response:

        HTTP/1.1 201 Created
        Server: Apache-Coyote/1.1
        Set-Cookie: JSESSIONID=xxxxxxxxxxx; Path=/grouper-ws
        X-Grouper-resultCode: SUCCESS
        X-Grouper-success: T
        X-Grouper-resultCode2: NONE
        Content-Type: text/x-json;charset=UTF-8
        Content-Length: 1135
        Date: Tue, 20 Mar 2012 15:00:01 GMT
        Connection: close

        something({"WsGetGroupsResults":{"responseMetadata":{"millis":"223","serverVersion":"2.1.0"},"resultMetadata":{"resultCode":"SUCCESS","resultMessage":"Success for: clientVersion: 2.1.0, subjectLookups: Array size: 2: [0]: WsSubjectLookup[subjectId=test.subject.0]\n[1]: WsSubjectLookup[subjectId=test.subject.1]\n\nmemberFilter: All, includeGroupDetail: false, actAsSubject: null\n, params: null\n fieldName1: null\n, scope: null, wsStemLookup: null\n, stemScope: null, enabled: null, pageSize: null, pageNumber: null, sortString: null, ascending: null\n, pointInTimeFrom: null, pointInTimeTo: null","success":"T"},"results":[{"resultMetadata":{"resultCode":"SUCCESS","success":"T"},"wsSubject":{"attributeValues":["description.test.subject.0"],"id":"test.subject.0","name":"my name is test.subject.0","resultCode":"SUCCESS","sourceId":"jdbc","success":"T"}},{"resultMetadata":{"resultCode":"SUCCESS","success":"T"},"wsSubject":{"attributeValues":["description.test.subject.1"],"id":"test.subject.1","name":"my name is test.subject.1","resultCode":"SUCCESS","sourceId":"jdbc","success":"T"}}],"subjectAttributeNames":["description"]}})
        Show
        Chris Hyzer added a comment - This is fixed. Note, if you want to disable this functionality, set this in the grouper-ws.properties ws.allowJsonWrapper = false If this is the request (could be any operation): POST /grouper-ws/servicesRest/v2_1_000/subjects?grouperJsonResponseWrapper=something HTTP/1.1 Connection: close Authorization: Basic XXXXXXXX User-Agent: Jakarta Commons-HttpClient/3.0 Host: localhost:8090 Content-Length: 149 Content-Type: text/x-json; charset=UTF-8 {"WsRestGetGroupsRequest":{"subjectAttributeNames":["description"],"subjectLookups":[{"subjectId":"test.subject.0"},{"subjectId":"test.subject.1"}]}} Then this is the response: HTTP/1.1 201 Created Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=xxxxxxxxxxx; Path=/grouper-ws X-Grouper-resultCode: SUCCESS X-Grouper-success: T X-Grouper-resultCode2: NONE Content-Type: text/x-json;charset=UTF-8 Content-Length: 1135 Date: Tue, 20 Mar 2012 15:00:01 GMT Connection: close something({"WsGetGroupsResults":{"responseMetadata":{"millis":"223","serverVersion":"2.1.0"},"resultMetadata":{"resultCode":"SUCCESS","resultMessage":"Success for: clientVersion: 2.1.0, subjectLookups: Array size: 2: [0]: WsSubjectLookup[subjectId=test.subject.0]\n[1]: WsSubjectLookup[subjectId=test.subject.1]\n\nmemberFilter: All, includeGroupDetail: false, actAsSubject: null\n, params: null\n fieldName1: null\n, scope: null, wsStemLookup: null\n, stemScope: null, enabled: null, pageSize: null, pageNumber: null, sortString: null, ascending: null\n, pointInTimeFrom: null, pointInTimeTo: null","success":"T"},"results":[{"resultMetadata":{"resultCode":"SUCCESS","success":"T"},"wsSubject":{"attributeValues":["description.test.subject.0"],"id":"test.subject.0","name":"my name is test.subject.0","resultCode":"SUCCESS","sourceId":"jdbc","success":"T"}},{"resultMetadata":{"resultCode":"SUCCESS","success":"T"},"wsSubject":{"attributeValues":["description.test.subject.1"],"id":"test.subject.1","name":"my name is test.subject.1","resultCode":"SUCCESS","sourceId":"jdbc","success":"T"}}],"subjectAttributeNames":["description"]}})

          People

          • Assignee:
            Chris Hyzer
            Reporter:
            David Langenberg
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: