HPOSSOD 1.0 Technical Note

HP Web Services for Output Server 37
Using HP Web Services for Output Server
Sample clients
}
}
You must change the host and the specified port in the code to import the certificate, and you must specify the file on
the client to which you want the Public key information to be written. Therefore, use the file in Web Service client
program to invoke the Web Services for Output Server through SSL.
An example of portion of code is as follows:
//This is is the path to which the Public key from the server certificate is imported:
private static final String TRUSTSTORE_URL="c:\\jssecacerts";
private static final String TRUSTSTORE_PW="changeit";
static
{
javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(
new javax.net.ssl.HostnameVerifier(){
public boolean verify(String hostname,
javax.net.ssl.SSLSession sslSession) {
//specify the hostname to which we want to connect to
if(hostname.equals("<IP Address>")){
return true; }
return false;
} });
System.setProperty("javax.net.ssl.trustStore", TRUSTSTORE_URL) ;
System.setProperty("javax.net.ssl.trustStorePassword", TRUSTSTORE_PW);
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider() );
Sample clients
The following section consists of sample clients for .NET and Java.
Prerequisites for .NET client setup
1. Start the Visual Studio 2005.
2. Create a new C# Project.
3. Choose Console Application (or a web application depending on the type of client you are coding) as the project
type.
4. On the solution explorer, right-click on web reference and add a web reference. (Example: HPOMWS)
5. In the URL, add the wsdl url and click on add reference.
6. Create a sample C# program.
7. Add the import for the web reference (created in step 4)
using System;
using System.IO;