Sami Korhonen
Sami Korhonen

Reputation: 1303

Returning SOAPFault from JAX-WS Provider<SOAPMessage>

what is the preferred way of creating SOAPMessage containing a SOAPFault from a webservice that implements JAX-WS Provider interface?

MessageFactory.newInstance() seems like unnecessarily expensive operation and there's no mention about thread safety. I have four possible solutions, but got no idea which I should be using:

  1. Pool of MessageFactories in a static variable
  2. Reuse the received
  3. SOAPMessage by clearing the content and possible attachment Create a synchronized method for MessageFactory.createMessage()
  4. Use MessageFactory.newInstance() for every call

Upvotes: 1

Views: 339

Answers (1)

Aviram Segal
Aviram Segal

Reputation: 11120

Premature optimization is the root of all evil

As this will be very easy to change later, I would go with option 4 (MessageFactory.newInstance() every time) and only consider other options if and when I see it has performance issues.

This might not be a performance issue at all and you'll save yourself some coding.

Upvotes: 1

Related Questions