You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by js...@apache.org on 2006/06/30 19:59:44 UTC

svn commit: r418345 - /incubator/servicemix/site/client-api.html

Author: jstrachan
Date: Fri Jun 30 10:59:43 2006
New Revision: 418345

URL: http://svn.apache.org/viewvc?rev=418345&view=rev
Log:
Latest export from confluence

Modified:
    incubator/servicemix/site/client-api.html

Modified: incubator/servicemix/site/client-api.html
URL: http://svn.apache.org/viewvc/incubator/servicemix/site/client-api.html?rev=418345&r1=418344&r2=418345&view=diff
==============================================================================
--- incubator/servicemix/site/client-api.html (original)
+++ incubator/servicemix/site/client-api.html Fri Jun 30 10:59:43 2006
@@ -224,8 +224,7 @@
 <!--          
             <div class="pagetitle">Client API</div>
 -->
-            <DIV class="wiki-content">
-<P>To make it simpler to use as an end user, we&apos;ve created a JBI <SPAN class="nobr"><A href="http://servicemix.org/maven/servicemix-core/apidocs/org/apache/servicemix/client/ServiceMixClient.html" title="Visit page outside Confluence" rel="nofollow">Client API<SUP><IMG class="rendericon" src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0" width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN> which makes it easy to work with any JBI container and other JBI components.</P>
+            <DIV class="wiki-content"><P>To make it simpler to use as an end user, we&apos;ve created a JBI <SPAN class="nobr"><A href="http://servicemix.org/maven/servicemix-core/apidocs/org/apache/servicemix/client/ServiceMixClient.html" title="Visit page outside Confluence" rel="nofollow">Client API<SUP><IMG class="rendericon" src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0" width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN> which makes it easy to work with any JBI container and other JBI components.</P>
 
 <P>The JavaDoc is probably self evident for many things, especially if you are aware of the JBI APIs. There is an <SPAN class="nobr"><A href="http://servicemix.codehaus.org/maven/servicemix-core/xref-test/org/apache/servicemix/client/ServiceMixClientTest.html" title="Visit page outside Confluence" rel="nofollow">example test case<SUP><IMG class="rendericon" src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0" width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN> which shows many of these APIs in action.</P>
 
@@ -275,6 +274,51 @@
 NormalizedMessage outMessage = exchange.getOutMessage();</PRE>
 </DIV></DIV>
 
+<H2><A name="ClientAPI-WorkingwithURIsandDestinations"></A>Working with URIs and Destinations</H2>
+
+<P>ServiceMix has integrated support for <A href="uris.html" title="URIs">URIs</A> to simplify the accessing of endpoints within the <A href="nmr.html" title="NMR">NMR</A>. The ServiceMixClient (from 3.0-M3 or later) allows you to work with URIs easily via a Destination interface. This interface acts as a factory of MessageExchange objects which are pre-wired to specific endpoints specified via a URI.</P>
+
+<P>The following shows how to work with InOnly for one way messaging</P>
+
+<DIV class="code"><DIV class="codeContent">
+<PRE class="code-java">Destination destination = client.createDestination(<SPAN class="code-quote">&quot;service:http:<SPAN class="code-comment">//servicemix.org/cheese/receiver&quot;</SPAN>);
+</SPAN>InOnly exchange = destination.createInOnlyExchange();
+
+NormalizedMessage message = exchange.getInMessage();
+message.setProperty(<SPAN class="code-quote">&quot;name&quot;</SPAN>, <SPAN class="code-quote">&quot;James&quot;</SPAN>);
+message.setContent(<SPAN class="code-keyword">new</SPAN> StreamSource(<SPAN class="code-keyword">new</SPAN> StringReader(<SPAN class="code-quote">&quot;&lt;hello&gt;world&lt;/hello&gt;&quot;</SPAN>)));
+
+client.send(exchange);</PRE>
+</DIV></DIV>
+
+<P>Or using InOut for request-response</P>
+
+<DIV class="code"><DIV class="codeContent">
+<PRE class="code-java">Destination destination = client.createDestination(<SPAN class="code-quote">&quot;service:http:<SPAN class="code-comment">//servicemix.org/cheese/myService&quot;</SPAN>);
+</SPAN>InOut exchange = destination.createInOutExchange();
+
+NormalizedMessage request = exchange.getInMessage();
+request.setProperty(<SPAN class="code-quote">&quot;name&quot;</SPAN>, <SPAN class="code-quote">&quot;James&quot;</SPAN>);
+request.setContent(<SPAN class="code-keyword">new</SPAN> StreamSource(<SPAN class="code-keyword">new</SPAN> StringReader(<SPAN class="code-quote">&quot;&lt;hello&gt;world&lt;/hello&gt;&quot;</SPAN>)));
+
+client.sendSync(exchange);
+
+NormalizedMessage response = exchange.getOutMessage();</PRE>
+</DIV></DIV>
+
+<H3><A name="ClientAPI-SimpleronewaymessagingwithDestinations"></A>Simpler one-way messaging with Destinations</H3>
+
+<P>For one-way messaging its sometimes simpler to just work with a Message instance (you can always refer to the MessageExchange via the getExchange() method if need be). For example</P>
+
+<DIV class="code"><DIV class="codeContent">
+<PRE class="code-java">Destination destination = client.createDestination(<SPAN class="code-quote">&quot;service:http:<SPAN class="code-comment">//servicemix.org/cheese/receiver&quot;</SPAN>);
+</SPAN>Message message = destination.createInOnlyMessage();
+message.setProperty(<SPAN class="code-quote">&quot;name&quot;</SPAN>, <SPAN class="code-quote">&quot;James&quot;</SPAN>);
+message.setBody(<SPAN class="code-quote">&quot;&lt;hello&gt;world&lt;/hello&gt;&quot;</SPAN>);
+
+client.send(message);</PRE>
+</DIV></DIV>
+
 <H2><A name="ClientAPI-UsingthePOJOmethods"></A>Using the POJO methods</H2>
 
 <P>We provide a few helper POJO based methods to allow you to use JBI using regular POJOs to hide some of the XML marshaling detail. Then you can use a plugable <SPAN class="nobr"><A href="http://servicemix.codehaus.org/maven/apidocs/org/servicemix/client/Marshaler.html" title="Visit page outside Confluence" rel="nofollow">Marshaler<SUP><IMG class="rendericon" src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0" width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN> to map your POJOs to JAXP Sources.</P>
@@ -341,8 +385,8 @@
     </DIV>
     <DIV id="site-footer">
           Added by     <A href="http://goopen.org/confluence/users/viewuserprofile.action?username=jstrachan">James Strachan</A>,
-    last edited by     <A href="http://goopen.org/confluence/users/viewuserprofile.action?username=gnodet">Guillaume Nodet</A> on May 11, 2006
-                  &nbsp;(<A href="http://goopen.org/confluence/pages/diffpages.action?pageId=1957&originalId=5264">view change</A>)
+    last edited by     <A href="http://goopen.org/confluence/users/viewuserprofile.action?username=jstrachan">James Strachan</A> on Jun 30, 2006
+                  &nbsp;(<A href="http://goopen.org/confluence/pages/diffpages.action?pageId=1957&originalId=8914">view change</A>)
               
       (<A href="http://goopen.org/confluence/pages/editpage.action?pageId=1957">edit page</A>)
     </DIV>