From: www.itworld.com

The Profile View

by David Wall

June 25, 2002 —

 

Sending SOAP messages is a lot easier if you specify a profile when you
create the MessageFactory object that will spawn the message. The
profile tells the MessageFactory to generate SOAP messages that comply
with a specific message format standard, such as ebXML.

You can find out what profiles your messaging provider supports by
opening a connection to the messaging provider, like this...

ctx = newInitialContext();
ProviderConnectionFactory pcf =
(ProviderConnectionFactory)ctx.lookup("MessagingProviderName");
ProviderConnection pc = pcf.createConnection();

...and then extracting the ProviderMetaData object from that and taking
an array of profiles from the ProviderMetaData, like this...

ProviderMetaData pmd = pc.getMetaData();
String[] supportedProfiles = pmd.getSupportedProfiles();
String desiredProfile = null;

You can then examine the array elements one at a time until you find one
that matches the specification you want:

for (int i=0; i if (supportedProfiles[i].equalsIgnoreCase("ebxml")) {
desiredProfile = supportedProfiles[i];
break;
}
}

Once you've done that, you can proceed to create a SOAP message based on
the messaginf profile you got from your search. You'd do that like this:

MessageFactory mf = pc.createMessageFactory(desiredProfile);
EbXMLMessageImpl ebxmlMsg = (EbXMLMessageImpl)mf.createMessage();