<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head><link rel="stylesheet" href="../../../print.css" type="text/css" media="print"> | |
<title>Advanced Web Service Interoperability - NetBeans IDE Tutorial</title> | |
<meta name="description" | |
content="This tutorial shows how to use the IDE to configure security mechanisms for web services."> | |
<meta name="KEYWORDS" content="NETBEANS, TUTORIAL, GUIDE, USER, DOCUMENTATION, WEB SERVICE, WEB SERVICES, MTOM, METRO, WS-I, WS-RM, RELIABLE MESSAGING, SECURITY, WCF, WINDOWS COMMUNICATION FOUNDATION"> | |
<link rel="stylesheet" href="../../../netbeans.css"> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head> | |
<body> | |
<h1>Advanced Web Service Interoperability</h1> | |
<p>Advanced Web Service Interoperability (WSIT), also referred to as Web Service | |
"Quality of Service", encompasses components that enable interoperability between | |
Java web services and .Net web services. | |
This document demonstrates some of the support in the IDE for configuring a web service | |
and client that use WSIT. For more information on using WSIT, see | |
<a href="http://docs.oracle.com/cd/E19159-01/820-1072/ahibn/index.html">Chapter 3 WSIT Example Using a Web Container and NetBeans IDE</a> | |
in <a href="http://docs.oracle.com/cd/E19159-01/820-1072/index.html">The WSIT Tutorial</a></p> | |
<p><b>Contents</b></p> | |
<img src="../../../images_www/articles/72/netbeans-stamp-74-73-72.png" class="stamp" alt="Content on this page applies to NetBeans IDE 7.2, 7.3 and 7.4" title="Content on this page applies to the NetBeans IDE 7.2, 7.3 and 7.4" > | |
<ul> | |
<li><a href="#Exercise_1">Getting to Know the Calculator Sample</a> | |
<ul><li><a href="#Exercise_1_1">Exploring the Sample</a></li> | |
<li><a href="#Exercise_1_2">Deploying and Testing the Calculator Sample</a></li> | |
</ul> | |
<li><a href="#Exercise_2">Getting to Know the Secured Calculator Sample</a> | |
<ul><li><a href="#Exercise_2_1">Exploring the Sample</a></li> | |
<li><a href="#Exercise_2_2">Deploying and Testing the Secured Calculator Sample</a></li> | |
</ul> | |
</ul> | |
<p><b>To follow this tutorial, you need the following software and resources.</b></p> | |
<table> | |
<tbody> | |
<tr> | |
<th class="tblheader" scope="col">Software or Resource</th> | |
<th class="tblheader" scope="col">Version Required</th> | |
</tr> | |
<tr> | |
<td class="tbltd1"><a target="_blank" href="https://netbeans.org/downloads/index.html">NetBeans IDE</a></td> | |
<td class="tbltd1">Java EE download bundle</td> | |
</tr> | |
<tr> | |
<td class="tbltd1"><a target="_blank" href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Java Development Kit (JDK)</a></td> | |
<td class="tbltd1">version 6 or | |
version 7</td> | |
</tr> | |
<tr> | |
<td class="tbltd1">Java EE-compliant web or application server</td> | |
<td class="tbltd1"> | |
GlassFish Server Open Source Edition 3.1.x, 4.x<br> or <br><a href="http://www.oracle.com/technetwork/middleware/weblogic/overview/index.html" target="_blank">Oracle WebLogic Server</a> 11g or 12c | |
</td></tr> | |
</tbody> | |
</table> | |
<p class="notes">The GlassFish server can be installed, optionally, with the Java EE distribution of NetBeans IDE. | |
Alternatively, you can visit the <a href="https://glassfish.java.net/download.html">the GlassFish server downloads page</a> or the <a target="_blank" href="http://tomcat.apache.org/download-60.cgi">Apache Tomcat downloads page</a>.</p> | |
<p class="alert"><strong>Important: </strong>Java EE projects require GlassFish Server 3.1.x, 4.x, or Oracle WebLogic Server 12c.</p> | |
<!--Exercise 1: --> | |
<a name="Exercise_0"></a> | |
<h2>Introduction</h2> | |
<p>Components relating to advanced web services interoperability | |
fall into four main categories:</p> | |
<ul> | |
<li><b>Bootstrapping and configuration.</b> The process that is executed to | |
create a Web service client that can access and consume a Web service.</li> | |
<li><b>Message security.</b> The following security configuration options are supported: | |
<ul> | |
<li>Targets to sign and encrypt options</li> | |
<li>Client/service Web services security</li> | |
<li>Client/service trust options</li> | |
<li>Advanced configuration options</li> | |
<li>Keystore configuration options</li> | |
</ul> | |
</li> | |
<li><b>Message optimization.</b> Ensures that Web services | |
messages are transmitted over the Internet in the most efficient | |
manner. Message optimization is achieved in Web services communication | |
by encoding messages prior to transmission and then de-encoding | |
them when they reach there final destination.</li> | |
<li><b>Reliable messaging.</b> Measured by a system's | |
ability to deliver messages from point A to point B without error.</li> | |
</ul> | |
<p>"Quality of service" is configured in the Web Service Attributes Editor, | |
which can be accessed from the node representing | |
the web service or client in the Projects window. In this document | |
you are introduced to two samples that are distributed with the IDE: | |
an unsecured web service sample and a secured web service sample. | |
This document will show some of the differences between the samples | |
and also how to use the IDE to configure security for your own web services and clients.</p> | |
<p>For a full and complete guide to topics relating to 'Quality of Service', | |
see <a target="_blank" href="http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/reference/tutorials/wsit/doc/index.html">The WSIT Tutorial</a>. | |
<!-- ===================================================================================== --> | |
<a name="Exercise_1"></a><h2>Getting to Know the Calculator Sample</h2> | |
<p>The goal of this exercise is to | |
get to know the Calculator sample that is bundled | |
with the IDE. In contrast to the next sample, this | |
sample is not secured, as you will see when you examine the web service.</p> | |
<div class="indent"> | |
<h3 class="tutorial"><a name="Exercise_1_1"></a>Exploring the Sample</h3> | |
<p>In this exercise you will use the New Project wizard to create the sample, | |
examine the sample in the IDE and deploy the application.</p> | |
<ol> | |
<li>Choose File > New Project (Ctrl-Shift-N on Linux and Windows, ⌘-Shift-N on MacOS) | |
to open the New Project wizard.</li> | |
<li>Expand the Samples category and select the Web Services | |
node and then select the Calculator sample. Click Next.<br> | |
<img src="../../../images_www/articles/74/websvc/wsit/wsit-newproject.png" alt="New Project wizard showing calculator sample" title="New Project wizard showing calculator sample" class="margin-around b-all"></li> | |
<li>Confirm that a Java EE-compliant server is selected in the Server drop-down list. | |
Click Finish. | |
<p>When you click Finish the wizard creates two projects: | |
<ul> | |
<li><strong>CalculatorApp</strong> provides a web service named CalculatorWS that exposes an operation named 'add'.</li> | |
<li><strong>CalculatorClientApp</strong> provides a client named CalculatorWSService that invokes the web service's 'add' operation.</li> | |
</ul> | |
<p class="alert">The CalculatorClientApp service might be badged with an error icon | |
because the IDE cannot find the WSDL for the CalculatorWS service. | |
The error will be resolved after you deploy CalculatorApp and clean and build the CalculatorClientApp.</p> | |
<img src="../../../images_www/articles/74/websvc/wsit/wsit-projects.png" alt="Projects window displaying the web service and the client" class="margin-around b-all" title="Projects window displaying the web service and the client"></li> | |
<li>Double-click the CalculatorWS web service to open the file in the editor and click the | |
Design tab at the top of the editor to view the web service in the visual designer.<br> | |
<img src="../../../images_www/articles/74/websvc/wsit/wsit-design.png" alt="CalculatorWS service in Design GUI (Visual Designer) tab" class="margin-around b-all" title="CalculatorWS service in Design GUI (Visual Designer) tab"> | |
<p class="notes"><b>Note:</b> In the Quality of Service section in the design tab of the service you can see that <i>no</i> options are enabled. | |
As a result, the Quality of Service components have not been applied to this particular web service. | |
You will look at a web service where a Quality of Service component <em>is</em> enabled when you create the secure web service.</p> | |
</li> | |
</ol> | |
<p>For a full tutorial on web services in the IDE, see <a href="jax-ws.html">Getting Started with JAX-WS Web Services</a>. | |
<h3 class="tutorial"><a name="Exercise_1_2"></a>Deploying and Testing the Calculator Sample</h3> | |
<ol> | |
<li>Right-click the CalculatorApp project and choose Run. | |
<p>The server starts and the web service is deployed to the server. | |
You will see a page open in your default browser that provides some details of the service.</p> | |
<img src="../../../images_www/articles/74/websvc/wsit/wsit-browser1.png" alt="CalculatorWS information window in browser" class="margin-around b-all" title="CalculatorWS information window in browser"></li> | |
<li>Click on the WSDL link in the page in the browser to see the WSDL file that | |
defines the web service. | |
<br><img src="../../../images_www/articles/74/websvc/wsit/wsit-browser2.png" alt="Calculator WS WSDL in browser" class="margin-around b-all" title="Calculator WS WSDL in browser"> | |
<p class="notes"><b>Note.</b> If the WSDL does not display, check the URL in the browser's location bar. | |
It should point to <tt>http://localhost:<em>your_port_number</em>/CalculatorApp/CalculatorWSService?WSDL</tt>.</p> | |
</li> | |
<li>In the Projects window of the IDE, right-click CalculatorWS under the Web Services node and choose Test Web Service in the popup menu.<br> | |
<p>When you test the web service a page for testing the service opens in your browser.</p> | |
<img src="../../../images_www/articles/74/websvc/wsit/wsit-browser3.png" alt="Calculator WS Tester in browser" class="margin-around b-all" title="Calculator WS Tester in browser"> | |
<p>The IDE can provide a client for testing your web service and | |
open the test application in your browser. | |
In the test application you can enter values for each of the fields defined in the web service. | |
The test application has a button that is labeled after the name of the operation in the service. | |
When you click the button you will see the result of invoking the operation.</p> | |
</li> | |
<li>Examine the CalculatorClientApp project in the Projects window for any error badges. | |
<p>If there are error icons for <tt>ClientServlet.java</tt>, right-click the project node and | |
choose Clean and Build in the popup menu. | |
The errors appeared because the CalculatorWS service was not deployed. | |
Now that it is deployed, the IDE can parse the WSDL and the ClientServlet compiles.</p></li> | |
<li>Right-click the CalculatorClientApp project node and choose Run. | |
<p>When you run the application an interface for the service opens in your browser.</p> | |
<img src="../../../images_www/articles/74/websvc/wsit/wsit-browser4.png" alt="Calculator Service client in browser" class="margin-around b-all" title="Calculator Service client in browser"></li> | |
<li>Enter values in the two fields and click Get Result. | |
<p>When you click Get Result the result of the operation is retrieved from the | |
web service and displayed in the client.</p></li> | |
</ol> | |
<p>The web service is functioning correctly and the client retrieves results, | |
but this project does not make use of the Quality of Service components. | |
In the next section, you will see how you can configure Quality of Service components.</p> | |
</div> | |
<!-- ===================================================================================== --> | |
<h2><a name="Exercise_2"></a> | |
<!--Exercise 1: --> | |
Getting to Know the Secured Calculator Sample</h2> | |
<p>The goal of this exercise is to examine how a secured web service is set up | |
and how a client interacts with it.</p> | |
<div class="indent"> | |
<h3 class="tutorial"><a name="Exercise_2_1"></a>Exploring the Sample</h3> | |
<p>In this exercise you use the New Project wizard to create the sample | |
and then examine how Quality of Service is configured for the application.</p> | |
<ol> | |
<li>Choose File > New Project (Ctrl-Shift-N on Linux and Windows, ⌘-Shift-N on MacOS) | |
to open the New Project wizard.</li> | |
<li>Expand the Samples category and select the Web Services | |
node and then select the Secure Calculator sample. Click Next.</li> | |
<li>Confirm that a Java EE-compliant server is selected in the Server drop-down list. | |
Click Finish. | |
<p>When you click Finish the wizard creates two projects: | |
<ul> | |
<li><strong>SecureCalculatorApp</strong> provides a web service named CalculatorWS that exposes an operation named 'add'.</li> | |
<li><strong>SecureCalculatorClientApp</strong> provides a client named CalculatorWSService that invokes the web service's 'add' operation.</li> | |
</ul> | |
<p class="alert">The SecureCalculatorClientApp service might be badged with an error icon | |
because the IDE cannot find the WSDL for the CalculatorWS service. | |
The error will be resolved after you deploy SecureCalculatorApp and clean and build the SecureCalculatorClientApp.</p> | |
</li> | |
<li>Double-click the CalculatorWS web service in the Web Services folder of SecureCalculatorApp to open the file in the editor and click the | |
Design tab at the top of the editor to view the web service in the visual designer. | |
<p class="notes"><b>Note:</b> In the Quality of Service section in the design view of the service | |
you can see that the Secure Service option is selected and that the other | |
two options are not selected. | |
The Quality of Service section in the design view specifies | |
which of the Quality of Service components is <i>enabled</i> for the | |
current web service.</p> | |
</li> | |
<li>Click Edit Web Service Attributes to open the Web Service Attributes Editor.<br> | |
<img src="../../../images_www/articles/74/websvc/wsit/wsit-quality-dialog.png" alt="Quality of Service page in WS Attributes Editor" class="margin-around b-all" title="Quality of Service page in WS Attributes Editor"> | |
<p>In the Quality of Service tab you can see that a Version Compatibility option is selected. | |
You should select the latest version that matches the version of Metro or .NET that is installed.</p> | |
<p class="alert">To enable the version compatibility drop down list, add the latest version of Metro to your project's classpath. | |
To add the latest Metro library, right-click the project's node in the Projects window, | |
open the project's Properties, go to the Libraries category, and browse for and add the latest Metro library.</p> | |
<p>Notice that the Secure Service option is selected and that a security mechanism is selected in the | |
drop-down list. The security mechanism specifies the approach used for securing the web service. | |
<p>In this sample application the Username Authentication with Symmetric Keys security mechanism is selected. | |
For a description of options and properties for the Username Authentication with Symmetric Keys security mechanism, | |
see <a href="http://docs.oracle.com/cd/E19182-01/821-0015/gggsrv/index.html">Username Authentication with Symmetric Key </a>. | |
For a description of other available security mechanisms, see | |
<a href="http://docs.oracle.com/cd/E19182-01/820-0595/6ncatc2q5/index.html" target="_blank">Configuring Security Mechanisms</a>.</p> | |
</li> | |
<li>Expand the Input Message and Output Message sections in the Quality of Service tab.<br> | |
<img src="../../../images_www/articles/74/websvc/wsit/wsit-quality-dialog2.png" alt="Quality of Service page with Message Parts button enabled" class="margin-around b-all" title="Quality of Service page with Message Parts button enabled"> | |
<p>The Message Parts button is enabled for Input Message and Output Message | |
if you select the Username Authentication with Symmetric Keys as the security mechanism.</p> | |
<p class="notes"><b>Note:</b> The Authentication Token drop-down list and the options for Input Message | |
are not enabled for the Username Authentication with Symmetric Keys security mechanism.</p> | |
</li> | |
<li>Click the Message Parts button in the Input Message section.<br> | |
<img src="../../../images_www/articles/74/websvc/wsit/wsit-messageparts.png" alt="Message Parts dialog" class="margin-around b-all" title="Message Parts dialog"> | |
<p>In the Message Parts dialog box you can see security options for different elements. | |
You can select a checkbox to enable or disable | |
the parts that should be signed, encrypted and required. | |
For each element you can specify the following options:</p> | |
<ul> | |
<li>Select <strong>Sign</strong> to specify the parts or elements of a | |
message that require integrity protection (digital signature).</li> | |
<li>Select <strong>Encrypt</strong> to specify the parts or elements of a message | |
that require confidentiality (encryption).</li> | |
<li>Select <strong>Require</strong> to specify the set of parts and/or elements that | |
a message must contain.</li> | |
</ul> | |
<p>Next you will look at how the web service client's | |
Quality of Service is configured.</p> | |
</li> | |
<li>In the Projects window, expand the Web Service References node in the | |
<strong>SecureCalculatorClientApp</strong> project.</li> | |
<li>Right-click the CalculatorWSService node and choose Edit Web Service Attributes | |
in the popup menu to open the Web Service Attributes dialog box. | |
<br> | |
<img src="../../../images_www/articles/74/websvc/wsit/wsit-qos-wsservice.png" alt="Web service client quality of service dialog" class="margin-around b-all" title="Web service client quality of service dialog"> | |
<p>You can see that a default user "wsitUser" and password exist. | |
The default user and password were created in the "file" realm.</p> | |
<p>If you select the Use Development Defaults option in the Security | |
section the IDE imports certificates into the GlassFish server keystore and | |
truststore, so that they can be used immediately for development.</p> | |
<p class="alert"><strong>Important: </strong> | |
In a production environment, you will probably want to | |
provide your own certificates and user settings, however, | |
in a development environment you may find these defaults | |
useful.</p> | |
<p>For a more detailed description of how to configure security for a web service client, see | |
<a href="http://docs.oracle.com/cd/E19159-01/820-1072/6ncp48v3b/index.html">Chapter 7 Using WSIT Security</a> | |
in <a href="http://docs.oracle.com/cd/E19159-01/820-1072/index.html">The WSIT Tutorial</a>.</p> | |
</li> | |
</ol> | |
<h3 class="tutorial"><a name="Exercise_2_2"></a>Deploying and Testing the Secured Calculator Sample</h3> | |
<ol> | |
<li>Right-click the web service project node and choose Run to deploye the web service.</li> | |
<li>Right-click the web service client project node and choose Run. | |
<p>When you run the client the application is deployed and | |
and the interface for the service opens in the browser.</p> | |
<img src="../../../images_www/articles/74/websvc/wsit/wsit-browser-secure1.png" alt="Secure web service client in browser" class="margin-around b-all" title="Secure web service client in browser"> | |
</li> | |
<li>Type a number in each of the fields and click Get Result. | |
<p>When you click Get Result the page will display a message that the | |
client was authenticated and will display the result of the operation.</p> | |
<img src="../../../images_www/articles/74/websvc/wsit/wsit-browser-secure2.png" alt="Secure web service client in browser showing results" class="margin-around b-all" title="Secure web service client in browser showing results"> | |
</li> | |
</ol> | |
<p class="notes">If you get an error message that authentication failed due to an invalid user/password pair, | |
there is either a problem with the default user created by the IDE or there are mismatched credentials | |
set on the client. | |
In this case, you need to create the user/password pair manually. | |
For instructions, please see | |
<a href="http://docs.oracle.com/cd/E19159-01/820-1072/6ncp48v3b/index.html">Chapter 7 Using WSIT Security</a> | |
in <a href="http://docs.oracle.com/cd/E19159-01/820-1072/index.html">The WSIT Tutorial</a>.</p> | |
</div> | |
<div class="feedback-box" ><a href="/about/contact_form.html?to=3&subject=Feedback:WSIT%20Advanced%20Interoperability%20in%20NetBeans%20IDE%206.0">Send Feedback on This Tutorial</a></div> | |
<!-- ======================================================================================= --> | |
<br> | |
<h2><a name="seealso"></a>See Also</h2> | |
<p>For more information about using NetBeans IDE to develop Web Services, see the following resources: | |
</p> | |
<ul> | |
<li><a href="client.html">Developing JAX-WS Web Service Clients</a></li> | |
<li><a href="jax-ws.html">Getting Started with JAX-WS Web Services</a></li> | |
<li><a href="rest.html">Getting Started with RESTful Web Services</a></li> | |
<li><a href="flower_overview.html">Web Service Application Passing Binary Data</a></li> | |
<li><a href="../../74/websvc/jaxb.html">Binding WSDL to Java with JAXB</a></li> | |
<li><a href="../../trails/web.html">Web Services Learning Trail</a></li> | |
</ul> | |
<p>To send comments and suggestions, get support, and keep informed about the latest | |
developments on the NetBeans IDE Java EE development features, <a href="../../../community/lists/top.html">join | |
the nbj2ee@netbeans.org mailing list</a>.</p> | |
</body> |