Skip to content

Instantly share code, notes, and snippets.

@YMA-MDL
Created September 23, 2016 09:06
Show Gist options
  • Select an option

  • Save YMA-MDL/8a65cf84de01fef2065c75e25ade0baf to your computer and use it in GitHub Desktop.

Select an option

Save YMA-MDL/8a65cf84de01fef2065c75e25ade0baf to your computer and use it in GitHub Desktop.
java example for AML call
String nameSpace = "http://www.aras-corp.com/";
String remoteMethod = "ApplyItem";
String characterEncoding = "UTF-8";
String SOAPmessage = "<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'><SOAP-ENV:Body><ApplyItem xmlns:m='http://www.aras-corp.com/'>" + context.XML_Buffer + "</ApplyItem></SOAP-ENV:Body></SOAP-ENV:Envelope>";
// Create new URL object and HttpURLConnection object
java.net.URL url = new java.net.URL(context.InnovatorService);
java.net.HttpURLConnection httpConnection = (java.net.HttpURLConnection) url.openConnection();
// Convert the message to a byte array
byte[] messageBytes = SOAPmessage.getBytes();
// Set headers
httpConnection.setRequestProperty("Content-Length", String.valueOf(messageBytes.length));
httpConnection.setRequestProperty("Content-Type","text/xml; charset=" + characterEncoding + "\"");
httpConnection.setRequestProperty("SOAPAction", remoteMethod);
httpConnection.setRequestMethod("POST");
httpConnection.setRequestProperty("AUTHUSER", context.UserName);
httpConnection.setRequestProperty("AUTHPASSWORD", context.UserPass);
httpConnection.setRequestProperty("DATABASE", context.DatabaseName);
httpConnection.setDoInput(true);
httpConnection.setDoOutput(true);
// Write and send the SOAP message
java.io.OutputStream out = httpConnection.getOutputStream();
out.write(messageBytes);
out.close();
// Read server response
java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(
httpConnection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
row7.XMLOut = inputLine;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment