SOAPjr Demos

The Browser side : Did it work?

If you use jQuery to make AJAX calls, how do you know if you got a;
  • Network error
  • Server error
  • Database error
  • Application error
  • Browser error
With SOAPjr you simply check;
        HEAD.result == 1
If not, then all the different types of possible errors are packed in a consistent format inside;
        HEAD.errors
This means you can easily pass back multiple errors, each one has a specific error code and message and they are grouped by ENVELOPE, HEAD, BODY and OPTIONS so error handling is clean, fast and consistent.

The Server side : Which data do you use?

If a browser sends you some data in a query, how do you know which fields go in the database and which fields tell you about the request itself. Is this different for each request and each application you build? Do you have to update your code in multiple places if you want to add a new parameter? With SOAPjr you always know your requests will cleanly be separated into;
    HEAD // parameters about the request (service_type, action_type, session id, etc.)
    BODY // the real payload of the request

The Goal

Our aim is to create a common set of "data model definitions" (dmd's) that align with the JSON-schema proposal so applications within specific domains can easily share data. The primary extension that SOAPjr may provide here is the use of consistent or standardised error codes.

Basic interactive demo

        /*
                Common SETUP design pattern:
                ----------------------------
                - create a SOAPjr_request object
                - set the HEAD and BODY values
                - then call send()

                The real work that handles the response is done in the callback below
        */


        /*
                Common CALLBACK design pattern:
                -------------------------------
                - get the response object's HEAD (for convenience)
                - if the result was successful process the BODY
                - else get the errors object and process any errors you find

                NOTE:   Now all transport, application and validation errors can be handled in a common way.
                        Also, multiple errors can easily be returned and common or domain specific error codes can also be standardised.

                NOTE:   This demo will be simplified and bought into line with the new SOAPjr lite jQuery plugin API
        */

	See http://SOAPjr.org/js/basic_demo.js for a working example.
	See http://SOAPjr.org/js/jquery.SOAPjr-1.1.0.js for the jQuery plugin.


Just click on the buttons below to test out a live SOAPjr demo.



Static Examples

SOAPjr Request Message Structure - View a Contact

This is a basic request to view the jCard details for a single user (based on their username). This message would be passed in a request within the "json" parameter e.g.
?json={"HEAD":{"service_type":"contacts","action_type":"view",
"sid":"80e5b8a8b9cbf3a79fe8d624628a0fe5"},"BODY":{"username":"jbloggs"}}
Of course this would be supplied with the relevant encoding.

NOTE: A jCard dmd is yet to be created - once available this should also be defined in the request HEAD.
{
    "HEAD" : {
        "service_type" : "contacts",
        "action_type" : "view",
        "sid" : "80e5b8a8b9cbf3a79fe8d624628a0fe5"
    },
    "BODY" : {
        "username" : "jbloggs"
    }
}

SOAPjr Response Message Structure - View a Contact (No errors)

This is a simple SOAPjr response with a HEAD.result that represents a success. The BODY contains a single jCard record. In a list "list" or "search" context this would contain an array of 0 or more jCard records.
{
    "HEAD" : {
        "result" : 1
    },
    "BODY" : {
        "email" : [
            {
                "type" : ["internet","pref"],
                "value" : "jbloggs@SOAPjr.org"
            }
        ],
        "fn" : "Joe Bloggs",
        "kind" : "individual",
        "n" : {
            "family-name" : ["Bloggs"],
            "given-name" : ["Joe"],
            "value" : "Bloggs;Joe"
        },
        "org" : [
            {
                "organization-name" : "SOAPjr.org"
            }
        ]
    }
}

SOAPjr Response Message Structure - View a Contact (Invalid SID)

This SOAPjr response shows that an invalid Session ID was supplied. If HEAD.result does not equal 1 then there was an error. In that case you can walk HEAD.errors and retrieve and process as many errors as have been returned. Each element within the request object can then have a specified error code and message allowing for more robust and sophisticated error handling.
{
    "HEAD" : {
        "result" : 0,
        "errors" : {
            "HEAD" : {
                "sid" : {
                    "code" : "401",
                    "message" : "Invalid Session ID"
                }
            }
        }
    }
}

Latest News

New demonstration SOAPjr site added

Sep 27th 2009

A new site has been added to the demonstration section that shows a live working example of SOAPjr services - see http://SOAPjr.org/demos.html

File upload (related API) added to SOAPjr jquery plugin

Mar 25th 2009

A new version of the jquery plugin that support file uploads using the "related API" has been released. Version 1.3.0 of the SOAPjr jQuery plugin is available on the jQuery plugin site.

File upload (related API) added to SOAPjr CPAN module

Mar 25th 2009

A new version of the perl libs that support file uploads using the "related API" have been uploaded to CPAN. Thanks for the update Sean.

Redhat claim patent on SOAP over CGI

Mar 20th 2009

In 2007 Redhat lodged a patent on SOAP processing over CGI. Yet another great reason to migrate to SOAPjr which uses lightweight JSON instead of XML.

jQuery plugin bug fixes released

Dec 18th 2008

A variety of small bug fixes and tidy ups have been released (see revision history for more details). Version 1.1.2 of the SOAPjr jQuery plugin is available on the jQuery plugin site.

New jQuery plugin API

Dec 12th 2008

Now you can make SOAPjr calls with a single line, configure default settings or automatically validate the "send" or "receive" data against JSON Schemas. Version 1.1.0 of the SOAPjr jQuery plugin is available on the jQuery plugin site.

Creative Commons License
SOAPjr.org by SOAPjr.org is licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
Based on a work at SOAPjr.org.