I wrote a program that sends a cradit card authorization request to TransFirst.
I can successfully send a file with the authorization information and receive a
response. My problem is that I also get this as an output "INFO: Discarding unexpected response: HTTP/1.1 100 Continue". Does anyone know how to get rid of this output? Thanks in advance.
My code is:
Code:
import java.io.*;
//import java.util.*;
import java.security.*;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
import org.apache.commons.httpclient.methods.PostMethod;
public class tfirstComm {
static String testURL = "https://ePaysecure1.transfirst.com/elink/authpd.asp";
static String hostURL = "https://ePaysecure1.transfirst.com/elink/authpd.asp";
public static void main(String args[]) throws Exception
{
// Display usage parameters
if (args.length != 1)
{
System.err.println("usage: java tfirstComm orderID");
System.exit(0);
}
try
{
String fileRequest = args[0];
String fileResponse = "A"+fileRequest+".ret";
File tempReta = new File(fileResponse);
BufferedWriter wrReta = new BufferedWriter(new FileWriter(tempReta));
File tempAuth = new File("TR" + fileRequest + ".aut");
// Turn on SSL capabilites//////////////////////////////////////////
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
// Create a TCP connection & POST the XML temp file
String workURL = "";
workURL = hostURL;
PostMethod post = new PostMethod(workURL);
post.setRequestBody(new FileInputStream(tempAuth));
//post.setRequestHeader("Host:", "htt://epay.transfirst.com");
//post.setRequestHeader("POST",hostURL,"false");
post.setRequestHeader("Pragma", "No-Cache");
post.setRequestHeader("Stateless-Transaction", "true");
post.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
if (tempAuth.length() < Integer.MAX_VALUE)
{
post.setRequestContentLength((int)tempAuth.length());
}
else
{
post.setRequestContentLength(EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED);
}
HttpClient httpclient = new HttpClient();
int result = httpclient.executeMethod(post);
//System.out.print(post.getResponseBodyAsString());
// Write the response to a temp file
wrReta.write(post.getResponseBodyAsString());
// Close the TCP connection, temp files, & db connection
post.releaseConnection();
wrReta.close();
}
catch (IOException e)
{
System.err.println("Communication Error - Retry the Authorization");
System.out.println(e.toString());
System.exit(-1);
e.printStackTrace();
}
catch (Exception e)
{
System.out.println(e.toString());
e.printStackTrace();
System.exit(1);
}
}
}