📄 session3.html
字号:
<a name="wp81014"> </a><div class="pSmartList2"><li>In the combo box below this button, select <code class="cCode">HelloService</code>.</li></div><a name="wp81015"> </a><div class="pSmartList2"><li>In the JAR Display Name field, enter <code class="cCode">HelloServiceJAR</code>.</li></div><a name="wp81016"> </a><div class="pSmartList2"><li>Click Edit.</li></div><a name="wp81017"> </a><div class="pSmartList2"><li>In the tree under Available Files, locate the <code class="cCode"><</code><code class="cVariable">INSTALL</code><code class="cCode">>/j2eetutorial14/examples/ejb/helloservice/build/</code> directory.</li></div><a name="wp81018"> </a><div class="pSmartList2"><li>In the Available Files tree select <code class="cCode">mapping.xml</code> and <code class="cCode">MyHelloService.wsdl</code>.</li></div><a name="wp81019"> </a><div class="pSmartList2"><li>Select these classes from the <code class="cCode"><</code><code class="cVariable">INSTALL</code><code class="cCode">>/j2eetutorial14/examples/ejb/helloservice/build/helloservice/</code> directory: <code class="cCode">HelloIF.class</code> and <code class="cCode">HelloServiceBean.class</code>.</li></div><a name="wp81020"> </a><div class="pSmartList2"><li>Click Add.</li></div><a name="wp81021"> </a><div class="pSmartList2"><li>Click OK.</li></div><a name="wp81022"> </a><div class="pSmartList2"><li>Click Next.</li></div></ol></div><a name="wp81023"> </a><div class="pSmartList1"><li>General dialog box</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81024"> </a><div class="pSmartList2"><li>Under Enterprise Bean Type, select Stateless Session.</li></div><a name="wp81026"> </a><div class="pSmartList2"><li>In the Enterprise Bean Class combo box, select <code class="cCode">helloservice.HelloServiceBean</code>.</li></div><a name="wp81027"> </a><div class="pSmartList2"><li>In the Enterprise Bean Name field, enter <code class="cCode">HelloServiceEJB</code>.</li></div><a name="wp81028"> </a><div class="pSmartList2"><li>Click Next. </li></div></ol></div><a name="wp81029"> </a><div class="pSmartList1"><li>In the Configuration Options dialog box, click Next. The wizard will automatically select the Yes button for Expose Bean as Web Service Endpoint.</li></div><a name="wp81030"> </a><div class="pSmartList1"><li>In the Choose Service dialog box:</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81031"> </a><div class="pSmartList2"><li>Select <code class="cCode">META-INF/wsdl/MyHelloService.wsdl</code> in the WSDL File combo box.</li></div><a name="wp81032"> </a><div class="pSmartList2"><li>Select <code class="cCode">mapping.xml</code> from the Mapping File combo box.</li></div><a name="wp81033"> </a><div class="pSmartList2"><li>Make sure <code class="cCode">MyHelloService</code> is in the Service Name and Service Display Name edit boxes.</li></div></ol></div><a name="wp81034"> </a><div class="pSmartList1"><li>In the Web Service Endpoint dialog box:</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81035"> </a><div class="pSmartList2"><li>Select <code class="cCode">helloservice.HelloIF</code> in the Service Endpoint Interface combo box.</li></div><a name="wp81036"> </a><div class="pSmartList2"><li>In the WSDL Port section, set the Namespace to <code class="cCode">urn:Foo</code>, and the Local Part to <code class="cCode">HelloIFPort</code>.</li></div><a name="wp81037"> </a><div class="pSmartList2"><li>In the Sun-specific Settings section, set the Endpoint Address URI to <code class="cCode">hello-ejb/hello</code>.</li></div><a name="wp81038"> </a><div class="pSmartList2"><li>Click Next.</li></div></ol></div><a name="wp81704"> </a><div class="pSmartList1"><li>Click Finish.</li></div><a name="wp81691"> </a><div class="pSmartList1"><li>Select <code class="cCode">HelloServiceJAR</code> in the tree in deploytool.</li></div><a name="wp81692"> </a><div class="pSmartList1"><li>Click the Web Services tabbed pane.</li></div><a name="wp81693"> </a><div class="pSmartList1"><li>Select <code class="cCode">MyHelloService</code> in the WebServices table.</li></div><a name="wp81694"> </a><div class="pSmartList1"><li>In the Sun-specific Settings section in the WSDL Publish Location field enter <code class="cCode">hello-ejb/hello?WSDL</code>.</li></div></ol></div><a name="wp81042"> </a><h4 class="pHeading3">Deploying the Enterprise Application</h4><a name="wp81043"> </a><p class="pBody">Now that the J2EE application contains the enterprise bean, it is ready for deployment. </p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp81045"> </a><div class="pSmartList1"><li>Select the <code class="cCode">HelloService</code> application.</li></div><a name="wp81046"> </a><div class="pSmartList1"><li>Select Tools<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>Deploy.</li></div><a name="wp81047"> </a><div class="pSmartList1"><li>Under Connection Settings, enter the user name and password for the J2EE application server. </li></div><a name="wp81048"> </a><div class="pSmartList1"><li>Click OK.</li></div><a name="wp81049"> </a><div class="pSmartList1"><li>In the Distribute Module dialog box click Close when the deployment completes.</li></div><a name="wp81050"> </a><div class="pSmartList1"><li>Verify the deployment.</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81051"> </a><div class="pSmartList2"><li>In the tree, expand the Servers node and select the host that is running the J2EE application server.</li></div><a name="wp81052"> </a><div class="pSmartList2"><li>In the Deployed Objects table, make sure that <code class="cCode">HelloService</code> is listed and its status is Running.</li></div></ol></div></ol></div><a name="wp81061"> </a><h3 class="pHeading2">Building the Web Service Client</h3><a name="wp81062"> </a><p class="pBody">In the next section, to test the Web service implemented by <code class="cCode">HelloServiceEJB</code>, you will run the JAX-RPC client described in Chapter <a href="JAXRPC.html#wp64024">8</a>.</p><a name="wp81714"> </a><p class="pBody">Verify that <code class="cCode">HelloServiceEJB</code> has been deployed by clicking on the target application server in the Servers tree in <code class="cCode">deploytool</code>. In the Deployed Objects tree you should see <code class="cCode">HelloServiceApp</code>.</p><a name="wp81066"> </a><p class="pBody">To build the static stub client, perform these steps:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp81067"> </a><div class="pSmartList1"><li>In a terminal go to the <code class="cVariable"><INSTALL></code><code class="cCode">/j2eetutorial14/examples/jaxrpc/helloservice/</code> directory and type:</li></div><a name="wp81068"> </a><p class="pBodyRelative"><code class="cCode">asant build</code> </p><a name="wp81069"> </a><div class="pSmartList1"><li>In a terminal go to the <code class="cVariable"><INSTALL></code><code class="cCode">/j2eetutorial14/examples/jaxrpc/staticstub/</code> directory. </li></div><a name="wp81623"> </a><div class="pSmartList1"><li>Open <code class="cCode">config-wsdl.xml</code> in a text editor and change the line that reads:</li></div><a name="wp81629"> </a><p class="pBodyRelative"><code class="cCode"><wsdl location="http://localhost:8080/hello-jaxrpc/hello?WSDL"</code> </p><a name="wp81624"> </a><p class="pBodyRelative">To:</p><a name="wp81635"> </a><p class="pBodyRelative"><code class="cCode"><wsdl location="http://localhost:8080/hello-ejb/hello?WSDL"</code> </p><a name="wp81622"> </a><div class="pSmartList1"><li>Type:</li></div><a name="wp81070"> </a><p class="pBodyRelative"><code class="cCode">asant build</code> </p><a name="wp81071"> </a><div class="pSmartList1"><li>Edit the <code class="cCode">build.properties</code> file and change the <code class="cCode">endpoint.address</code> property to</li></div><a name="wp81072"> </a><p class="pBodyRelative"><code class="cCode">http://localhost:8080/hello-ejb/hello</code> </p></ol></div><a name="wp81073"> </a><p class="pBody">For details about creating the JAX-RPC service and client, see these sections: <a href="JAXRPC4.html#wp115211">Creating a Web Service with JAX-RPC</a> and <a href="JAXRPC5.html#wp79965">Static Stub Client Example</a>.</p><a name="wp81080"> </a><h3 class="pHeading2">Running the Web Service Client</h3><a name="wp81082"> </a><p class="pBody">To run the client, go to the <code class="cVariable"><INSTALL></code><code class="cCode">/j2eetutorial14/examples/jaxrpc/staticstub/</code> directory and enter:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">asant run<a name="wp81083"> </a></pre></div><a name="wp81084"> </a><p class="pBody">The client should display the following line:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">Hello Duke! (from HelloServiceEJB)<a name="wp81085"> </a></pre></div> </blockquote> <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"> <table width="550" summary="layout" id="SummaryNotReq1"> <tr> <td align="left" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a> </td> <td align="center" valign="center"><a accesskey="p" href="Session2.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="Session4.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a> </td> <td align="right" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font> </font> </td> </tr> </table> <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"><p><font size="-1">All of the material in <em>The J2EE(TM) 1.4 Tutorial</em> is <a href="J2EETutorialFront2.html">copyright</a>-protected and may not be published in other workswithout express written permission from Sun Microsystems.</font> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -