Your WST installation includes the following samples and tutorials that familiarize you with the WST development tool. All samples in this section require Eclipse to be running and the Sybase Web services plug-in installed. See Chapter 4, “Web Services Administration.”
The WST development tool provides the architecture and tools to create and deploy Web services from various types of files, which generate a WSDL file as part of the Web service creation. From the generated WSDL file, use the WST development tool to create a test client that tests your newly exposed Web service.
In this tutorial, you:
Connect to EAServer (Web services container)
Expose a Java class as a Web service
Generate a test client for the exposed Web service
Run the test client
The Java source files are in the JavaClass/simpleJavaClass and JavaClassClient subdirectories. Instructions for running the tutorial are in the file ReadmeForEclipse.txt in the JavaClass/simpleJavaClass directory.
The sample described above includes a client, AddClient.java located in the JavaClassClient/client subdirectory. This section describes how to modify this sample and import a test certificate into a keystore so that you can run the tutorial using HTTPS.
To run the test client using HTTPS, you must have Java Secure Socket Extension (JSSE) installed and configured on the client. See Chapter 5, “Using SSL in Java Clients”, in the EAServer Security Administration and Programming Guide for more information.
Exporting the Jaguar Test CA
You must export the Jaguar Test CA using Security Manager. See the EAServer Security Administration and Programming Guide for information about starting and using Security Manager.
From Security Manager, select the CA Certificates folder.
Highlight the Sybase Jaguar User Test CA.
Select File | Export Certificate.
From the Export Certificate wizard, select the format type for the exported certificate. For the Test CA, select Binary Encode X509 Certificate. Click Next.
Select Save to File and enter the full path name to a file that will contain the test CA. Use EASTestCA as the certificate name.
Do not add any extension to the file name. A .crt extension is automatically added to the exported certificate by Security Manager.
Click Finish to export the certificate to the EASTestCA.crt.
Create a Java Keystore containing the Sybase Jaguar
test CA and mark the certificate trusted.
This procedure uses the Java keytool command to create a keystore, import the EASTestCA.crt certificate, and mark it trusted.
From the command line, go to the $JAGUAR/sample/wst_samples directory.
Enter this command to create the keystore named EASTestCA.jks and install EASTestCA.crt, mark it trusted, and protect the keystore with the password “changeit”:
<path_to_JDK_1.3>/bin/keytool -import -v -trustcacerts -alias eastestca -file EASTestCA.crt -keypass changeit -keystore EASTestCA.jks
The Java keytool command requires you to answer two questions. Here are the questions, answers you should provide, and output:
Enter keystore password: changeit
Owner: L=Sybase Jaguar User Test Locality, O=Sybase Jaguar User Test, CN=Sybase Jaguar User Test CA (TEST USE ONLY) Issuer: L=Sybase Jaguar User Test Locality, O=Sybase Jaguar User Test, CN=Sybase Jaguar User Test CA (TEST USE ONLY) Serial number: 1 Valid from: Fri Oct 16 11:02:16 PDT 1998 until: Thu Oct 16 11:02:16 PDT 2003 Certificate fingerprints: MD5: 5B:66:65:6A:4F:11:41:7C:B4:9B:17:CF:30:61:26:5F SHA1: B5:38:55:36:E2:FF:F2:28:5E:45:80:94:BF:54:20:96:28:5B:CC:F8
Trust this certificate? [no]: yes
Certificate was added to keystore [Saving EASTestCA.jks]
Modify the client program
Make these changes to the AddClient.java file. When you run the program, the client will connect to the listener at port 8081. This tutorial assumes that you are running the client on the same machine as your EAServer installation.
modify AddClient.java as follows:
import java.net.URL;
import java.net.MalformedURLException;
import java.security.Security;
import java.io.File;
public class AddClient
{
public static void main(String[] args)
{
...
String jksStore=
".." + File.separator + ".." + File.separator +
"EASTestCA.jks";
System.setProperty("javax.net.ssl.trustStore", jksStore);
System.out.println("Set system property " +
javax.net.ssl.trustStore to " + jksStore);
// Dynamically register the JSSE provider
Security.addProvider(new
com.sun.net.ssl.internal.ssl.Provider());
context = new AddNumbers_ServiceLocator();
URL newURL = null;
try
{
newURL =
new URL("https://localhost:8081/AddSample/services/AddNumbers");
}
catch(MalformedURLException me)
{
me.printStackTrace();
return;
}
System.out.println("Connecting to: " + newURL.toString());
client = context.getAddNumbers(newURL);
Compile and run the sample
Change to the JavaClassClient/client subdirectory and compile and run the test client. For example:
$JAGUAR/bin/wstant compile run -Dnum1=5 -Dnum2=8
The WST development tool allows you to develop, deploy, and run Web services that conform to the JAX-RPC specification.
In this tutorial, you:
Deploy the Web service described in “Establishing Web service security, and generating a test client”
Deploy a Java class as a Web service
Run the JAX-RPC client
The source files are in the JAXRPCService and JAXRPCClient subdirectories. Instructions for running the tutorial are in the file readmeEclipse.txt in the JAXRPCService/server directory.
The WST development tool offers different options for exposing Web services and generating test clients.
In this tutorial, you:
Use EAServer Manager to install an EJB into EAServer
Use the Quick Expose option to expose your EJB as a Web service
Generate a JSP test client for the exposed Web service
Run the JSP test client
The source files are in the EJBSample/statelessEjbSample subdirectory. Instructions for running the tutorial are in the file readme.txt.
Authorization for Web services is enforced by roles. Using the WST development tool you can create new roles, or use predefined roles to establish security at the Web service and Web service operation level. Using different levels of security at the operation level allows you to closely control who has access to your resources.
In this tutorial, you:
Expose a Java class as a Web service
Create an administrator role and a general role and assign those roles to Web service operations/methods
Generate two test clients: one to administer, the other for general business purposes
Run the test clients to verify that the security constraints provided by the roles work as expected
The source files are in the SecuritySample and SecuritySampleClient subdirectories. Instructions for running the tutorial are in the file readme.txt in the SecuritySample directory.
This sample demonstrates how to expose an existing CORBA component as a Web service. In addition, the sample illustrates which component properties enable the component to be exposed. The WST development tool contains an “Other components” folder, which contains components that can be deployed as Web services. Once deployed, the components remain listed in the Other Components folder. This tutorial contains a CORBA Java component that can be exposed as a Web service once it is made stateless. Use EAServer Manager and the WST development tool together to run this tutorial.
In this tutorial, you:
Use EAServer Manager to install a CORBA component in EAServer
Modify the CORBA component’s properties so it is stateless
Expose the component as a Web service
Create and run a Web service client
The source files are in the CORBAComponent subdirectory. Instructions for running the tutorial are in the file readme.txt.
In this sample you download the Google Web services APIs and create a Web service client that allows you to perform sample Google searches.
The source files are in the GoogleAPI subdirectory. Instructions for running the tutorial are in the file GoogleSearchEAS5.htm.
| Copyright © 2005. Sybase Inc. All rights reserved. |
|
|