<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Wise-core Programmer Guide (version 1.0)
</h3>
<span style="margin-bottom: 10px;">
    modified by <a href="http://community.jboss.org/people/admin">Administrator Administrator</a> in <i>Wise</i> - <a href="http://community.jboss.org/docs/DOC-12896">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p><div class="toc" style="border: 1px dashed black; padding: 10px;"><ul><li>
<a class="jive-link-anchor-small" href="#1_What_is_wisecore">1. What is wise-core</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#2__Who_should_read_this_guide">2 . Who should read this guide</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#3_API_description">3. API description</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#4_Configurations">4. Configurations</a>
</li>
<ul><li>
<a class="jive-link-anchor-small" href="#41_WiseClientConfiguration">4.1 WiseClientConfiguration</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#42_WSDynamicClientFactory">4.2 WSDynamicClientFactory</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#43_WSConsumer">4.3 WSConsumer</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#44_WSSEHelloWorld">4.4 WSSEHelloWorld</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#45_WSSEDefault">4.5 WSSEDefault</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#46_EnablerDelegate">4.6 EnablerDelegate</a>
</li>
</ul><li>
<a class="jive-link-anchor-small" href="#5_Using_Wise_API">5. Using Wise API</a>
</li>
<ul><li>
<a class="jive-link-anchor-small" href="#51_One_line_of_code_invocation">5.1 One line of code invocation</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#52_Interactively_explore_your_wsdl_objects">5.2 Interactively explore your wsdl objects</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#53_Go_Dynamic_use_Groovy">5.3 Go Dynamic, use Groovy</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#54_Go_Dynamic_use_Ruby">5.4 Go Dynamic, use Ruby</a>
</li>
</ul><li>
<a class="jive-link-anchor-small" href="#6_WiseMapper_from_your_own_object_model_to_the_generated_JAXWS_model_and_vice_versa">6. WiseMapper: from your own object model to the generated JAX-WS model and vice versa</a>
</li>
<ul><li>
<a class="jive-link-anchor-small" href="#61_SmooksWiseMapper">6.1 SmooksWiseMapper</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#62_Writing_your_own_Mapper">6.2 Writing your own Mapper</a>
</li>
</ul><li>
<a class="jive-link-anchor-small" href="#7_Adding_standard_JAXWS_handlers">7. Adding standard JAX-WS handlers</a>
</li>
<ul><li>
<a class="jive-link-anchor-small" href="#71_Logging_Handler">7.1 Logging Handler</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#72_Smooks_Handler">7.2 Smooks Handler</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#73_Adding_your_own_Handler">7.3 Adding your own Handler</a>
</li>
</ul><li>
<a class="jive-link-anchor-small" href="#8_Extensions_WS_and_MTOM">8. Extensions (WS-* and MTOM)</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#9_JAXRS_Client_Support">9. JAX-RS Client Support</a>
</li>
<ul><li>
<a class="jive-link-anchor-small" href="#91_Create_RSDynamicClient">9.1 Create RSDynamicClient</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#92_Return_responses_">9.2 Return responses </a>
</li>
</ul><li>
<a class="jive-link-anchor-small" href="#10_Requirements_and_dependencies">10. Requirements and dependencies</a>
</li>
<ul><li>
<a class="jive-link-anchor-small" href="#101_Special_Note_on_jaxwsrt_and_jbosswsnativejaxws_jars_on_JDK5">10.1 Special Note on jaxws-rt and jbossws-native-jaxws jars on JDK5</a>
</li>
</ul><li>
<a class="jive-link-anchor-small" href="#11_Samples">11. Samples</a>
</li>
<ul><li>
<a class="jive-link-anchor-small" href="#111_AddressingAndSecurity">11.1 AddressingAndSecurity</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#112_HelloWorld">11.2 HelloWorld</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#113_HelloWorldGroovy">11.3 HelloWorldGroovy</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#114_HelloWorldJDK6">11.4 HelloWorldJDK6</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#115_HelloWorldRuby">11.5 HelloWorldRuby</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#116_InteractiveHelloWorldJDK6">11.6 InteractiveHelloWorldJDK6</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#117_jaxrs">11.7 jaxrs</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#118_MTOMSample">11.8 MTOMSample</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#119_UsingSmooks">11.9 UsingSmooks</a>
</li>
</ul></ul></div></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1 id="1_What_is_wisecore">1. What is wise-core</h1><p><span>It is a library to simplify web service invocation from a client point of view aims to&#160; provide a near zero-code solution to find and parse <span>wsdls</span>, select service and endpoint and call operations mapping user defined object model to <span>JAX</span>-WS objects needed to perform the call.</span></p><p>In other words wise-core aims to provide web services client invocation in a dynamic manner.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span>It&rsquo;s matter of fact that <span>wsconsume</span> tools is great for java developer, generating needed stub class, but it introduces a new (or renewed </span><span> :) </span><span>) level of coupling very similar to <span>corba</span> IDL. Generating statically <span>webservice</span> stub you are in fact coupling client and server.</span></p><p>So what is the alternative? Generate these stubs runtime and use dynamic mapping on generated stub.</p><p><span>How wise-core does perform this generic task? In a nutshell it generates </span><span>classes</span><span> on the fly using <span>wsconsume</span> runtime <span>API</span>, loading them in current class loader and uses them with Java Reflection <span>API</span>. </span><span>What we add is a generic mapping <span>API</span> to transform an arbitrary object model in the <span>wsconsume</span> generated ones, make the call and map the answer back again to the custom model using S</span><span class="postbody"><span><span>mooks. Moreover this is achieved keeping the API general enough to </span></span></span><span class="postbody"><span>plug in other <span>mappers</span> (perhaps custom ones) to transform user defined object into <span>JAX</span>-WS generated objects.</span></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span>Wise supports standard <span>JAX</span>-WS handlers too and a generic <span>smooks</span> transformation handler to apply transformation to generated SOAP messages;</span><span> in the next future</span><span> it will also support easy configuration/<span>API</span> to activate various <span>WS</span>-*.</span></p><p>The key to understand the Wise-core idea is to keep in mind it is an API hiding JAX-WS wsconsume tools to generate JAX-WS stub classes and providing API to invoke them in a dynamic way using mappers to convert your own object model to JAX-WS generated one.</p><p>One of the most important aspects of this approach is that Wise delegates everything concerning standards and interoperability to the underlying JAX-WS client implementation (JBossWS in the current implementation). In other words if an hand written webservice client using JBossWS is interoperable and respects standard, the same applies for a Wise-generated client! We are just adding commodities and dynamical transparent generation and access to JAX-WS clients, we are not rewriting client APIs, the well tested and working ones from JBossWS is fine for us <span> ;) </span></p><h1 id="2__Who_should_read_this_guide">2 . Who should read this guide</h1><p><span>This guide is written for developers who would use Wise-core in their own application to call <span>webservices</span>.</span></p><p><span>This guide would be very useful also for programmers and architect using <span>JBossESB</span> and would better understand what is happening under the hood during a zero-code <span>webserive</span> invocation based on Wise.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1 id="3_API_description">3. API description</h1><p><span>We are going to describe here our <span>API</span>, its goals and how it could be used in practice to simplify your <span>webservice</span> client development. Anyway we strongly suggest you to take a look at our <span>javadoc</span> as more complete reference for the <span>API</span>.</span></p><p>The core elements of our API are:</p><ul><li><a class="jive-link-external-small" href="http://www.jboss.org/file-access/default/members/wise/freezone/1.0/apiDocs/org/jboss/wise/core/client/WSDynamicClient.html"><span><span>WSDynamicClient</span></span></a><span>: This is the Wise core class responsible for the invocation of the <span>JAX</span>-WS tools and that handles <span>wsdl</span> retrieval &amp; parsing. It is used to build the list of <span>WSService</span> representing the <span>services</span> published in parsed <span>wsdl</span>.&#160; It can also be <span>used to</span> </span><span>directly</span><span> get the <span>WSMethod</span> to invoke the specified action on specified port of specified service. It is the base method for "one line of code invocation"</span><br/></li><li><a class="jive-link-external-small" href="http://www.jboss.org/file-access/default/members/wise/freezone/1.0/apiDocs/org/jboss/wise/core/client/WSService.html"><span><span>WSService</span></span></a><span>: represents a <span>single</span> service. It can be used to retrieve the current service endpoints (Ports).</span><br/></li><li><a class="jive-link-external-small" href="http://www.jboss.org/file-access/default/members/wise/freezone/1.0/apiDocs/org/jboss/wise/core/client/WSEndpoint.html"><span><span>WSEndpoint</span></span></a>: represents an Endpoint(Port) and has utility methods to edit username, password, endpoint address, attach handlers, etc.<br/></li><li><a class="jive-link-external-small" href="http://www.jboss.org/file-access/default/members/wise/freezone/1.0/apiDocs/org/jboss/wise/core/client/WSMethod.html"><span><span>WSMethod</span></span></a><span>: represents a <span>webservice</span> operation(action) invocation and it always refers to a specific endpoint. It is used for effective invocation of a web service action.</span><br/></li><li><a class="jive-link-external-small" href="http://www.jboss.org/file-access/default/members/wise/freezone/1.0/apiDocs/org/jboss/wise/core/client/WebParameter.html"><span><span>WebParameter</span></span></a>: holds single parameter's data required for an invocation<br/></li><li><a class="jive-link-external-small" href="http://www.jboss.org/file-access/default/members/wise/freezone/1.0/apiDocs/org/jboss/wise/core/client/InvocationResult.html"><span><span>InvocationResult</span></span></a><span>: holds the <span>webservice's</span> invocation result data. Anyway it returns a Map&lt;String, Object&gt; with <span>webservice's</span> call results, eventually applying a&#160; mapping to custom objects using a <span>WiseMapper</span></span><br/></li><li><a class="jive-link-external-small" href="http://www.jboss.org/file-access/default/members/wise/freezone/1.0/apiDocs/org/jboss/wise/core/mapper/WiseMapper.html"><span><span>WiseMapper</span></span></a><span>: is a simple interface implemented by any <span>mapper</span> used within wise-core requiring a single method <span>applyMapping</span>.</span><br/></li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>All the elements mentioned above can be combined and used to perform web service invocation and get results. They basically support two kinds of invocation:</p><ol><li><span>One line of code invocation: with this name we mean a near zero code invocation where developer who have well configured Wise just have to know <span>wsdl</span> location, endpoint and port name to invoke the service and get results. For a complete description and sample of this Wise usecase please refer to paragraph 5.1.</span><br/></li><li><span>Interactively explore your <span>wsdl</span>: Wise can support a more interactive style of <span>development</span> exploring all <span>wsdl</span> artifact dynamically loaded. This kind of use <span></span>is ideal for an interactive ser interface to call the service and is by the way how we are developing our web <span>GUI</span>. For a complete description and sample of this Wise usecase please refer to paragraph 5.2.</span></li></ol><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1 id="4_Configurations">4. Configurations</h1><p><span>Wise-core configurations are provided by <span>JBoss</span> standard inversion of control Micro Container. Wise-core read standard META-<span>INF</span>/jboss-beans.<span>xml</span> from your <span>classpath</span>. We suggest to put them into your jar, but also include a resources dir in your <span>classpath</span> is fine (and in fact is what is done in our samples). A typical <span>jboss</span>-beans.<span>xml</span> for Wise look like this one:</span></p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>

<span class="jive-xml-tag"><span>&lt;deployment xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"
&#160;&#160;&#160;&#160; xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
&#160;&#160;&#160;&#160; xmlns="urn:jboss:bean-deployer"&gt;</span></span>

&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;bean name="WSKernelLocator" class="org.jboss.wise.core.jbossmc.KernelUtil"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;property name="kernel"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;inject bean="jboss.kernel:service=Kernel" /&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/property&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/bean&gt;</span>

&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;bean name="WiseClientConfiguration"
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; class="org.jboss.wise.core.jbossmc.beans.WiseClientConfiguration"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;property name="defaultUserName"&gt;</span>foo<span class="jive-xml-tag">&lt;/property&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;property name="defaultPassword"&gt;</span>pwd<span class="jive-xml-tag">&lt;/property&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;property name="defaultTmpDeployDir"&gt;</span>temp<span class="jive-xml-tag">&lt;/property&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/bean&gt;</span>

&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;bean name="WSDynamicClientFactory"
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; class="org.jboss.wise.core.jbossmc.beans.ReflectionWSDynamicClientFactory"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;property name="config"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;inject bean="WiseClientConfiguration"&gt;</span><span class="jive-xml-tag">&lt;/inject&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/property&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/bean&gt;</span>

&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;bean name="WSConsumer"
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; class="org.jboss.wise.core.consumer.impl.jbosswsnative.WSImportImpl"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;property name="keepSource"&gt;</span>true<span class="jive-xml-tag">&lt;/property&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;property name="verbose"&gt;</span>true<span class="jive-xml-tag">&lt;/property&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/bean&gt;</span>

&#160;&#160;&#160; <span class="jive-xml-tag">&lt;bean name="WSSEHelloWorld"
&#160;&#160;&#160;&#160;&#160;&#160;&#160; class="org.jboss.wise.core.wsextensions.impl.jbosswsnative.NativeSecurityConfig"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;property name="configFileURL"&gt;</span>integration/test/wsse/WEB-INF/jboss-wsse-client.xml<span class="jive-xml-tag">&lt;/property&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;property name="configName"&gt;</span>Standard WSSecurity Endpoint<span class="jive-xml-tag">&lt;/property&gt;</span>
&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/bean&gt;</span>

&#160;&#160;&#160; <span class="jive-xml-tag">&lt;bean name="WSSEDefault"
&#160;&#160;&#160;&#160;&#160;&#160;&#160; class="org.jboss.wise.core.wsextensions.impl.jbosswsnative.NativeSecurityConfig"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;property name="configFileURL"&gt;</span>integration/test/wsse/WEB-INF/jboss-wsse-client.xml<span class="jive-xml-tag">&lt;/property&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;property name="configName"&gt;</span>Standard WSSecurity Client<span class="jive-xml-tag">&lt;/property&gt;</span>
&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/bean&gt;</span>



&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;bean name="EnablerDelegate"
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; class="org.jboss.wise.core.wsextensions.impl.jbosswsnative.ReflectionEnablerDelegate"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;property name="securityConfigMap"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;map class="java.util.HashMap" keyClass="java.lang.String"
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; valueClass="java.lang.String"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;entry&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;key&gt;</span>HelloWorldBeanPort<span class="jive-xml-tag">&lt;/key&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;value&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;inject bean="WSSEHelloWorld" /&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/value&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/entry&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/map&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/property&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;property name="defaultSecurityConfig"&gt;</span><span class="jive-xml-tag">&lt;inject bean="WSSEDefault" /&gt;</span><span class="jive-xml-tag">&lt;/property&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/bean&gt;</span>
<span class="jive-xml-tag">&lt;/deployment&gt;</span>

</code></pre><p><span>Here is a description of bean configured in this file and <span>their</span> valid attribute:</span></p><h2 id="41_WiseClientConfiguration"><span>4.1 <span>WiseClientConfiguration</span></span></h2><p>It contains all default values Wise could use for some common attribute during a call. Of course they can be overridden in the code.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><table border="1" cellpadding="3" cellspacing="0" style="border: 1px solid #000000; width: 95%; height: 138px;"><tbody><tr><th align="center" style="background-color:#6690BC;;border: 1px solid #000000;background-color:#6690BC;" valign="middle"><span style="color: #ffffff;"><strong>Property<br/></strong></span></th><th align="center" style="background-color: #6690bc; text-align: center;;border: 1px solid #000000;background-color: #6690bc; text-align: center;" valign="middle"><span style="color: #ffffff;"><strong>Description<br/></strong></span></th></tr><tr><td style="border: 1px solid #000000;"><span><span>defaultUserName</span></span></td><td style="border: 1px solid #000000;"><span>It's the default user name used to call <span>webservice</span> requiring authentication.</span></td></tr><tr><td style="border: 1px solid #000000;"><span><span>defaultPassword</span></span></td><td style="border: 1px solid #000000;"><span><span>I'ts</span> the <span>default</span> password used to call <span>webservice</span> requiring authentication.</span></td></tr><tr><td style="border: 1px solid #000000;"><span><span>defaultTmpDir</span></span></td><td style="border: 1px solid #000000;"><p><span>It's the temporary directory used by Wise to keep downloaded <span>wsdls</span> and <span>wsconsume</span> generated classes file.</span></p><p><strong><span>It's very important to understand that this directory is cleaned when Wise perform its first call after <span>JVM</span> starts.</span></strong></p><p><strong><span>For this reason you have to provide different <span>tmp</span> dirs if you plan to run wise with more than one <span>JVM</span>.</span></strong></p></td></tr><tr><td style="border: 1px solid #000000;"><span><span>logConfig</span></span></td><td style="border: 1px solid #000000;"><span>It's the location of Wise's log4j <span>config</span> file.</span></td></tr></tbody></table><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2 id="42_WSDynamicClientFactory">4.2 WSDynamicClientFactory</h2><p><span>It injects the client factory implementation, deciding in fact which implementation of Wise <span>API</span> you are using. At the moment we provide just this reflection based implementation, but in near future we will have also a <span>Javassist</span> ones. Of course here you <span>can</span> provide your own implementation and inject it.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2 id="43_WSConsumer"><span>4.3 <span>WSConsumer</span></span></h2><p><span>It injects the <span>WSConsumer</span> implementation, deciding which <span>API</span> you are using to consume the <span>wsdl</span> and generate <span>JAX</span>-WS client classes. At the moment we are providing a org.<span>jboss</span>.wise.core.consumer.<span>impl</span>.jbosswsnative.<span>WSImportImpl</span>. This bean may be used also to set some general properties for class generation:</span></p><table border="1" cellpadding="3" cellspacing="0" style="border: 1px solid #000000; width: 837px; height: 85px;"><tbody><tr><th align="center" style="background-color:#6690BC;;border: 1px solid #000000;background-color:#6690BC;" valign="middle"><span style="color: #ffffff;"><strong>Property</strong></span></th><th align="center" style="background-color:#6690BC;;border: 1px solid #000000;background-color:#6690BC;" valign="middle"><span style="color: #ffffff;"><strong>Description</strong></span></th></tr><tr><td style="border: 1px solid #000000;">verbose</td><td style="border: 1px solid #000000;"><span>boolean value to decide if <span>wsconsume</span> have to use <span>verbose</span> option printing more information during compiling and running classes</span></td></tr><tr><td style="border: 1px solid #000000;"><span><span>keepSource</span></span></td><td style="border: 1px solid #000000;"><p><span>boolean value to decide if Wise has <span>t</span>o keep source java files (and not only .class) in <span>tmp</span> directory. It may be useful to have a look </span>at them in case of problem or debug.</p></td></tr></tbody></table><h2><br/></h2><h2 id="44_WSSEHelloWorld">4.4 WSSEHelloWorld<br/></h2><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>It injects a WS-Security configuration specific for the "HelloWorld" service. See section 4.6 to understand how this configuration is used and&#160; enabled in wise-core.</p><p>This bean isn't required for all WS-Security enabled services because if some service haven't specific config the default configuration is used (see section 4.5). Possible property are:</p><table border="1" cellpadding="3" cellspacing="0" style="border: 1px solid #000000; width: 881px; height: 69px;"><tbody><tr><th align="center" style="background-color:#6690BC;;border: 1px solid #000000;background-color:#6690BC;" valign="middle"><span style="color: #ffffff;"><strong>Property<br/></strong></span></th><th align="center" style="background-color:#6690BC;;border: 1px solid #000000;background-color:#6690BC;" valign="middle"><span style="color: #ffffff;"><strong>Descrition<br/></strong></span></th></tr><tr><td style="border: 1px solid #000000;">configFileURL</td><td style="border: 1px solid #000000;">It is the URL of config file used by JbossWS to enable WS-SE. For more information about this file refer to our samples and/or to <a class="jive-link-external-small" href="http://jbossws.jboss.org/mediawiki/index.php?title=JAX-WS_User_Guide#WS-Security">JBossWS documentation</a></td></tr><tr><td style="border: 1px solid #000000;">configName</td><td style="border: 1px solid #000000;">It is the config name sed by JbossWS to enable WS-SE. For more information about this file refer to our samples and/or to <a class="jive-link-external-small" href="http://jbossws.jboss.org/mediawiki/index.php?title=JAX-WS_User_Guide#WS-Security">JBossWS documentation</a></td></tr></tbody></table><h2><br/></h2><h2 id="45_WSSEDefault">4.5 WSSEDefault</h2><p>It injects a WS-Security default configuration used by services which don't define a specific configuration as described in section 4.5. See also section 4.6 to understand how this configuration is used and&#160; enabled in wise-core.</p><p>Possible property are:</p><table border="1" cellpadding="3" cellspacing="0" style="border: 1px solid #000000; width: 881px; height: 69px;"><tbody><tr><th align="center" style="background-color:#6690BC;;border: 1px solid #000000;background-color:#6690BC;" valign="middle"><span style="color: #ffffff;"><strong>Property<br/></strong></span></th><th align="center" style="background-color:#6690BC;;border: 1px solid #000000;background-color:#6690BC;" valign="middle"><span style="color: #ffffff;"><strong>Descrition<br/></strong></span></th></tr><tr><td style="border: 1px solid #000000;">configFileURL</td><td style="border: 1px solid #000000;">It is the URL of config file used by JbossWS to enable WS-SE. For more information about this file refer to our samples and/or to <a class="jive-link-external-small" href="http://jbossws.jboss.org/mediawiki/index.php?title=JAX-WS_User_Guide#WS-Security">JBossWS documentation</a></td></tr><tr><td style="border: 1px solid #000000;">configName</td><td style="border: 1px solid #000000;">It is the config name sed by JbossWS to enable WS-SE. For more information about this file refer to our samples and/or to <a class="jive-link-external-small" href="http://jbossws.jboss.org/mediawiki/index.php?title=JAX-WS_User_Guide#WS-Security">JBossWS documentation</a></td></tr></tbody></table><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2 id="46_EnablerDelegate">4.6 EnablerDelegate</h2><p>It injects WS-Security configs and link them to right Ports. In other words it enables WS-Security on Ports used as key of securityConfigMap defining also which securityConfig to use for them.</p><p>Possible property are:</p><table border="1" cellpadding="3" cellspacing="0" style="border: 1px solid #000000; width: 881px; height: 69px;"><tbody><tr><th align="center" style="background-color:#6690BC;;border: 1px solid #000000;background-color:#6690BC;" valign="middle"><span style="color: #ffffff;"><strong>Property<br/></strong></span></th><th align="center" style="background-color:#6690BC;;border: 1px solid #000000;background-color:#6690BC;" valign="middle"><span style="color: #ffffff;"><strong>Descrition<br/></strong></span></th></tr><tr><td style="border: 1px solid #000000;">securityConfigMap</td><td style="border: 1px solid #000000;">It inject a java.util.HashMap with PortNames as key and injectig a specif WS-Security configuration bean as value. See also section 4.4</td></tr><tr><td style="border: 1px solid #000000;">defaultSecurityConfig</td><td style="border: 1px solid #000000;">WS-Security default configuration used by services which don't define a specific configuration (not appearing on securityConfigMap). See also section 4.5<a class="jive-link-external-small" href="http://jbossws.jboss.org/mediawiki/index.php?title=JAX-WS_User_Guide#WS-Security">http://jbossws.jboss.org/mediawiki/index.php?title=JAX-WS_User_Guide#WS-Security</a></td></tr></tbody></table><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1 id="5_Using_Wise_API"><span>5. Using Wise <span>API</span></span></h1><p><span>Wise can be used either as near zero code web service invocation framework or as an <span>API</span> to </span><span>(interactively)</span><span> explore <span>wsdl</span> generated objects and then perform the invocation through theselected service/endpoint/port.</span></p><p><span>The first approach is very useful when Wise is integrated in a server side solution, while the second one is ideal when you are building an <span>interactive</span> client with some (or intense) user interaction.</span></p><p><span>By the way the first approach is the one that has been used while integrating Wise in <span>JBossESB</span>, while the second one is the base on which we are building or web based generic interactive client of web service (Wise-<span>webgui</span>).</span></p><h2 id="51_One_line_of_code_invocation">5.1 One line of code invocation</h2><p><span>A sample may be much more clear than a lot of explanation:</span></p><pre class="jive-pre"><code class="jive-code jive-java">WSDynamicClient client = WSDynamicClientFactory.getInstance().getClient(<font color="red">"http://127.0.0.1:8080/HelloWorldJDK6/HelloWorldWSJDK6?wsdl"</font>);
WSMethod method = client.getWSMethod(<font color="red">"HelloWorldWSJDK6Service"</font>, <font color="red">"HelloWorldJDK6Port"</font>, <font color="red">"sayHello"</font>);
HashMap&lt;String, Object&gt; requestMap = <font color="navy"><b>new</b></font> HashMap&lt;String, Object&gt;();
requestMap.put(<font color="red">"toWhom"</font>, <font color="red">"SpiderMan"</font>);
InvocationResult result = method.invoke(requestMap, <font color="navy"><b>null</b></font>);
</code></pre><p>I can already hear you saying: "hey, you said just 1 line of code, not 5!!". Yes, but if you exclude lines 3 and 4 where we are constructing a Map to put in request parameters that are normally build in other ways from your own program, you can easily compact the other 3 lines in just <em>one line of code invocation</em>. By the way keeping 3 lines of code makes the code more readable, but we would remark that conceptually you are writing a single line of code.</p><p>You can find a running sample called <strong><em>HelloWorld</em></strong> using exactly this code in our samples directory (both for JDK5 and JDK6).</p><h2 id="52_Interactively_explore_your_wsdl_objects"><span>5.2 Interactively explore your <span>wsdl</span> objects</span></h2><p>Here too an example would be good:</p><pre class="jive-pre"><code class="jive-code jive-java">WSDynamicClient client = WSDynamicClientFactory.getInstance().getClient(<font color="red">"http://127.0.0.1:8080/InteractiveHelloWorldJDK6/InteractiveHelloWorldWSJDK6?wsdl"</font>);
Map&lt;String, WSService&gt; services = client.processServices();
System.out.println(<font color="red">"Available services are:"</font>);
<font color="navy"><b>for</b></font> (String key : services.keySet()) <font color="navy">{</font>
&#160;&#160;&#160; System.out.println(key);
<font color="navy">}</font>
System.out.println(<font color="red">"Selecting the first one"</font>);
Map&lt;String, WSEndpoint&gt; endpoints = services.values().iterator().next().processEndpoints();
System.out.println(<font color="red">"Available endpoints are:"</font>);
<font color="navy"><b>for</b></font> (String key : endpoints.keySet()) <font color="navy">{</font>
&#160;&#160;&#160; System.out.println(key);
<font color="navy">}</font>
System.out.println(<font color="red">"Selecting the first one"</font>);
Map&lt;String, WSMethod&gt; methods = endpoints.values().iterator().next().getWSMethods();
System.out.println(<font color="red">"Available methods are:"</font>);
<font color="navy"><b>for</b></font> (String key : methods.keySet()) <font color="navy">{</font>
&#160;&#160;&#160; System.out.println(key);
<font color="navy">}</font>
System.out.println(<font color="red">"Selecting the first one"</font>);
WSMethod method = methods.values().iterator().next();
HashMap&lt;String, Object&gt; requestMap = <font color="navy"><b>new</b></font> HashMap&lt;String, Object&gt;();
requestMap.put(<font color="red">"toWhom"</font>, <font color="red">"SpiderMan"</font>);
InvocationResult result = method.invoke(requestMap, <font color="navy"><b>null</b></font>);
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>You can find a running sample called<em><strong> IntercativeHelloWorld</strong></em> using exactly this code in our samples directory.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2 id="53_Go_Dynamic_use_Groovy">5.3 Go Dynamic, use Groovy</h2><p>Yes, Wise supports Groovy. We have a sample in our code base invoking HelloWorld from a Groovy script. We also have an example using closure to invoke a web service through Wise, just changing the input parameters to demonstrate how much Wise can be efficient caching all artifacts and having performance very similar to what you get with native use of JAX-WS client classes after the first invocation.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>But supporting Groovy means much more than this. Groovy is an high dynamic language and so it can be used to inspect dynamically generated classes. In other words with Groovy you can avoid to use Wise mappers, directly and dynamically using our generated classes. We will provide much more documentation and samples in next releases of Wise; until then, just use your creativity, and contribute reporting your experiments in the user forums.</p><p>But why using Wise from Groovy? Haven't Groovy its own web service client? Yes, but with Wise you will have a client for Groovy certified for JAX-WS standard, supporting authentication, MTOM, standard JAX-WS handlers, and of course WS-*.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2 id="54_Go_Dynamic_use_Ruby">5.4 Go Dynamic, use Ruby<br/></h2><p>Yes, Wise supports Ruby too (through JRuby). We have a sample in our code base invoking HelloWorld from a Ruby script. We also have an example using closure to invoke a web service through Wise, just changing the input parameters to demonstrate how much Wise can be efficient caching all artifacts and having performance very similar to what you get with native use of JAX-WS client classes after the first invocation.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>But, as for Groovy, supporting Ruby means much more than this. With a so muchhigh dynamic language you could inspect dynamically generated classes. In other words with Ruby you can avoid to use Wise mappers, directly and dynamically using our generated classes. We will provide much more documentation and samples in next releases of Wise; until then, just use your creativity, and contribute reporting your experiments in the user forums.</p><p>But why using Wise from Ruby? Haven't Ruby its own web service client? Yes, but with Wise you will have a client for Ruby certified for JAX-WS standard, supporting authentication, MTOM, standard JAX-WS handlers, and of course WS-*.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1 id="6_WiseMapper_from_your_own_object_model_to_the_generated_JAXWS_model_and_vice_versa"><span>6. <span>WiseMapper</span>: from your own object model to the generated <span>JAX</span>-WS model and <span>vice versa</span></span></h1><p>The core idea of Wise is to permit users to call webservice using their own object model, loading at runtime (and hiding) the JAX-WS generated client classes. Of course developers who have a complex object model and/or using a webservice with a complex model have to provide some kind of mapping between them.</p><p>This task is done by applying a WiseMapper which is responsible of this mapping. Mappers are applied both to WSMethod invocation and results coming from InvocationResult. Of course the first one maps from the custom model to the JAX-WS one, while the second takes care of the other way.</p><p>Wise provide a <a class="jive-link-external-small" href="http://milyn.codehaus.org/Smooks">Smooks</a> based mapper, but it should be easy to write your own.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2 id="61_SmooksWiseMapper">6.1 SmooksWiseMapper</h2><p>For any information about Smooks and its own configuration file please refer to <a class="jive-link-external-small" href="http://milyn.codehaus.org/Smooks+Documentation">its own documentation</a></p><p>When writing a Smooks config file to use with Wise, you need to consider that the object model generated by JAX-WS tools isn't available at compile time since Wise generates it at runtime. Even if in most cases you can infer the JAX-WS generated classes and properties names from the wsdl document, sometimes it might be useful to set keepSource = true in Wise's jboss-beans.xml to have the opportunity to take a look to generated classes.</p><p>We provide a sample demonstrating use of smooks mapper in our code base named <em><strong>usingSmooks</strong></em>.</p><h2 id="62_Writing_your_own_Mapper"><span>6.2 Writing your own <span>Mapper</span></span></h2><p>You just have to implement <a class="jive-link-external-small" href="http://www.jboss.org/file-access/default/members/wise/freezone/1.0/apiDocs/org/jboss/wise/core/mapper/WiseMapper.html">WiseMapper interface.</a></p><h1 id="7_Adding_standard_JAXWS_handlers">7. Adding standard JAX-WS handlers</h1><p>WSEndPoint class has a method to add standard JAX-WS handlers to the endpoint. Wise takes care of the handler chain construction and ensures your client side handlers are fired during any invocations.</p><p>We provide two standard handlers: one to log the request/response SOAP message for any invocation and one applying Smooks transformation on your SOAP content.</p><h2 id="71_Logging_Handler">7.1 <a class="jive-link-external-small" href="http://www.jboss.org/file-access/default/members/wise/freezone/1.0/apiDocs/org/jboss/wise/core/handlers/LoggingHandler.html">Logging Handler</a></h2><p>This simple SOAPHandler will output the contents of incoming and outgoing messages. It checks the MESSAGE_OUTBOUND_PROPERTY in the context to see if this is an outgoing or incoming message. Finally, it writes a brief message to the print stream and outputs the message.</p><h2 id="72_Smooks_Handler">7.2 <a class="jive-link-external-small" href="http://www.jboss.org/file-access/default/members/wise/freezone/1.0/apiDocs/org/jboss/wise/core/handlers/SmooksHandler.html">Smooks Handler</a></h2><p>A SOAPHandler extension. It applies Smooks transformations on SOAP messages. The transformation can also use freemarker, using provided javaBeans map to get values. It can apply transformation on inbound messages only, outbound ones only or both, depending on setInBoundHandlingEnabled(boolean) and setOutBoundHandlingEnabled(boolean) methods.</p><p>Take a look at our unit test org.jboss.wise.core.mapper.SmooksMapperTest in test-src directory.</p><h2 id="73_Adding_your_own_Handler">7.3 Adding your own Handler</h2><p>Since Wise's handlers are JAX-WS standard handlers, you just have to provide a class that implements SOAPHandler&lt;SOAPMessageContext&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1 id="8_Extensions_WS_and_MTOM">8. Extensions (WS-* and MTOM)</h1><p>We tried to respect the Wise's easy to use approach also designing APIs to enable and use most common extensions (MTOM and WS-*) in Wise.</p><p>There are in Wise's API an interface (<a class="jive-link-external-small" href="http://www.jboss.org/file-access/default/members/wise/freezone/1.0/apiDocs/org/jboss/wise/core/wsextensions/WSExtensionEnabler.html">WSExtensionEnabler</a>) defining a WSExtension to be enabled on an endpoint using wise-core client APIs. The basic idea is to add&#160; all WSExtension you want to enable to a <a class="jive-link-external-small" href="../../../file-access/default/members/wise/freezone/1.0/apiDocs/org/jboss/wise/core/client/WSEndpoint.html"><code>WSEndpoint</code></a> using addWSExtension method. WSExtension implementation are meant to&#160; be pure declarative class delegating all their operations to a "visitor" class injected into the system with IOC Different&#160; Visitors implement <a class="jive-link-external-small" href="../../../file-access/default/members/wise/freezone/1.0/apiDocs/org/jboss/wise/core/wsextensions/EnablerDelegate.html"><code>EnablerDelegate</code></a> and have to take care to implement necessary steps to implement various WSExtension&#160; for the JAXWS implementation for which they are supposed to work.</p><p>A snippet of use may clarify how much simple it can be from API's user poit of view</p><pre class="jive-pre"><code class="jive-code jive-java">WSDynamicClient client = WSDynamicClientFactory.getInstance().getJAXWSClient(<font color="red">"http://127.0.0.1:8080/MTOMSample/MTOMWS?wsdl"</font>);
WSMethod method = client.getWSMethod(<font color="red">"MTOMWSService"</font>, <font color="red">"MTOMPort"</font>, <font color="red">"sayHello"</font>);
method.getEndpoint().addWSExtension(<font color="navy"><b>new</b></font> MTOMEnabler());
</code></pre><p>It enable mtom on <em>MTOMPort</em> endpoint.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The same can be applied for example to easily enable both WSSecurity and WSAddressing on endpoint. Take a look to this amazing snippet:</p><pre class="jive-pre"><code class="jive-code jive-java">WSDynamicClient client = WSDynamicClientFactory.getInstance().getJAXWSClient(<font color="red">"http://127.0.0.1:8080/AddressingAndSecuritySample?wsdl"</font>);
WSMethod method = client.getWSMethod(<font color="red">"EndpointImplService"</font>, <font color="red">"EndpointImplPort"</font>, <font color="red">"sayHello"</font>);
method.getEndpoint().addWSExtension(<font color="navy"><b>new</b></font> WSSecurityEnabler());
method.getEndpoint().addWSExtension(<font color="navy"><b>new</b></font> WSAddressingEnabler());
</code></pre><p>These few lines of code and some easy configs for WSSecurity (see section 4.4, 4.5 and 4.6) are all what you need to enable WS-SE and WS-A!</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Take a look to our samples to get some complete working code about (section 10)</p><p>We plan to support in the same manner also some other WS-* in future versions.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1 id="9_JAXRS_Client_Support">9. JAX-RS Client Support<br/></h1><p>WISE has a preliminary JAX-RS client support to allow writing clients that can invoke JAX-RS services. The code snippet below showed how this works:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="darkgreen">// Sent HTTP GET request to query customer info</font>
System.out.println(<font color="red">"Sent HTTP GET request to query customer info"</font>);
RSDynamicClient client = WSDynamicClientFactory.getInstance().getJAXRSClient(
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="red">"http://localhost:9000/customerservice/customers/123"</font>,
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; RSDynamicClient.HttpMethod.GET, null,
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="red">"application/xml"</font>);
InvocationResult result = client.invoke();
String response = (String) result.getResult().get(InvocationResult.RESPONSE);
System.out.println(response);
&#160;
&#160;
<font color="darkgreen">// Sent HTTP PUT request to update customer info</font>
System.out.println(<font color="red">"\n"</font>);
System.out.println(<font color="red">"Sent HTTP PUT request to update customer info"</font>);
client = WSDynamicClientFactory.getInstance().getJAXRSClient(
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="red">"http://localhost:9000/customerservice/customers"</font>,
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; RSDynamicClient.HttpMethod.PUT, <font color="red">"application/xml"</font>,
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="red">"application/xml"</font>);
JaxrsClient jaxrsClient = <font color="navy"><b>new</b></font> JaxrsClient();
InputStream request = jaxrsClient.getClass().getResourceAsStream(<font color="red">"resources/update_customer.xml"</font>);
result = client.invoke(request, <font color="navy"><b>null</b></font>);
response = (String) result.getResult().get(InvocationResult.RESPONSE);
<font color="navy"><b>int</b></font> statusCode = ((Integer) result.getResult().get(InvocationResult.STATUS)).intValue();
System.out.println(<font color="red">"Response status code: "</font> + statusCode);
System.out.println(<font color="red">"Response body: "</font>);
System.out.println(response);
&#160;
&#160;
&#160;
<font color="darkgreen">// Sent HTTP POST request to add customer</font>
System.out.println(<font color="red">"\n"</font>);
System.out.println(<font color="red">"Sent HTTP POST request to add customer"</font>);
client = WSDynamicClientFactory.getInstance().getJAXRSClient(
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="red">"http://localhost:9000/customerservice/customers"</font>,
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; RSDynamicClient.HttpMethod.POST, <font color="red">"application/xml"</font>,
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="red">"application/xml"</font>);
request = jaxrsClient.getClass().getResourceAsStream(<font color="red">"resources/add_customer.xml"</font>);
result = client.invoke(request, <font color="navy"><b>null</b></font>);
response = (String) result.getResult().get(InvocationResult.RESPONSE);
statusCode = ((Integer) result.getResult().get(InvocationResult.STATUS)).intValue();
&#160;
&#160;
System.out.println(<font color="red">"Response status code: "</font> + statusCode);
System.out.println(<font color="red">"Response body: "</font>);
System.out.println(response);
&#160;
</code></pre><h2 id="91_Create_RSDynamicClient">9.1 Create RSDynamicClient</h2><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The main interface you need to use is the getJAXRSClient method from WSDynamicClientFactory. See below:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">&#160;&#160;&#160; <font color="darkgreen">/**
&#160;&#160;&#160;&#160; * Return an instance of RSDynamicClient taken from cache if possible, generate and initialise if not.
&#160;&#160;&#160;&#160; *
&#160;&#160;&#160;&#160; * @param endpointURL
&#160;&#160;&#160;&#160; * @param httpMethod
&#160;&#160;&#160;&#160; * @param produceMediaTypes
&#160;&#160;&#160;&#160; * @param consumeMediaTypes
&#160;&#160;&#160;&#160; * @return an instance of {@link RSDynamicClient} already initialized, ready to be called
&#160;&#160;&#160;&#160; */</font>
&#160;&#160;&#160; <font color="navy"><b>public</b></font> RSDynamicClient getJAXRSClient( String endpointURL,
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; RSDynamicClient.HttpMethod httpMethod,
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; String produceMediaTypes,
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; String consumeMediaTypes ) <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; ......
&#160;
&#160;&#160;&#160; <font color="navy">}</font>
&#160;
</code></pre><h2 id="92_Return_responses_">9.2 Return responses <br/></h2><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Get the response body:</p><pre class="jive-pre"><code class="jive-code jive-java">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; InvocationResult result = client.invoke();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; String response = (String) result.getResult().get(InvocationResult.RESPONSE);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println(response);
&#160;
</code></pre><p>Get the response code:</p><pre class="jive-pre"><code class="jive-code jive-java">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; InvocationResult result = client.invoke(request, <font color="navy"><b>null</b></font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; String response = (String) result.getResult().get(InvocationResult.RESPONSE);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>int</b></font> statusCode = ((Integer) result.getResult().get(InvocationResult.STATUS)).intValue();
&#160;
</code></pre><p>Get the response headers:</p><pre class="jive-pre"><code class="jive-code jive-java">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Not supported yet in <font color="navy"><b>this</b></font> version
&#160;
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1 id="10_Requirements_and_dependencies">10. Requirements and dependencies</h1><p>The current implementation depends on JBossWS. Take a look to our samples to better understand which libraries are required.</p><p>A special note is needed about some JAX-WS jars included, since it have been slightly modified to make Wise and JBossWS client work properly.</p><h2 id="101_Special_Note_on_jaxwsrt_and_jbosswsnativejaxws_jars_on_JDK5">10.1 Special Note on jaxws-rt and jbossws-native-jaxws jars on JDK5<br/></h2><div class="action-body">The problem is caused because JBossWS uses 2 different jaxws provider impl (one for tooling, the Sun's RI, and one for everything else, it's own implementation) Of course due to the spi mechanism of loading provider, you can't have both in classpath since the one loaded first takes prevalence on the other. Chaper 6.2.1 of JAX-WS 2.0 specification defines also the algorithm to load this Provider: <br/></div><blockquote class="jive-quote"><div class="action-body"><br/></div><div class="action-body">/**<br/>&#160;&#160;&#160; * This method uses the algorithm below using the JAXWS Provider as an example.<br/>&#160;&#160;&#160; * <br/>&#160;&#160;&#160; * 1. If a resource with the name of META-INF/services/javax.xml.ws.spi.Provider exists, then<br/>&#160;&#160;&#160; * its first line, if present, is used as the UTF-8 encoded name of the implementation class.<br/>&#160;&#160;&#160; * <br/>&#160;&#160;&#160; * 2. If the ${java.home}/lib/jaxws.properties file exists and it is readable by the <br/>&#160;&#160;&#160; * java.util.Properties.load(InputStream) method and it contains an entry whose key is <br/>&#160;&#160;&#160; * javax.xml.ws.spi.Provider, then the value of that entry is used as the name of the implementation class.<br/>&#160;&#160;&#160; * <br/>&#160;&#160;&#160; * 3. If a system property with the name javax.xml.ws.spi.Provider is defined, then its value is used<br/>&#160;&#160;&#160; * as the name of the implementation class.<br/>&#160;&#160;&#160; * <br/>&#160;&#160;&#160; * 4. Finally, a default implementation class name is used.<br/>&#160;&#160;&#160; */<br/></div></blockquote><div class="action-body"> </div><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>For this reason, in order to use both implementations, Wise requires modified jar artifacts without the META-INF/services/javax.xml.ws.spi.Provider file; then the Provider implementation to be used is set in WSImporterImpl through a System property.</p><div class="action-body">In practise this means you have to use the version of this two libraries that we ship with Wise and not those provided by JBossWS or other sources.</div><div class="action-body">The problem isn't present with JDK6 since it uses its internal JAX-WS implementation (coming with the JDK) which uses the same provider used by wsconsume tool avoiding any kind of conflict.</div><div class="action-body"><h2><br/></h2></div><h1 id="11_Samples">11. Samples</h1><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>We have a set of samples demonstrating how to use wise in a standalone application. We have reported here the full list of samples, describing only ones which need some specific description.</p><p>Please refer to JBossESB quickstar samples for Wise/ESB integration example of use.What you find in this section is also available in samples README.txt for your convenience.</p><p><br/>Any directory, except lib and ant ones, contains a single example. Directory name would suggest which kind of test you will find in. Only in case we think example needs a further explanation you will find a local README.txt inside its directory.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>lib directory contains library referred by examples. ant directory contains build.xml imported from all examples' build.xml.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>How to run examples?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>1. Enter in specific example directory <span> ;) </span></p><p>2. Edit resources/META-INF/jboss-beans.xml and change properties according to your environment (i.e defaultTmpDeployDir) if needed.</p><p>3. Edit resources/META-INF/wise-log4j.xml and change properties according to your environment if needed.</p><p>4. Edit build.properties changing "JBossHome" and "ServerConfig" property to point to your JBossAS instance<br/>5. Start your JBossAS instance (of course it have to provide JBossWS)<br/>6. type "ant deployTestWS" to deploy server side content (aka the ws against example will run)<br/>7. type "ant runTest" to run the client side example<br/>8. type "ant undeployTestWS" to undeploy server side content<br/>9. Have a look to the code.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If something changes for a specific example you will find instructions on local README.txt</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>have fun.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2 id="111_AddressingAndSecurity">11.1 AddressingAndSecurity</h2><p>This sample demonstrate the WS-* enabler capabilities of wise-core (see section 8 for a complete description). Please focus your attention on jboss-beans.xml configuration (see section 4 for a complete description and specific subsection 4.4, 4.5, 4.6) and on the client's code.</p><h2 id="112_HelloWorld">11.2 HelloWorld</h2><p>This the basic sample of use of wise-core using a one-line-of-code style (see section 5.1). It use JDK 5 and jbossws as its base.</p><h2 id="113_HelloWorldGroovy">11.3 HelloWorldGroovy</h2><p>The same of previous sample, but using groovy (see section 5.3)</p><p>Groovy include in its botloader directory ($GROOVY_HOME/lib) xpp.jar XML Pull Parser. <br/>It conflicts with xercesImpl.jar needed by jbossws and more general by jaxws. If it is happenning you would get this exception:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Caught: java.lang.LinkageError: loader constraint violation: loader (instance of &lt;bootloader&gt;) previously initiated loading for a different type with name "javax/xml/namespace/QName"<br/>java.lang.LinkageError: loader constraint violation: loader (instance of &lt;bootloader&gt;) previously initiated loading for a different type with name "javax/xml/namespace/QName"</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>To solve the problem you have to remove or rename this file before use wise directly within an interpreted script.<br/>Of course it isn't a problem if you compile script with groovyc since it will compile it in java bytecode<br/>and class loading will depend only by jvm used to launch the compiled application.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Then run runGroovyJDK6.sh and have fun. <br/>If you want to see groovy's closures in action with Wise run runGroovyClosure.sh</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If you would use this example compiling groovy script in bytecode and then run please type "ant compileGroovy"<br/>before type "ant runTest". And please note this example have 2 different script (i.e. compiled <br/>classes that can act as Main). Select which one you would run editing locale build.xml file.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2 id="114_HelloWorldJDK6">11.4 HelloWorldJDK6</h2><div class="action-body">The same of 10.2, but using JDK6 and its own native JAX-WS client libraries. It doesen't need jbossws for client side. (see also section 9.1)<br/><h2 id="115_HelloWorldRuby">11.5 HelloWorldRuby</h2><p>The same of 10.2, but using Ruby (see section 5.4)</p><p>To run this sample edit runJRubyJDK6.sh and set your JRUBY_PATH.<br/>Then run runGroovyJDK6.sh and have fun. <br/>If you want to see groovy's closures in action with Wise edit and then run runGroovyClosure.sh</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></div><h2 id="116_InteractiveHelloWorldJDK6">11.6 InteractiveHelloWorldJDK6</h2><p>This the basic sample of use of wise-core using a interactive style (see section 5.2)</p><h2 id="117_jaxrs">11.7 jaxrs</h2><p>AX-RS Client API Demo <br/>======================</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The demo shows how to use WISE JAX-RS client API to invoke JAX-RS services.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><br/>Prerequisites<br/>-------------</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Apache CXF 2.2 snapshot. WISE JAX-RS client API can work with any JAX-RS (JSR-311)<br/>compliant implementations. This sample chooses Apache CXF for the purpose of<br/>demostration.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><br/>Building and running the demo using Ant<br/>---------------------------------------</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>1. Download and install Apache CXF 2.2 snapshot. <br/>2. Start CXF JAX-RS server from &lt;CXF-installation-dir&gt;\samples\jax_rs\basic directory. <br/>3. From the base directory of this sample (i.e., where this README file is<br/>located), the Ant build.xml file can be used to build and run the demo. <br/>The client target automatically build the demo.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Using either UNIX or Windows:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160; ant runTest</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>To remove the .class files generated, run "ant clean".</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><br/>What Happened<br/>-------------<br/>Examine JaxrsClient.java, compare it with the client codes used by CXF jax_rs\basic to <br/>understand how WISE JAX-RS client API can simplify the invocation of JAX-RS service.</p><h2 id="118_MTOMSample">11.8 MTOMSample</h2><p>This sample demonstrate the MTOM enabler capabilities of wise-core (see section 8 for a complete description). Have a look also to this issue <a class="jive-link-external-small" href="https://jira.jboss.org/jira/browse/WISE-45">https://jira.jboss.org/jira/browse/WISE-45</a></p><h2 id="119_UsingSmooks">11.9 UsingSmooks</h2><p>This sample demonstrate the full power of smooks mapper (see section 6.1). Please focus your attention on smooks-config-* files.</p><div class="action-body"><br/></div></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Comment by <a href="http://community.jboss.org/docs/DOC-12896">going to Community</a></p>

        <p style="margin: 0;">Create a new document in Wise at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2048">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>