13.01.2013 Views

Connecting to PaymentTrust's Secure Transaction Network - WorldPay

Connecting to PaymentTrust's Secure Transaction Network - WorldPay

Connecting to PaymentTrust's Secure Transaction Network - WorldPay

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

275<br />

urlConnection = url.openConnection();<br />

// Get the input stream from the socket and attach it <strong>to</strong> a BufferedReader.<br />

in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));<br />

// Used <strong>to</strong> s<strong>to</strong>re incoming data from the HTTP server.<br />

String input = new String();<br />

// Read the data coming from the HTTP server in<strong>to</strong> the input string.<br />

input = in.readLine();<br />

System.out.println("Result from GET method");<br />

System.out.println("-----------------------------------------------");<br />

parseInput(input);<br />

}<br />

catch(IOException ex)<br />

{<br />

System.out.println("Error occurred while attempting GET: " + ex.<strong>to</strong>String());<br />

}<br />

}<br />

else if(httpMethod.equals("POST"))<br />

{<br />

// Build the final URL <strong>to</strong> the HTTP server.<br />

url = new URL(urlLocation);<br />

try<br />

{<br />

// Connect <strong>to</strong> the server.<br />

urlConnection = url.openConnection();<br />

// Set this flag <strong>to</strong> true <strong>to</strong> be able <strong>to</strong> post data <strong>to</strong> the HTTP server.<br />

urlConnection.setDoOutput(true);<br />

// Get the output stream from the socket and attach it <strong>to</strong> a BufferedWriter.<br />

out = new BufferedWriter(new OutputStreamWriter(urlConnection.getOutputStream()));<br />

// POST the STL transaction <strong>to</strong> the server.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!