Java, SAAJ, and Object Factories
JBoss comes with their own implementation of SAAJ, and yet tonight I’ve been doing nothing but dealing with exception after exception getting it working. javax.xml.soap.SOAPException: Unable to create message factory for SOAP: org.jboss.ws.core.soap.MessageFactoryImpl
So off I go to import the Sun SAAJ implementation from my favorite Maven repository:
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>saaj-api</artifactId>
<version>1.3</version>
<scope>provided</scope>
</dependency>
So what’s my problem. Simple. The world, especially the world of SOAP messages, should go more like so:
SOAPMessage msg = new SOAPMessage();
and less like
MessageFactory mFact = javax.xml.soap.MessageFactory.newInstance();
SOAPMessage msg = mFact.createMessage();
Let me do less dealing with infrastructure at instantiation, and more at presentation.