I'm following up on my original post to give others (who may be looking) the answer of how to do this using Java.
Many thanks to both pier-olivier.tremblay and IanRich for their assistance.
Code follows. Approximately 100 lines. 3 methods.
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
/**
* @author I shamelessly stole most of this code from user 'acdcjunior' on https://stackoverflow.com/questions/19291283/soap-request-to-webservice-with-java
*/
public class CallPAMProcess
{
/**
* Main Entry Point
* @param args
*/
public static void main( String[] args )
{
try
{
// Create SOAP Connection
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnectionFactory.createConnection();
// Send SOAP Message to PAM Server
String url = "http://<your PAM server>:8080/itpam/soap";
SOAPMessage soapResponse =
soapConnection.call( executeProcess( "<procLocationOnPAM>", "<yourLogin>", "<yourPassword>" ), url );
// View the SOAP Response (see method, below)
printSOAPResponse( soapResponse );
// Optionally, you can parse the SOAP Response (in this example, the Process Runtime ID)
String runtimeID = soapResponse.getSOAPBody().getElementsByTagName( "ROID" ).item( 0 ).getTextContent();
System.out.println( "\n\n" + runtimeID );
soapConnection.close();
}
catch ( Exception e )
{
System.err.println( "Error occurred while sending SOAP Request to Server" );
e.printStackTrace();
}
}
/**
* Formats a SOAP message to send to PAM
* @param _procName
* @param _usr
* @param _pass
* @return
* @throws Exception
*/
public static SOAPMessage executeProcess(String _procName, String _usr, String _pass)
throws Exception
{
// This (verbatum) comes from Web Services API Reference document
String formattedSOAPMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"\n"
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n"
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"
+ "<SOAP-ENV:Header/>\n"
+ "<SOAP-ENV:Body>\n"
+ "<tns:executeProcess xmlns:tns=\"http://www.ca.com/itpam\">\n"
+ "<tns:flow>\n"
+ "<tns:name>" + _procName + "</tns:name>\n"
+ "<tns:action>start</tns:action>\n"
+ "<tns:auth>\n"
+ "<tns:user>" + _usr + "</tns:user>\n"
+ "<tns:password>" + _pass + "</tns:password>\n"
+ "</tns:auth>\n"
+ "</tns:flow>\n"
+ "</tns:executeProcess>\n"
+ "</SOAP-ENV:Body>\n"
+ "</SOAP-ENV:Envelope>";
// Convert String to SOAP object (note that PAM is stuck at v1.1 for SOAP)
InputStream is = new ByteArrayInputStream( formattedSOAPMsg.getBytes() );
SOAPMessage msg =
MessageFactory.newInstance( SOAPConstants.SOAP_1_1_PROTOCOL ).createMessage( new MimeHeaders(), is );
// Add headers to SOAP object (won't work without this--even if everything else is correct)
MimeHeaders headers = msg.getMimeHeaders();
headers.addHeader( "SOAPAction", "ExecuteC2OFlow" ); // ( <-- Note: this is a naming error on CA's end )
msg.saveChanges();
// Print the request message (for debug)
System.out.print( "Request SOAP Message = " );
msg.writeTo( System.out );
System.out.println();
return msg;
};
/**
* Method used to print the SOAP Response
* @param soapResponse
* @throws Exception
*/
private static void printSOAPResponse( SOAPMessage soapResponse )
throws Exception
{
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
Source sourceContent = soapResponse.getSOAPPart().getContent();
System.out.print( "\nResponse SOAP Message = " );
StreamResult result = new StreamResult( System.out );
transformer.transform( sourceContent, result );
}
}