muSOAing for 4/7/09

A small segway. I want to talk a little about the flexibility offered by the combination of Axis2 with Xmlbeans. Folks who are used to Xmlbeans will find this to be a boon. Often during services invocation if becomes necessary to manually serialize the request object. Using the inbuilt factory this object can be very easily marshalled.

Take a case where you receive your input Xml in the form of DOM Objects and you have to construct your Xmlbeans type. Here is a small example,

public RequestDoc constructReq(Document header, Document body, Document content) {

String headerString = documentToString(headereader);
String bodyString = documentToString(body);
String contentString = documentToString(content);
StringBuffer sb = new StringBuffer();

String finalString = “

“;
finalString = finalString + headerString
finalString = finalString + “

“;
finalString = finalString + bodyString;
finalString = finalString + “

“;
finalString = finalString + contentString;
finalString = finalString + “

“;

RequestDoc requestDoc = RequestDocument.Factory.parse(finalString);
return requestDoc;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: