View Javadoc
1   package ca.uhn.hl7v2.examples.hoh;
2   
3   import java.io.IOException;
4   
5   import ca.uhn.hl7v2.hoh.api.DecodeException;
6   import ca.uhn.hl7v2.hoh.api.EncodeException;
7   import ca.uhn.hl7v2.hoh.api.IReceivable;
8   import ca.uhn.hl7v2.hoh.api.ISendable;
9   import ca.uhn.hl7v2.hoh.raw.client.HohRawClientSimple;
10  import ca.uhn.hl7v2.hoh.sockets.CustomCertificateTlsSocketFactory;
11  
12  public class CustomCertificateClient {
13  
14  	/**
15  	 * @param args
16  	 * @throws EncodeException 
17  	 * @throws IOException 
18  	 * @throws DecodeException 
19  	 */
20  	@SuppressWarnings("unused")
21     public static void main(String[] args) throws DecodeException, IOException, EncodeException {
22  		ISendable<?> sendable = null;
23  
24  // START SNIPPET: client 
25  // Create a client
26  HohRawClientSimpleentSimple.html#HohRawClientSimple">HohRawClientSimple client = new HohRawClientSimple("remotehost", 443, "/");
27  
28  // Assign a socketfactory which references the truststore
29  CustomCertificateTlsSocketFactoryustomCertificateTlsSocketFactory">CustomCertificateTlsSocketFactory clientSocketFactory = new CustomCertificateTlsSocketFactory();
30  clientSocketFactory.setKeystoreFilename("/path/to/truststore/truststore.jks");
31  clientSocketFactory.setKeystorePassphrase("trustpassword");
32  client.setSocketFactory(clientSocketFactory);
33  
34  // Send a message
35  IReceivable<String> response = client.sendAndReceive(sendable);
36  // END SNIPPET: client 
37  
38  
39  
40  	}
41  
42  }