Show Table of Contents
9.19.2. SwaRef
WS-I Attachment Profile 1.0 は swaRef 使って MIME 添付の部分を参照するメカニズムを定義します。 このメカニズムでは、 タイプ wsi:swaRef の XML 要素のコンテントは MIME 添付として送信され、 SOAP Body 内側の要素は RFC 2111 で定義されるように CID URI スキームでこの添付への参照を格納します。
9.19.2.1. SwaRef と JAX-WS エンドポイントを併用
JAX-WS エンドポイントはすべてのマーシャル/アンマーシャルを JAXB API に委任します。
DataHandler
タイプに対して SwaRef エンコーディングを有効にする最もシンプルな方法は、 以下のようにペイロード bean に @XmlAttachmentRef
アノテーションを付ける方法です。
/** * Payload bean that will use SwaRef encoding */ @XmlRootElement public class DocumentPayload { private DataHandler data; public DocumentPayload() { } public DocumentPayload(DataHandler data) { this.data = data; } @XmlElement @XmlAttachmentRef public DataHandler getData() { return data; } public void setData(DataHandler data) { this.data = data; } }
エンドポイントをラップしたドキュメントでは、 サービスエンドポイントインターフェースで
@XmlAttachmentRef
アノテーションを指定することさえ可能です。
@WebService public interface DocWrappedEndpoint { @WebMethod DocumentPayload beanAnnotation(DocumentPayload dhw, String test); @WebMethod @XmlAttachmentRef DataHandler parameterAnnotation(@XmlAttachmentRef DataHandler data, String test); }
次にメッセージは CID で添付部分を参照することになります。
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'> <env:Header/> <env:Body> <ns2:parameterAnnotation xmlns:ns2='http://swaref.samples.jaxws.ws.test.jboss.org/'> <arg0>cid:0-1180017772935-32455963@ws.jboss.org</arg0> <arg1>Wrapped test</arg1> </ns2:parameterAnnotation> </env:Body> </env:Envelope>