Debian Codegraph @

samples/swa/SwaBindingImpl.java

raw
1 /**
2 * SwaBindingImpl.java
3 *
4 * This file was auto-generated from WSDL
5 * by the Apache Axis 1.2alpha Dec 07, 2003 (08:01:12 EST) WSDL2Java emitter.
6 */
7 package samples.swa;
8
9 import org.apache.axis.AxisFault;
10 import org.apache.axis.Message;
11 import org.apache.axis.MessageContext;
12 import org.apache.axis.attachments.AttachmentPart;
13 import org.apache.axis.attachments.Attachments;
14
15 import javax.activation.DataHandler;
16 import javax.mail.internet.MimeBodyPart;
17 import java.util.Iterator;
18
19 /**
20 * Class SwaBindingImpl
21 *
22 * @version %I%, %G%
23 */
24 public class SwaBindingImpl implements samples.swa.SwaPort {
25
26 /**
27 * Method swaSend
28 *
29 * @param applicationName
30 * @param content
31 * @return
32 * @throws java.rmi.RemoteException
33 */
34 public java.lang.String swaSend(
35 java.lang.String applicationName, javax.mail.internet.MimeMultipart content)
36 throws java.rmi.RemoteException {
37
38 MimeBodyPart mpb = null;
39
40 System.out.println("Application: " + applicationName);
41
42 /*
43 * Now do some printing to get information about the multipart
44 * content and the associated attachments. Axis performs
45 * several steps during deserialization of this SOAP
46 * call. Only the steps of interesst are described here.
47 *
48 * The MIME multipart that contains the other parts (because
49 * it's multipart/mixed or multipart/related) is handled as
50 * ONE Axis attachment during the first part of
51 * deserialization. This attachment is identified by the CID:
52 * prefixed string generated during serialization.
53 *
54 * The next step (see
55 * MimeMultipartDataHandlerDeserializer.java) gets the data
56 * handler of the Axis attachment and creates a MimeMultipart
57 * object using the data source as input of the new
58 * MimeMultipart object. The MimeMultipart object parses the
59 * input (on demand? -> this need to be clarified) and builds
60 * the associated body parts.
61 *
62 * The Axis attachment part is not disposed or otherwise
63 * managed after it was serialized into the MimeMultipart
64 * object. Therefore it is a good idea to call the dispose()
65 * method of the Axis attachment part after processing is
66 * complete. Doing so releases all used resources, also
67 * deleting disk cache files if necessary, of this attachment
68 * part.
69 */
70 try {
71 int contCount = content.getCount();
72
73 System.out.println("Number of Mimeparts: " + contCount);
74
75 for (int i = 0; i < contCount; i++) {
76 mpb = (MimeBodyPart) content.getBodyPart(i);
77
78 DataHandler dh = mpb.getDataHandler();
79
80 System.out.println("Mime data type: " + dh.getContentType());
81 }
82 } catch (javax.mail.MessagingException ex) {
83 }
84
85 /*
86 * the next prints are just for information only
87 */
88 AttachmentPart[] attParts = getMessageAttachments();
89
90 System.out.println("Number of attachements: " + attParts.length);
91
92 if (attParts.length > 0) {
93 try {
94 System.out.println("Att[0] type: "
95 + attParts[0].getContentType());
96 System.out.println(
97 "Att[0] dh type: "
98 + attParts[0].getDataHandler().getContentType());
99 System.out.println("Att[0] file: "
100 + attParts[0].getAttachmentFile());
101 } catch (javax.xml.soap.SOAPException ex) {
102 }
103 }
104
105 /*
106 * Now process the parametes including the MimeMultipart
107 */
108
109 /*
110 * Processing is done, now dispose the attachements. This is not done
111 * by Axis, should be done by service.
112 */
113 MessageContext msgContext = MessageContext.getCurrentContext();
114 Message reqMsg = msgContext.getRequestMessage();
115 Attachments messageAttachments = reqMsg.getAttachmentsImpl();
116
117 messageAttachments.dispose();
118
119 return null;
120 }
121
122 /**
123 * extract attachments from the current request
124 *
125 * @return a list of attachmentparts or
126 * an empty array for no attachments support in this axis
127 * buid/runtime
128 * @throws AxisFault
129 */
130 private AttachmentPart[] getMessageAttachments() throws AxisFault {
131
132 MessageContext msgContext = MessageContext.getCurrentContext();
133 Message reqMsg = msgContext.getRequestMessage();
134 Attachments messageAttachments = reqMsg.getAttachmentsImpl();
135 int attachmentCount =
136 messageAttachments.getAttachmentCount();
137 AttachmentPart attachments[] = new AttachmentPart[attachmentCount];
138 Iterator it =
139 messageAttachments.getAttachments().iterator();
140 int count = 0;
141
142 while (it.hasNext()) {
143 AttachmentPart part = (AttachmentPart) it.next();
144 attachments[count++] = part;
145 }
146 return attachments;
147 }
148 }