summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/documentation-2x/sca-java-bindingjsonrpc.html
diff options
context:
space:
mode:
authorcoreyg <coreyg@13f79535-47bb-0310-9956-ffa450edef68>2014-11-21 09:30:19 +0000
committercoreyg <coreyg@13f79535-47bb-0310-9956-ffa450edef68>2014-11-21 09:30:19 +0000
commit200a40b332420f94992eb39a6d0ea1cf1490ffc4 (patch)
tree1c76ef1d254c7bfc91128a313d319bd60da9d01e /site/trunk/site-publish/documentation-2x/sca-java-bindingjsonrpc.html
parent85f53ab6ab4f664d63774c94b672a875c9e52b8a (diff)
Adding tuscany's website to their svn repo for svnpubsub
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1640879 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'site/trunk/site-publish/documentation-2x/sca-java-bindingjsonrpc.html')
-rw-r--r--site/trunk/site-publish/documentation-2x/sca-java-bindingjsonrpc.html329
1 files changed, 329 insertions, 0 deletions
diff --git a/site/trunk/site-publish/documentation-2x/sca-java-bindingjsonrpc.html b/site/trunk/site-publish/documentation-2x/sca-java-bindingjsonrpc.html
new file mode 100644
index 0000000000..8362ee137f
--- /dev/null
+++ b/site/trunk/site-publish/documentation-2x/sca-java-bindingjsonrpc.html
@@ -0,0 +1,329 @@
+
+
+
+
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<HTML>
+ <HEAD>
+ <META name="description" content="Apache Tuscany">
+ <META name="keywords" content="apache, apache tuscany, tuscany, service, services, fabric, soa, service oriented architecture, sca, service component architecture, das, sdo, csa, ruby, opensource">
+
+ <LINK type="text/css" rel="stylesheet" href="http://tuscany.apache.org/stylesheets/default.css">
+ <LINK rel="SHORTCUT ICON" href="https://cwiki.apache.org/confluence/display/TUSCANYxDOCx2x/$images/favicon.ico">
+ <TITLE>SCA Java binding.jsonrpc : Apache Tuscany</TITLE>
+ <META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD>
+
+ <STYLE>
+ .spacetree * ul {
+ padding-left:0px;
+ margin-left: 0px;
+ }
+ .spacetree * li {
+ margin-left: 5px;
+ padding-left:5px;
+ }
+ </STYLE>
+
+ <BODY onload="init()">
+ <!-- topNav -->
+ <TABLE border="0" cellpadding="2" cellspacing="0" width="100%">
+ <TR class="topBar">
+ <TD align="left" valign="middle" class="topBarDiv" align="left" nowrap="">
+ <A href="https://cwiki.apache.org/geronimo"> Home</A> &gt;&nbsp;<A href="index.html" title="Apache Tuscany Docs 2.x">Apache Tuscany Docs 2.x</A>&nbsp;&gt;&nbsp;<A href="index.html" title="Index">Index</A>&nbsp;&gt;&nbsp;<A href="sca-java-extensions-guide.html" title="SCA Java Extensions Guide">SCA Java Extensions Guide</A>&nbsp;&gt;&nbsp;<A href="" title="SCA Java binding.jsonrpc">SCA Java binding.jsonrpc</A>
+ </TD>
+ <TD align="right" valign="middle" nowrap="">
+ <FORM name="search" action="http://www.google.com/search" method="get">
+ <INPUT type="hidden" name="ie" value="UTF-8">
+ <INPUT type="hidden" name="oe" value="UTF-8">
+ <INPUT type="hidden" name="domains" value="">
+ <INPUT type="hidden" name="sitesearch" value="">
+ <INPUT type="text" name="q" maxlength="255" value="">
+ <INPUT type="submit" name="btnG" value="Google Search">
+ </FORM>
+ </TD>
+ </TR>
+ </TABLE>
+
+
+ <TABLE border="0" cellpadding="2" cellspacing="0" width="100%">
+ <TR class="topBar">
+ <TD align="left" valign="middle" class="topBarDiv" nowrap="true" width="100%">
+ &nbsp;<A href="index.html" title="Apache Tuscany Docs 2.x">Apache Tuscany Docs 2.x</A>&nbsp;&gt;&nbsp;<A href="index.html" title="Index">Index</A>&nbsp;&gt;&nbsp;<A href="sca-java-extensions-guide.html" title="SCA Java Extensions Guide">SCA Java Extensions Guide</A>&nbsp;&gt;&nbsp;<A href="" title="SCA Java binding.jsonrpc">SCA Java binding.jsonrpc</A>
+ </TD>
+
+ <TD align="right" valign="middle" class="topBarDiv" align="left" nowrap="true">
+ <A href="http://tuscany.apache.org/">Tuscany Home</A> | <A href="http://mail-archives.apache.org/mod_mbox/tuscany-user">User List</A> | <A href="http://mail-archives.apache.org/mod_mbox/tuscany-dev">Dev List</A> | <A href="http://issues.apache.org/jira/browse/Tuscany">Issue Tracker</A>&nbsp;&nbsp;
+ </TD>
+ </TR>
+ </TABLE>
+
+ <TABLE border="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
+ <TR>
+ <TD valign="top" align="left" width="22%" bgcolor="#F9F9F9" class="noprint">
+ <DIV class="tabletitle">Table of Contents</DIV>
+ <DIV class="spacetree">
+
+
+ </DIV>
+ </TD>
+ <TD align="left" valign="top" width="78%">
+ <!-- pageContent -->
+ <DIV id="PageContent">
+ <DIV class="pageheader" style="padding: 6px 0px 0px 0px;">
+ <!-- We'll enable this once we figure out how to access (and save) the logo resource -->
+ <!--img src="http://geronimo.apache.org/images/confluence_logo.gif" style="float: left; margin: 4px 4px 4px 10px;" border="0"-->
+ <DIV style="margin: 0px 10px 0px 10px" class="smalltext">Apache Tuscany Docs 2.x</DIV>
+ <DIV style="margin: 0px 10px 8px 10px" class="pagetitle">SCA Java binding.jsonrpc</DIV>
+
+ <DIV class="greynavbar" align="right" style="padding: 2px 10px; margin: 0px;">
+<!-- -->
+ <A href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=5964964">
+ <IMG src="http://geronimo.apache.org/images/icons/notep_16.gif" height="16" width="16" border="0" align="absmiddle" title="Edit Page"></A>
+ <A href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=5964964">Edit Page</A>
+ &nbsp;
+ <A href="https://cwiki.apache.org/confluence/pages/listpages.action?key=TUSCANYxDOCx2x">
+ <IMG src="http://geronimo.apache.org/images/icons/browse_space.gif" height="16" width="16" border="0" align="absmiddle" title="Browse Space"></A>
+ <A href="https://cwiki.apache.org/confluence/pages/listpages.action?key=TUSCANYxDOCx2x">Browse Space</A>
+ &nbsp;
+ <A href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=TUSCANYxDOCx2x&fromPageId=5964964">
+ <IMG src="http://geronimo.apache.org/images/icons/add_page_16.gif" height="16" width="16" border="0" align="absmiddle" title="Add Page"></A>
+ <A href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=TUSCANYxDOCx2x&fromPageId=5964964">Add Page</A>
+ &nbsp;
+ <A href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=TUSCANYxDOCx2x&fromPageId=5964964">
+ <IMG src="http://geronimo.apache.org/images/icons/add_blogentry_16.gif" height="16" width="16" border="0" align="absmiddle" title="Add News"></A>
+ <A href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=TUSCANYxDOCx2x&fromPageId=5964964">Add News</A>
+<!-- -->
+ </DIV>
+ </DIV>
+
+ <DIV class="pagecontent">
+ <DIV class="wiki-content">
+ <H3><A name="SCAJavabinding.jsonrpc-%3Cbinding.jsonrpc%3E"></A>&lt;binding.jsonrpc&gt;</H3>
+
+<P>Tuscany supports <A href="http://json-rpc.org/" class="external-link" rel="nofollow">JSON-RPC</A> as a protcol for use with SCA services by using the &lt;binding.jsonrpc&gt; element in your Application composite. This enables remote web browser clients to easily make RPC style calls to server-side SCA components.</P>
+
+<H3><A name="SCAJavabinding.jsonrpc-UserStories"></A>User Stories</H3>
+<UL>
+ <LI>A client application invoke a remote SCA Service using JSON-RPC and the invocation return business objects in JSON format. <IMG class="emoticon" src="https://cwiki.apache.org/confluence/images/icons/emoticons/check.gif" height="16" width="16" align="absmiddle" alt="" border="0">
+ <UL>
+ <LI>e.g. Retrieve catalog items</LI>
+ </UL>
+ </LI>
+ <LI>A SCA component can define a reference to a remote SCA Service and use JSON-RPC for the invocation. <IMG class="emoticon" src="https://cwiki.apache.org/confluence/images/icons/emoticons/check.gif" height="16" width="16" align="absmiddle" alt="" border="0">
+ <UL>
+ <LI>e.g. A catalog aggregator invoke various catalog services using JSON-RPC and aggregate the returned items into a single response</LI>
+ </UL>
+ </LI>
+ <LI>A client application invoke a SCA Service using JSON-RPC and the invocation returns a business exception. <IMG class="emoticon" src="https://cwiki.apache.org/confluence/images/icons/emoticons/check.gif" height="16" width="16" align="absmiddle" alt="" border="0">
+ <UL>
+ <LI>e.g. Empty catalog throws a Busines Exception. Business Exception should properly propagate and display nicely to client.</LI>
+ </UL>
+ </LI>
+ <LI>A client application invoke a SCA Service using JSON-RPC and the invocation returns a runtime exception. <IMG class="emoticon" src="https://cwiki.apache.org/confluence/images/icons/emoticons/check.gif" height="16" width="16" align="absmiddle" alt="" border="0">
+ <UL>
+ <LI>e.g. Try to retrieve catalog items from a catalog service that is un-available. Runtime exception properly propagate and display nicely to client.</LI>
+ </UL>
+ </LI>
+ <LI>A client application needs to access a service exposed trough JSON-RPC binding that requires authentication.
+ <UL>
+ <LI>e.g. make sure if nobody can get to the catalog if it's not authenticated</LI>
+ </UL>
+ </LI>
+</UL>
+
+
+
+<H3><A name="SCAJavabinding.jsonrpc-UsingtheTuscanyJSONRPCbinding"></A>Using the Tuscany JSON-RPC binding</H3>
+
+<P>You could use this binding without any configuration, or by providing a specific service URI. <BR>
+To include it on a SCA service or Reference, choose one of the examples below :</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+&lt;composite xmlns=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//docs.oasis-open.org/ns/opencsa/sca/200903&quot;</SPAN>
+</SPAN> xmlns:tuscany=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//tuscany.apache.org/xmlns/sca/1.1&quot;</SPAN>
+</SPAN> ...
+
+ &lt;tuscany:binding.jsonrpc/&gt;
+</PRE>
+</DIV></DIV>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+&lt;composite xmlns=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//docs.oasis-open.org/ns/opencsa/sca/200903&quot;</SPAN>
+</SPAN> xmlns:tuscany=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//tuscany.apache.org/xmlns/sca/1.1&quot;</SPAN>
+</SPAN> ...
+
+ &lt;binding.jsonrpc uri=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//localhost:8080/store/catalog&quot;</SPAN>/&gt;</SPAN>
+</PRE>
+</DIV></DIV>
+
+<H3><A name="SCAJavabinding.jsonrpc-ConsumingJSONRPCservicesontheclientapplication"></A>Consuming JSON-RPC services on the client application</H3>
+
+<P>Any JSON-RPC client may be used to access SCA services which use &lt;binding.jsonrpc&gt;, below we are going to describe different ways you could consume the Tuscany JSON-RPC services in your client application.</P>
+
+<H4><A name="SCAJavabinding.jsonrpc-UtilizingTuscanyImplementation.widget"></A>Utilizing Tuscany Implementation.widget</H4>
+
+<P>When your web client application is defined as an SCA component utilizing <A href="sca-java-implementationwidget.html" title="SCA Java implementation.widget">Tuscany Widgets</A>, a JavaScript is generated which may be included within an HTML document to properly inject services references to SCA references defined on the same HTML document.</P>
+
+<P>This script is used by simply including the following tag within the HTML page :</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+&lt;script type=<SPAN class="code-quote">&quot;text/javascript&quot;</SPAN> src=<SPAN class="code-quote">&quot;html-page-name.js&quot;</SPAN> /&gt;
+</PRE>
+</DIV></DIV>
+
+<P>This initializes the proxys for the SCA services which can then be injected into SCA references to make requests to the server-side components. For example, if there was a service named &quot;myService&quot; which had operations &quot;aOnewayRequest&quot; and &quot;anRpcRequest&quot; the scripts in the HTML page could now invoke these operations with the following:</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-comment">//@Reference
+</SPAN><SPAN class="code-keyword">var</SPAN> myService = <SPAN class="code-keyword">new</SPAN> Reference(<SPAN class="code-quote">&quot;myService&quot;</SPAN>);
+myService.aOnewayRequest(args);
+</PRE>
+</DIV></DIV>
+<P>or</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-comment">//@Reference
+</SPAN><SPAN class="code-keyword">var</SPAN> myService = <SPAN class="code-keyword">new</SPAN> JSONRpcClient(<SPAN class="code-quote">&quot;myService&quot;</SPAN>);
+myService.anRpcRequest(args, responseFunction);
+</PRE>
+</DIV></DIV>
+
+<P>Also see <A href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=TUSCANYxDOCx2x&title=SCA%2BJava%2Bimplementation.widget&linkCreation=true&fromPageId=5964964" class="createlink">Tuscany Widgets</A> for more details.</P>
+
+<H4><A name="SCAJavabinding.jsonrpc-UtilizingaJavaScriptClientProxy"></A>Utilizing a JavaScript Client Proxy</H4>
+
+<P>To simplify the task for web browsers developers Tuscany provides a 'binding-jsonrpc.js&quot; JavaScript client proxy code that can be included in your application. </P>
+
+<P>After copying the script to your application, it can be used bu simply including the following tag within the HTML page :</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+&lt;script type=<SPAN class="code-quote">&quot;text/javascript&quot;</SPAN> src=<SPAN class="code-quote">&quot;binding-jsonrpc.js&quot;</SPAN> /&gt;
+</PRE>
+</DIV></DIV>
+
+<P>This initializes the proxys for the SCA services which can then be used make requests to the server-side components. Based on the scenario described above, below are the to invoke these operations.</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-keyword">var</SPAN> myService = <SPAN class="code-keyword">new</SPAN> JSONRpcClient(<SPAN class="code-quote">&quot;Catalog&quot;</SPAN>).service;
+myService.aOnewayRequest(args);
+</PRE>
+</DIV></DIV>
+<P>or</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-keyword">var</SPAN> myService = <SPAN class="code-keyword">new</SPAN> JSONRpcClient(<SPAN class="code-quote">&quot;Catalog&quot;</SPAN>).service;
+myService.anRpcRequest(args, responseFunction);
+</PRE>
+</DIV></DIV>
+
+<H4><A name="SCAJavabinding.jsonrpc-HandlingJSONRPCResponsewithcallbacks"></A>Handling JSON-RPC Response with callbacks</H4>
+
+<P>In that example 'responseFunction' is the name of a function which is called to process the response and which gets called asynchronously on another thread when the response is avaialble. RPC requests are done this way instead of the simpler &quot;answer = myService.anRpcRequest(args)&quot; to avoid hanging the browser while the (potentially slow) request is being processed. An example of the responseFunction for the previous example is:</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+function responseFunction(answer){
+ <SPAN class="code-comment">// <SPAN class="code-keyword">do</SPAN> something with answer
+</SPAN>}
+</PRE>
+</DIV></DIV>
+
+<H4><A name="SCAJavabinding.jsonrpc-Handlingerrors"></A>Handling errors</H4>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-comment">//initialization code
+</SPAN><SPAN class="code-keyword">try</SPAN>{
+ myService.anRpcRequest(args, responseFunction);
+} <SPAN class="code-keyword">catch</SPAN>(e) {
+ <SPAN class="code-comment">//handle error
+</SPAN> alert(e);
+}
+
+function responseFunction(answer, exception){
+ <SPAN class="code-comment">//handle exception information
+</SPAN> <SPAN class="code-keyword">if</SPAN>(exception){
+ alert(exception.message);
+ <SPAN class="code-keyword">return</SPAN>;
+ }
+ <SPAN class="code-comment">// <SPAN class="code-keyword">do</SPAN> something with answer
+</SPAN>}
+
+</PRE>
+</DIV></DIV>
+
+<H4><A name="SCAJavabinding.jsonrpc-UsingSCAJSONRPCserviceswithDojo"></A>Using SCA JSON-RPC services with Dojo</H4>
+
+<P>Apache Tuscany JSON-RPC services provide built-in support for <A href="http://manual.dojotoolkit.org/WikiHome/DojoDotBook/Book9" class="external-link" rel="nofollow">Dojo RPC</A>. The <A href="http://dojotoolkit.org/" class="external-link" rel="nofollow">Dojo</A> toolkit is a popular framework for writing Ajax/Web 2.0 style browser client applications. Tuscany SCA services which use &lt;binding.jsonrpc&gt; will by default support the <A href="http://dojo.jot.com/SMD" class="external-link" rel="nofollow">Simple Method Description (SMD) </A> protocol. SMD is similar to ?wsdl for Web services, entering a service endpoint appended with ?smd will return a SMD descriptor for the service. </P>
+
+<P>Using Tuscany SCA services with Dojo can therefore be as simple as the following:</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+ <SPAN class="code-keyword">var</SPAN> myService = <SPAN class="code-keyword">new</SPAN> dojo.rpc.JsonService(<SPAN class="code-quote">&quot;myService?smd&quot;</SPAN>);
+</PRE>
+</DIV></DIV>
+
+<H4><A name="SCAJavabinding.jsonrpc-Supporteddatatypes"></A>Supported data types</H4>
+
+<P>The JSON-RPC binding utilize the Databinding Framework to provide support for the following data transformations :</P>
+
+<UL>
+ <LI>Primitive Type &lt;==&gt; JSON &lt;==&gt; Primitive Type</LI>
+ <LI>Array of Primitive Type &lt;==&gt; JSON &lt;==&gt; Array of Primitive Type</LI>
+ <LI>Java bean &lt;==&gt; JSON &lt;==&gt; Java bean</LI>
+ <LI>List &lt;==&gt; JSON &lt;==&gt; List</LI>
+ <LI>Map &lt;==&gt; JSON &lt;==&gt; Map</LI>
+ <LI>Set &lt;==&gt; JSON &lt;==&gt; Set</LI>
+</UL>
+
+
+<H4><A name="SCAJavabinding.jsonrpc-Someexamples%3A"></A>Some examples:</H4>
+
+<P>There are two samples showing using &lt;binding.jsonrpc&gt;, one which uses the Dojo Toolkit on the client, and another which uses the Tuscany scaDomain.js script. The samples are <A href="https://svn.apache.org/repos/asf/incubator/tuscany/java/sca/samples/helloworld-dojo/" class="external-link" rel="nofollow">helloworld-dojo</A> and <A href="https://svn.apache.org/repos/asf/incubator/tuscany/java/sca/samples/helloworld-jsonrpc/" class="external-link" rel="nofollow">helloworld-jsonrpc</A>.</P>
+
+
+ </DIV>
+
+ </DIV>
+ </DIV>
+ </TD>
+ </TR>
+ </TABLE>
+
+ <!-- footer -->
+ <TABLE border="0" cellpadding="2" cellspacing="0" width="100%">
+ <TR>
+ <TD align="left" valign="middle" class="footer">
+ &nbsp;&nbsp;
+ <IMG src="http://static.delicious.com/img/delicious.small.gif" height="10" width="10" alt="Delicious">
+ <A href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title),'delicious','toolbar=no,width=550,height=550'); return false;">Bookmark this on Delicious</A>
+ &nbsp;&nbsp;
+ <IMG src="http://digg.com/img/badges/16x16-digg-guy.gif" width="16" height="16" alt="Digg!">
+ <A href="" onclick="window.open('http://digg.com/submit?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)+'&topic=programming');">Digg this</A>
+ <!-- Slicker, but no text
+ <script type="text/javascript">
+ digg_skin = 'icon';
+ digg_window = 'new';
+ digg_title = 'Apache Geronimo v2.2 Documentation : SCA Java binding.jsonrpc';
+ digg_topic = 'programming';
+ </script>
+ <script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
+ -->
+ &nbsp;&nbsp;
+ </TD>
+ <TD align="right" valign="middle" class="footer">
+ <A href="http://cwiki.apache.org/GMOxPMGT/geronimo-privacy-policy.html">Privacy Policy</A>&nbsp;&nbsp;-&nbsp;&nbsp;
+ Copyright &copy; 2003-2010, The Apache Software Foundation, Licensed under <A href="http://www.apache.org/licenses/LICENSE-2.0">ASL 2.0.</A>&nbsp;&nbsp;
+ </TD>
+ </TR>
+ </TABLE>
+
+ </BODY>
+</HTML> \ No newline at end of file