|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.xml.rpc.handler.GenericHandler
org.systinet.wasp.handler.WaspGenericHandler
org.systinet.wasp.attachments.UnreferencedAttachmentsHandler
JAX-RPC handler and static helper functions to handle unreferenced attachments. By unreferenced attachments mean attachments that are not described in WSDL (no MIME or DIME part, no standard reference in body). Such attachments are sent for example by .NET in its default configuration.
This JAX-RPC handler reads attachments from call context on the sending side and attaches them to the message; on the receiver side all SOAP message attachments are made accessible by putting them to the call context. To put/get attachments to/from context use helper functions provided in this class.
Example (client sending and receiving unreferenced attachments):
// prepare (for communication with .NET SSJ must be set to use DIME; either for this processing or globally) ServiceClient serviceClient = ServiceClient.create("http://servicehost/path/service?wsdl); UnreferencedAttachmentsHandler.registerUnreferencedAttachmentsHandler(serviceClient); ServiceIface service = (ServiceIface) serviceClient.createProxy(ServiceIface.class); // invoke InputStream attachment = ...; UnreferencedAttachmentsHandler.addAttachment(serviceClient.getCallContext(), attachment); service.method(); // read received attachments List attachments = UnreferencedAttachmentsHandler.getInputStreams(serviceClient.getCallContext()); for (Iterator attachmentIterator = attachments.iterator(); attachmentIterator.hasNext(); ) { InputStream attachmentStream = (InputStream) attachmentIterator.next(); // use attachmentStream attachmentStream.close(); } UnreferencedAttachmentsHandler.releaseUnreferencedAttachments(serviceClient);
Field Summary | |
static java.lang.String |
CONTEXT_DATA_KEY
A key for unreferenced attachment data in the call context. |
Fields inherited from class org.systinet.wasp.handler.WaspGenericHandler |
headers |
Constructor Summary | |
protected |
UnreferencedAttachmentsHandler(java.lang.String messageAttachmentType)
Creates a new instance of the handler. |
Method Summary | |
static void |
addAttachment(CallContext callContext,
javax.activation.DataHandler attachment)
Adds a new attachment to the outgoing message. |
static void |
addAttachment(CallContext callContext,
java.io.InputStream attachment)
Adds a new attachment to the outgoing message. |
static void |
addAttachments(CallContext callContext,
java.util.Collection attachments)
Adds a collection of attachment to the outgoing message. |
static java.util.List |
getAttachmentParts(CallContext callContext)
Returns all input message's attachments as SAAJ attachment parts. |
static java.util.List |
getInputStreams(CallContext callContext)
Returns all input message's attachments as input streams. |
static java.util.List |
getMessageAttachments(CallContext callContext)
Returns all input message's attachments as message attachments. |
boolean |
handleInput(MessageContext context)
Reads all message's attachments and puts the structure in the context. |
boolean |
handleOutput(MessageContext context)
Puts all attachments from the context into the message. |
static void |
registerUnreferencedAttachmentsHandler(Processing processing)
A helper method; registers a new instance of this handler to a processing. |
static void |
registerUnreferencedAttachmentsHandler(Processing processing,
java.lang.String attachmentType)
See registerUnreferencedAttachmentsHandler(org.systinet.wasp.webservice.Processing) ; this method in addition sets up the handler
to always set the attachment type of the message to the specified one. |
static void |
releaseUnreferencedAttachments(ServiceClient serviceClient)
Releases all unreferenced attachments. |
Methods inherited from class org.systinet.wasp.handler.WaspGenericHandler |
getHeaders, handleRequest, handleResponse, init |
Methods inherited from class javax.xml.rpc.handler.GenericHandler |
destroy, handleFault |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String CONTEXT_DATA_KEY
Constructor Detail |
protected UnreferencedAttachmentsHandler(java.lang.String messageAttachmentType)
messageAttachmentType
- null
(= use SSJ default),
Message.CT_MULTIPART_RELATED
or Message.CT_APPLICATION_DIME
java.lang.IllegalArgumentException
- if messageAttachmentType
is wrongMethod Detail |
public boolean handleOutput(MessageContext context)
handleOutput
in class WaspGenericHandler
context
- SOAPMessageContext
true
means process next handler, false
means stop processing and return response to client(on server) or stop processing and
deserialize response(on client)public boolean handleInput(MessageContext context)
handleInput
in class WaspGenericHandler
context
- SOAPMessageContext
true
means process next handler, false
means stop processing and return response to client(on server) or stop processing and
deserialize response(on client)public static void registerUnreferencedAttachmentsHandler(Processing processing)
processing
- a processing (ServiceClient
or ServiceEndpoint
) that should
send/receive unreferenced attachments
java.lang.NullPointerException
- if processing
is null
public static void registerUnreferencedAttachmentsHandler(Processing processing, java.lang.String attachmentType)
registerUnreferencedAttachmentsHandler(org.systinet.wasp.webservice.Processing)
; this method in addition sets up the handler
to always set the attachment type of the message to the specified one.
This is useful only when WSDL says nothing about the type and you do not want to use SSJ's default.
processing
- a processing to setattachmentType
- null
, Message.CT_MULTIPART_RELATED
or Message.CT_APPLICATION_DIME
java.lang.IllegalArgumentException
- if messageAttachmentType
is wrong
java.lang.NullPointerException
- if processing
is null
public static java.util.List getAttachmentParts(CallContext callContext)
callContext
- get attachments from this call context
AttachmentPart
s; never null
;
for better perfomance it is recommend to access it sequentially via iteratorpublic static java.util.List getMessageAttachments(CallContext callContext)
callContext
- get attachments from this call context
MessageAttachment
s; never null
;
for better perfomance it is recommend to access it sequentially via iteratorpublic static java.util.List getInputStreams(CallContext callContext)
callContext
- get attachments from this call context
InputStream
s; never null
;
for better perfomance it is recommend to access it sequentially via iteratorpublic static void releaseUnreferencedAttachments(ServiceClient serviceClient)
This method must be called on the client side for every call when work with unreferenced attachments is done.
serviceClient
- service client that holds the attachments
java.lang.NullPointerException
- if serviceClient
is null
public static void addAttachments(CallContext callContext, java.util.Collection attachments) throws java.io.IOException
callContext
- add into this call contextattachments
- a collection (possibly unmodifiable) of InputStream
,
DataHandler
or MessageAttachment
java.io.IOException
- I/O problem with some MessageAttachment
java.lang.NullPointerException
- if some parameter is null
java.lang.IllegalArgumentException
- if collection contains null
or an instance
of unexpected class
java.lang.IllegalStateException
- if there are unreleased unreferenced attachmentspublic static void addAttachment(CallContext callContext, java.io.InputStream attachment)
callContext
- add into this call contextattachment
- attachment represented as input stream; content type "application/octet-stream"
will be used for it
java.lang.NullPointerException
- some parameter is null
java.lang.IllegalStateException
- if there are unreleased unreferenced attachmentspublic static void addAttachment(CallContext callContext, javax.activation.DataHandler attachment)
callContext
- add into this call contextattachment
- attachment represented by data handler; remember to set up
DataContentHandlerFactory
properly for attachment type
java.lang.NullPointerException
- some parameter is null
java.lang.IllegalStateException
- if there are unreleased unreferenced attachments
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |