You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by bu...@apache.org on 2012/02/19 02:30:13 UTC
svn commit: r805304 - in /websites/staging/openejb/trunk: ./
content/examples-trunk/webservice-holder/
content/examples-trunk/webservice-holder/src/
content/examples-trunk/webservice-holder/src/main/
content/examples-trunk/webservice-holder/src/main/ja...
Author: buildbot
Date: Sun Feb 19 01:30:12 2012
New Revision: 805304
Log:
Staging update by buildbot for openejb
Added:
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/README.html
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/build.xml
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/pom.xml
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/main/
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/main/java/
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/main/java/org/
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/main/java/org/superbiz/
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/main/java/org/superbiz/ws/
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/main/java/org/superbiz/ws/out/
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/main/java/org/superbiz/ws/out/Calculator.java
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/main/java/org/superbiz/ws/out/CalculatorWs.java
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/test/
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/test/java/
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/test/java/org/
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/test/java/org/superbiz/
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/test/java/org/superbiz/ws/
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/test/java/org/superbiz/ws/out/
websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/test/java/org/superbiz/ws/out/CalculatorTest.java
Modified:
websites/staging/openejb/trunk/ (props changed)
Propchange: websites/staging/openejb/trunk/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Sun Feb 19 01:30:12 2012
@@ -1 +1 @@
-1290866
+1290918
Added: websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/README.html
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/README.html (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/README.html Sun Feb 19 01:30:12 2012
@@ -0,0 +1,342 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+
+ <meta charset="utf-8">
+ <title>@WebService OUT params with @WebParam and JAX-WS Holder</title>
+ <meta name="description" content="">
+ <meta name="author" content="">
+
+ <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
+ <!--[if lt IE 9]>
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+
+ <!-- Le styles -->
+ <link href="./../../bootstrap.css" rel="stylesheet">
+ <link href="./../../prettify.css" rel="stylesheet">
+ <link href="./../../bootstrap-mods.css" rel="stylesheet">
+
+ <style type="text/css">
+ body {
+ padding-top: 60px;
+ }
+ .sprite {
+ display: inline-block;
+ height: 20px;
+ margin: 0 auto 4px;
+ outline: medium none;
+ text-indent: -999em;
+ width: 24px;
+ background-image: url('./../../images/sprites.png');
+ background-repeat: no-repeat;
+ overflow: hidden;
+ cursor: pointer;
+ }
+ .fb-share {
+ background-position: 0px -40px;
+ }
+ .gp-share {
+ background-position: 0px 0px;
+ }
+ .tw-share {
+ background-position: 0px -80px;
+ }
+ </style>
+ <script type="text/javascript">
+ function fbshare () {
+ window.open(
+ "http://www.facebook.com/sharer/sharer.php?u="+document.URL,
+ 'Share on Facebook',
+ 'width=640,height=426');
+ };
+ function gpshare () {
+ window.open(
+ "https://plus.google.com/share?url="+document.URL,
+ 'Share on Google+',
+ 'width=584,height=385');
+ };
+ function twshare () {
+ window.open(
+ "https://twitter.com/intent/tweet?url="+document.URL+"&text=@WebService OUT params with @WebParam and JAX-WS Holder " + document.URL,
+ 'Share on Twitter',
+ 'width=800,height=526');
+ };
+ </script>
+
+
+ <!-- Le fav and touch icons -->
+ <link rel="shortcut icon" href="./../../images/favicon.ico">
+ <link rel="apple-touch-icon" href="./../../images/apple-touch-icon.png">
+ <link rel="apple-touch-icon" sizes="72x72" href="./../../images/apple-touch-icon-72x72.png">
+ <link rel="apple-touch-icon" sizes="114x114" href="./../../images/apple-touch-icon-114x114.png">
+
+ <script src="./../../javascript/prettify.js" type="text/javascript"></script>
+ <script src="./../../javascript/jquery-latest.js"></script>
+ <script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
+ <script src="./../../javascript/common.js"></script>
+ <script src="./../../javascript/prettyprint.js"></script>
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+
+
+ </head>
+
+ <body>
+
+ <div class="topbar">
+ <div class="fill">
+ <div class="container">
+ <a class="brand" href="./../../index.html">Apache TomEE</a>
+ <ul class="nav">
+ <li><a href="./../../index.html">Home</a></li>
+ <li><a href="./../../downloads.html">Downloads</a></li>
+ <li><a href="./../../documentation.html">Documentation</a></li>
+ <li><a href="./../../support.html">Support</a></li>
+ </ul>
+
+ <!-- Google CSE Search Box Begins -->
+ <FORM class="pull-right" id="searchbox_010475492895890475512:_t4iqjrgx90" action="http://www.google.com/cse">
+ <INPUT type="hidden" name="cx" value="010475492895890475512:_t4iqjrgx90">
+ <INPUT type="hidden" name="cof" value="FORID:0">
+ <INPUT name="q" type="text" placeholder="Search">
+ </FORM>
+ <!--<SCRIPT type="text/javascript" src="http://www.google.com/coop/cse/brand?form=searchbox_010475492895890475512:_t4iqjrgx90"></SCRIPT>-->
+ <!-- Google CSE Search Box Ends -->
+ </div>
+ </div>
+ </div>
+
+ <div class="container">
+
+
+
+<div class="row">
+ <div class="span8">
+ <small><a href="./../../index.html">Home</a> » <a href="./../../examples-trunk/">Examples Trunk</a> » <a href="./../../examples-trunk/webservice-holder/">Webservice Holder</a></small><br>
+ </div>
+ <div class="span8">
+ </div>
+</div>
+
+<div class="page-header">
+<h1>@WebService OUT params with @WebParam and JAX-WS Holder
+
+ <div style="float: right; position: relative; bottom: -10px; ">
+ <a onclick="javascript:gpshare()" class="gp-share sprite" title="share on Google+">share [gp]</a>
+ <a onclick="javascript:fbshare()" class="fb-share sprite" title="share on Facebook">share [fb]</a>
+ <a onclick="javascript:twshare()" class="tw-share sprite" title="share on Twitter">share [tw]</a>
+ </div>
+</h1>
+</div>
+
+<p>With SOAP it is possible to return multiple values in a single request. This is impossible in Java as a method can only return one object.</p>
+
+<p>JAX-WS solves this problem with the concept of Holders. A <code>javax.xml.ws.Holder</code> is a simple wrapper object that can be passed into the <code>@WebService</code> method as a parameter. The application sets the value of the holder during the request and the server will send the value back as an OUT parameter.</p>
+
+<h2>Using @WebParam and javax.xml.ws.Holder</h2>
+
+<p>The <code>@WebParam</code> annotation allows us to declare the <code>sum</code> and <code>multiply</code> Holders as <code>WebParam.Mode.OUT</code> parameters. As mentioned, these holders are simply empty buckets the application can fill in with data to have sent to the client. The server will pass them in uninitialized.</p>
+
+<pre><code>@Stateless
+@WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.ws.out.CalculatorWs")
+public class Calculator implements CalculatorWs {
+
+ public void sumAndMultiply(int a, int b,
+ @WebParam(name = "sum", mode = WebParam.Mode.OUT) Holder<Integer> sum,
+ @WebParam(name = "multiply", mode = WebParam.Mode.OUT) Holder<Integer> multiply) {
+ sum.value = a + b;
+ multiply.value = a * b;
+ }
+}
+</code></pre>
+
+<p>If the Holders were specified as <code>WebParam.Mode.INOUT</code> params, then the client could use them to send data and the application as well. The <code>Holder</code> instances would then be initialized with the data from the client request. The application could check the data before eventually overriting it with the response values.</p>
+
+<h2>The WSDL</h2>
+
+<p>The above JAX-WS <code>@WebService</code> component results in the folliwing WSDL that will be created automatically. Note the <code>sumAndMultiplyResponse</code> complext type returns two elements. These match the <code>@WebParam</code> declarations and our two <code>Holder<Integer></code> params.</p>
+
+<pre><code><?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ name="CalculatorService"
+ targetNamespace="http://superbiz.org/wsdl"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://superbiz.org/wsdl"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <xsd:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
+ targetNamespace="http://superbiz.org/wsdl"
+ xmlns:tns="http://superbiz.org/wsdl"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:element name="sumAndMultiply" type="tns:sumAndMultiply"/>
+ <xsd:complexType name="sumAndMultiply">
+ <xsd:sequence>
+ <xsd:element name="arg0" type="xsd:int"/>
+ <xsd:element name="arg1" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="sumAndMultiplyResponse" type="tns:sumAndMultiplyResponse"/>
+ <xsd:complexType name="sumAndMultiplyResponse">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" name="sum" type="xsd:int"/>
+ <xsd:element minOccurs="0" name="multiply" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="sumAndMultiplyResponse">
+ <wsdl:part element="tns:sumAndMultiplyResponse" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="sumAndMultiply">
+ <wsdl:part element="tns:sumAndMultiply" name="parameters"/>
+ </wsdl:message>
+ <wsdl:portType name="CalculatorWs">
+ <wsdl:operation name="sumAndMultiply">
+ <wsdl:input message="tns:sumAndMultiply" name="sumAndMultiply"/>
+ <wsdl:output message="tns:sumAndMultiplyResponse" name="sumAndMultiplyResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CalculatorServiceSoapBinding" type="tns:CalculatorWs">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="sumAndMultiply">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sumAndMultiply">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sumAndMultiplyResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CalculatorService">
+ <wsdl:port binding="tns:CalculatorServiceSoapBinding" name="CalculatorPort">
+ <soap:address location="http://127.0.0.1:4204/Calculator?wsdl"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
+</code></pre>
+
+<h2>Testing the OUT params</h2>
+
+<p>Here we see a JAX-WS client executing the <code>sumAndMultiply</code> operation. Two empty <code>Holder</code> instances are created and passed in as parameters. The data from the <code>sumAndMultiplyResponse</code> is placed in the <code>Holder</code> instances and is then available to the client after the operation completes.</p>
+
+<p>The holders themselves are not actually sent in the request unless they are configured as INOUT params via WebParam.Mode.INOUT on <code>@WebParam</code></p>
+
+<pre><code>import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Holder;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class CalculatorTest {
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("openejb.embedded.remotable", "true");
+ properties.setProperty("httpejbd.print", "true");
+ properties.setProperty("httpejbd.indent.xml", "true");
+ EJBContainer.createEJBContainer(properties);
+ }
+
+ @Test
+ public void outParams() throws Exception {
+ final Service calculatorService = Service.create(
+ new URL("http://127.0.0.1:4204/Calculator?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorService"));
+
+ assertNotNull(calculatorService);
+
+ final CalculatorWs calculator = calculatorService.getPort(CalculatorWs.class);
+
+ final Holder<Integer> sum = new Holder<Integer>();
+ final Holder<Integer> multiply = new Holder<Integer>();
+
+ calculator.sumAndMultiply(4, 6, sum, multiply);
+
+ assertEquals(10, (int) sum.value);
+ assertEquals(24, (int) multiply.value);
+ }
+}
+</code></pre>
+
+<h2>Inspecting the messages</h2>
+
+<p>The above execution results in the following SOAP message.</p>
+
+<h3>SOAP sumAndMultiply <small>client request</small></h3>
+
+<pre><code><?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:sumAndMultiply xmlns:ns1="http://superbiz.org/wsdl">
+ <arg0>4</arg0>
+ <arg1>6</arg1>
+ </ns1:sumAndMultiply>
+ </soap:Body>
+</soap:Envelope>
+</code></pre>
+
+<h3>SOAP sumAndMultiplyResponse <small>server response</small></h3>
+
+<pre><code><?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:sumAndMultiplyResponse xmlns:ns1="http://superbiz.org/wsdl">
+ <sum>10</sum>
+ <multiply>24</multiply>
+ </ns1:sumAndMultiplyResponse>
+ </soap:Body>
+</soap:Envelope>
+</code></pre>
+
+
+<div class="page-header"> </div>
+<h4>APIs Used</h4>
+<ul><li><a href="http://docs.oracle.com/javaee/6/api/javax/ejb/Stateless.html">javax.ejb.Stateless</a></li>
+<li><a href="http://docs.oracle.com/javaee/6/api/javax/ejb/embeddable/EJBContainer.html">javax.ejb.embeddable.EJBContainer</a></li>
+<li><a href="http://docs.oracle.com/javaee/6/api/javax/jws/WebParam.html">javax.jws.WebParam</a></li>
+<li><a href="http://docs.oracle.com/javaee/6/api/javax/jws/WebService.html">javax.jws.WebService</a></li>
+<li><a href="http://docs.oracle.com/javaee/6/api/javax/xml/namespace/QName.html">javax.xml.namespace.QName</a></li>
+<li><a href="http://docs.oracle.com/javaee/6/api/javax/xml/ws/Holder.html">javax.xml.ws.Holder</a></li>
+<li><a href="http://docs.oracle.com/javaee/6/api/javax/xml/ws/Service.html">javax.xml.ws.Service</a></li>
+</ul>
+
+
+
+ <footer>
+ <p>
+ Copyright © 2011 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.
+ Apache and the Apache feather logo are trademarks of The Apache Software Foundation.
+ </p>
+ </footer>
+
+ </div> <!-- /container -->
+
+ </body>
+</html>
Added: websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/build.xml
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/build.xml (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/build.xml Sun Feb 19 01:30:12 2012
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-29 16:48:17 -0800 (Sun, 29 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-cxf" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
Added: websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/pom.xml
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/pom.xml (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/pom.xml Sun Feb 19 01:30:12 2012
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-29 16:48:17 -0800 (Sun, 29 Jan 2012) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>webservice-holder</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @WebService Holder</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-3</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf</artifactId>
+ <version>4.0.0-beta-3-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- This is required on IBM JDKs (and potentially others) because saaj-impl depends
+ on Sun's internal copy of Xerces. See OPENEJB-1126. -->
+ <dependency>
+ <groupId>com.sun.xml.parsers</groupId>
+ <artifactId>jaxp-ri</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
Added: websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/main/java/org/superbiz/ws/out/Calculator.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/main/java/org/superbiz/ws/out/Calculator.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/main/java/org/superbiz/ws/out/Calculator.java Sun Feb 19 01:30:12 2012
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.out;
+
+import javax.ejb.Stateless;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+
+@Stateless
+@WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.ws.out.CalculatorWs")
+public class Calculator implements CalculatorWs {
+
+ public void sumAndMultiply(int a, int b,
+ @WebParam(name = "sum", mode = WebParam.Mode.OUT) Holder<Integer> sum,
+ @WebParam(name = "multiply", mode = WebParam.Mode.OUT) Holder<Integer> multiply) {
+ sum.value = a + b;
+ multiply.value = a * b;
+ }
+}
Added: websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/main/java/org/superbiz/ws/out/CalculatorWs.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/main/java/org/superbiz/ws/out/CalculatorWs.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/main/java/org/superbiz/ws/out/CalculatorWs.java Sun Feb 19 01:30:12 2012
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.out;
+
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+
+@WebService(targetNamespace = "http://superbiz.org/wsdl")
+public interface CalculatorWs {
+
+ public void sumAndMultiply(int a, int b, Holder<Integer> sum, Holder<Integer> multiply);
+}
Added: websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/test/java/org/superbiz/ws/out/CalculatorTest.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/test/java/org/superbiz/ws/out/CalculatorTest.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/webservice-holder/src/test/java/org/superbiz/ws/out/CalculatorTest.java Sun Feb 19 01:30:12 2012
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.out;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Holder;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class CalculatorTest {
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("openejb.embedded.remotable", "true");
+ // properties.setProperty("httpejbd.print", "true");
+ // properties.setProperty("httpejbd.indent.xml", "true");
+ EJBContainer.createEJBContainer(properties);
+ }
+
+ @Test
+ public void outParams() throws Exception {
+ final Service calculatorService = Service.create(
+ new URL("http://127.0.0.1:4204/Calculator?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorService"));
+
+ assertNotNull(calculatorService);
+
+ final CalculatorWs calculator = calculatorService.getPort(CalculatorWs.class);
+
+ final Holder<Integer> sum = new Holder<Integer>();
+ final Holder<Integer> multiply = new Holder<Integer>();
+
+ calculator.sumAndMultiply(4, 6, sum, multiply);
+
+ assertEquals(10, (int) sum.value);
+ assertEquals(24, (int) multiply.value);
+ }
+}