Cover by Andy Oram, Greg Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Exchanging Data Using E-Business Protocols

Something that was new to me on this project was the use of standard e-business protocols. When the distributor informed me of the requirement to exchange requests and responses using the Rosettanet standard, I had to do a little research. I started by going to the Rosettanet web site (http://www.rosettanet.org) and downloading the specific standards I was interested in. I found a diagram detailing a typical exchange between business partners, along with a specification for the XML request and response.

Since I had a lot of trial-and-error type work to do, the first thing I did was set up a test that I could run myself to simulate an interaction with the distributor without having to coordinate testing with their staff for each iteration of development. I used the Apache Commons HttpClient to manage the HTTP exchanges:

public class TestHotKeyService {public static void main (String[] args) throws Exception {

	        String strURL = "http://xxxxxxxxxxx/HotKey/HotKeyService";
	        String strXMLFilename = "SampleXMLRequest.xml";
	        File input = new File(strXMLFilename);

	        PostMethod post = new PostMethod(strURL);
	        post.setRequestBody(new FileInputStream(input));
	        if (input.length( ) < Integer.MAX_VALUE) {
	            post.setRequestContentLength((int)input.length());
	        } else {
	              post.setRequestContentLength(
	                  EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED);
	        }

	        post.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1");

	        HttpClient httpclient = new HttpClient(); System.out.println("[Response ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required