Jituimplemented the support for Provider-based endpoints in JAX-WS RI. Without undermining the wonderful effort of JAX-WS esteemed spec leads, here is an attempt to capture a whiteboard discussion on Provider-based endpoints possible combinations that Jitu and I had last Friday afternoon.

JAX-WS 2.0introduces javax.xml.ws.Provider interface that is an alternative to a Java service endpoint interface (SEI) based endpoint. It is used if the services need to work at the XML message level.

A Provider-based endpoint can receive data in javax.xml.transform.Source, javax.activation.DataSource or javax.xml.soap.SOAPMessage formats. It can work in either payload or message mode. JAX-WS specification has a conformance requirement (Provider support required) that defines the combinations of the Provider type, the mode and SOAP/HTTP or XML/HTTP binding. Additionally, the message on the service endpoint may be received as SOAP message (does not matter 1.1 or 1.2) or a mime multipart message. The table below summarizes the requirement with all the possible combinations.

                                                    
 XML/HTTPSOAP/HTTP

Provider<Source>

PayloadPrimary part or content as SourceSOAP Body from the primary part or SOAP Body as Source
MessagePrimary part or content as SourceSOAP Envelope from the primary part or SOAP Envelope as Source

Provider<DataSource>

PayloadNot Valid [1]Not Valid [1]
MessageDataSource as an objectNot Valid [2]

Provider<SOAPMessage>

PayloadNot Valid [3]Not Valid [3]
MessageNot Valid [4]SOAPMessage as an object

Provider<Source> may receive a mime multipart message or an XML message. If it is a mime multipart message, then the primary part for XML/HTTP and SOAP Envelope for SOAP/HTTP is extracted and converted to the Source for payload mode. The primary part, in the case of mime multipart message, must contain XML data for XML/HTTP binding. If it is an XML message then the content for XML/HTTP (irrespective of mode) is converted to the Source. The XML message is converted to SOAP message and SOAP Body or Envelope for SOAP/HTTP (depending upon the mode) is converted to the Source.

[1] Provider<DataSource> is used for sending attachments and thus payload mode is not valid.

[2] Provider<DataSource> in SOAP/HTTP is not valid since attachments in SOAP are sent using Provider<SOAPMessage>.

[3] Provider<SOAPMessage> in payload mode is not valid because the entire SOAPMessage is received, not just the payload which corresponds to the body of the SOAPMessage.

[4] Provider<SOAPMessage> in message mode using XML/HTTP binding is not valid since the client may have sent an XML message that may not be SOAP.

Provider<Source>-based endpoints using XML/HTTP binding allows you to develop and deploy RESTful Web services with JAX-WS 2.0. Read Marc Hadley's blog for more details.

I'll provide a similar explanation on Dispatch-based clients, used to invoke RESTful Web service, in a subsequent blog.

JAX-WS is available in Glassfish.

Technorati: JAX-WS Rest Web services glassfish