Setting up your environment means verifying you have the necessary prerequisites, setting up a project (if necessary), and generating any proxy code before you can write the code that consumes the web service.
| Step | Description | Applies To |
|---|---|---|
| 1 | Verifying you have the necessary technologies | All |
| 2 | Creating the project | All |
| 3 | Generating the SOAP proxy code | C#, Java |
For Java, verifying you have the necessary setup for Java means we're ensuring you have the correct versions of JDK and Axis installed, as well as the dependencies listed in the Prerequisites topic.
Open a console window.
Enter the following command:
java -version
The command response should be the following:
java version "1.5.0_05" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05) Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
If you do not get the appropriate response, check the Java documentation from Sun to ensure you have installed everything correctly.
If you are setting the environment variable CLASSPATH, make sure that it includes the JAR files listed in dependencies.txt file, located in the Java folder, and the WSS4J directory. The samples look for the file keys/X509.PFX.MSFT in WSS4J directory at runtime.
Open a console window.
Enter the following command:
java org.apache.axis.wsdl.WSDL2Java -h
If Axis is installed correctly, you should get the usage for WSDL2Java.
The samples included with this guide require either Microsoft Visual Studio 2005 or Visual C# 2005 Express Edition, and Web Services Enhancements (WSE) 3.0 for Microsoft .NET. You can find information about WSE from the Microsoft web site.
To verify the Visual Studio version:
Open Visual Studio 2005 C# Express Edition.
From the Help menu, click About Microsoft C# 2005 Express Edition.
Verify the dialog box lists Microsoft Visual Studio 2005 and version 2.0 of the .NET Framework.
Download and install Windows Service Enhancements (WSE) 3.0 for Microsoft .NET. For the purposes of this guide, it is assumed that all WSE options are installed.
This section lists the steps we used to create the code in this guide. The steps are helpful if you are not familiar with the tools we used or how they're used with web services. If you prefer, you can just open the project we've already created for you and proceed directly to the next step: Making A Request.
Important: | If you do use the projects included in this guide, be sure to update the AWS_ACCESS_KEY_ID and SECRET_ACCESS_KEY variables with your Access Key ID and Secret Access Key values. |
We're just using text editors for this Java example, so creating the project just involves placing the necessary files in the same directory. Copy all of the files from the Java folder to a location on your hard disk drive where you want to work with them.
Open the EnqueueSample.java and DequeueSample.java to work with the sampled provided while steping through this guide.
To create the project for C#, open the SimpleQueueService.sln solution file included with the sample code. The solution includes three projects used to create the sample application. All the files necessary for each project are included. You need only to make a few updates to make the sample work.
The next step, Making A Request, has more information about request authentication.
To open the SQS sample solution
Open Visual C# 2005 Express Edition.
From the File menu, point to Open Project. Click Browse and open the solution file for the samples, SimpleQueueService.sln. It is in the c#\SimpleQueueService folder.
Note: | If you are viewing this online, you need to download all the files associated with the sample solution for it to function correctly. You can download the Getting Started Guide files in .zip format from the AWS Resource Center. |
The files containing the code referenced in this guide are: Enqueue.cs in the Enqueue project, Dequeue.cs in the Dequeue project, and Client.cs in the SimpleQueueServiceClient project.
Before making changes to the sample projects, you may want to copy the files to your a new project directory.
The Enqueue and Dequeue projects both depend on the SimpleQueueServiceClient.dll created from SimpleQueueServiceClient project. No changes are necessary to the SimpleQueueServiceClient project.
For both the Enqueue and Dequeue projects, there is a wse3policyCache.config file that needs to reside in the same directory as the executable file generated from the project. This .config file contains settings specific to using X.509 certificates to authenticate the requests from the sample application.
The certificate used for these samples must be installed on the computer where the sample application is running. The certificate must also be issues to Windows user running the sample application. If not, some Access Denied errors may be encountered. Please see the Microsoft Windows documentation for information about certificates.
To use the C# samples you also need a certificate to authenticate your requests. This guide assumes you are using a certificate generated and issued to you by AWS. For information about how to obtain a certificate from AWS, go to the AWS web site. Point to Your Web Services Account, and click View Access Identifiers. The Access Identifiers page is displayed.
Follow the guidance provided on the Access Identifiers page to obtain a certificate from AWS. Note that certificates issued by AWS can be used only for authenticating web service requests to AWS.
To use a certificate generated by AWS with Visual Studio, it must first be converted to PKCS#12 format, and then installed for your Windows user account.
To convert your AWS certificate for use with Visual Studio
Make a copy of the Certificate file (cert-awsthumbprint.pem) and Private Key file (pk-awsthumbprint.pem) you downloaded from the AWS web site and place them in a secure location.
Use a utility such as OpenSSL to convert the file to a PKCS#12 format file. You can use a utility such as Cygwin for a Unix shell in which OpenSSL can be run. Please see the related product documentation for more information.
Run a command similar to the following (depending on the tools used) to convert your AWS certificate:
openssl pkcs12 -export -inkey pk.pem -in cert.pem -out out.p12 -nodes
Store the files output from the conversion.
To install the certificate, right-click the file, and then select Install Certificate. The certificate is now installed and can be used to authenticate requests to SQS.
Please see the Windows documentation for more information about installing certificates.
You must customize some of the properties for the project to support X.509 certificates.
Open the WSE Configuration tool using the Windows Start menu.
Open the wse3policyCache.config file for the Enqueue project (..\C#\SimpleQueueService\Enqueue\).
On the General tab, select Enable this project for Web Services Enhancements.
On the Policy tab:
Select Enable Policy.
Under Edit Application Policy click Add to specify the policy to enable.
The Add or Modify Policy Friendly Name dialog opens.
In the Add or Modify Policy Friendly Name dialog, type a name for the name of the policy, and then click OK.
The WSE Security Settings Wizard is displayed.
Use the following steps to select settings presented by the WSE Security Settings Wizard.
On the initial screen click Next.
On the Authentication Settings screen select Secure a Client Application, under Client Authentication Method, select Certificate, and then click Next.
On the Client Certificate screen, select the appropriate Store Location for your certificates, and then click Select Certificate. The Select Certificate dialog is displayed.
From the Select Certificate dialog, select the certificate to use, and then click OK.
Click View Certificate and confirm the certificate has a Private Key associated with it, and then click Next.
Note: | The certificate file must include a private key value, and must be the certificate associated with your AWS account. |
On the Message Protections screen:
Under Message Protection, clear the selection of Enable WS Security 1.1 Extensions.
Under Protection Order select Sign Only.
Under Secure Session, uncheck Establish Secure Session.
Click Next.
On the Server Certificate screen, select the certificate for the server to use, and then click Next. The certificate selected here will not be used by AWS, so the selection can be any certificate. You may want to use the same certificate as in preceding steps.
On the Create Security Settings screen, click Finish. The wse3policyCache.config file is created and added to your project.
Click OK on the WSE Security Settings dialog.
The WSE configuration file is now set to use your certificate with the sample application.