Chinmoy,

I walked through the axis2-saaj code and indeed when creating a
message from an input stream using MessageFactory, axis2-saaj doesn't
even request the attachments from Axiom. However, I'm not familiar
enough with the code to be able to fix this myself.

Maybe somebody else can help here?

Andreas

On Thu, Dec 18, 2008 at 13:05, Chinmoy Chakraborty <cch...@gmail.com> wrote:
> Andreas,
>
> Please find attached attachment.xml which I am using as inputstream to
> create SOAPMessage. The MIME boundary in my previous code snippet may differ
> since it is generated at runtime but this is the file generated by another
> system. I am also sending you the code that generates the attached file.
>
> SOAPMessage soapMsg = MessageFactory.newInstance().createMessage();
>           //setting the namespace declaration.
>           SOAPPart sp = soapMsg.getSOAPPart();
>           SOAPEnvelope se = sp.getEnvelope();
>           se.addNamespaceDeclaration("lw", "http://www.abc.com/xml/soap/";);
>           soapMsg.setProperty(soapMsg.CHARACTER_SET_ENCODING, "UTF-8");
>           soapMsg.setProperty(soapMsg.WRITE_XML_DECLARATION, "true");
>           //setting the soap header.
>           SOAPHeader soapHeader = soapMsg.getSOAPHeader();
>           //setting the session id
>           SOAPElement soapHeaderElement1 =
> soapHeader.addChildElement("session", "lw", "http://www.abc.com/xml/soap/";);
>
> soapHeaderElement1.addTextNode("8e0b383911e3942c87fda0be8ae1879b");
>           //setting the transactionId
>           SOAPElement soapHeaderElement2 =
> soapHeader.addChildElement("transactionId", "lw",
> "http://www.abc.com/xml/soap/";);
>           soapHeaderElement2.addTextNode(String.valueOf("2"));
>           //setting the serverId
>           SOAPElement soapHeaderElement3 =
> soapHeader.addChildElement("serverId", "lw",
> "http://www.abc.com/xml/soap/";);
>
> soapHeaderElement3.addTextNode(String.valueOf("192.168.1.66_d7618e5711e394247a7da0be8ae08921"));
>           SOAPBody soapBody = soapMsg.getSOAPBody();
>           SOAPElement callElement = soapBody.addChildElement("call", "lw",
> "http://www.abc.com/xml/soap/";);
>           SOAPElement msgObjectId = callElement.addChildElement("objectId");
>           msgObjectId.addTextNode("system");
>           SOAPElement msgMethod = callElement.addChildElement("method");
>           msgMethod.addTextNode("setRetVal");
>           SOAPElement paramElement = callElement.addChildElement("param");
>           SOAPElement valueElement = paramElement.addChildElement("value");
>           valueElement.addTextNode("attachment.txt");
>           DataHandler dh = new DataHandler(new FileDataSource("C:\\Documents
> and Settings\\lab\\Desktop\\car.txt"));
>           AttachmentPart ap = soapMsg.createAttachmentPart();
>           ap.setContentId("attachment.txt");
>           ap.setContent(dh.getContent(), dh.getContentType());
>           soapMsg.addAttachmentPart(ap);
>
>          OutputStream out = null;
>     try {
>       out = socket.getOutputStream();
>       out.write(0x02);
>       soapMsg.writeTo(out);
>       out.write(0x03);
>       out.flush();
>     } catch (Exception e) {
>       getLog().error("Exception sending the soap " + e, e);
>     } finally {
>       //   if (out == null) out.close();
>     }
>
>
> Chinmoy
>
> On Thu, Dec 18, 2008 at 5:21 PM, Andreas Veithen <andreas.veit...@gmail.com>
> wrote:
>>
>> Chinmoy,
>>
>> Can you also attach a sample message that you try to read with this code?
>>
>> Andreas
>>
>> On Thu, Dec 18, 2008 at 06:23, Chinmoy Chakraborty <cch...@gmail.com>
>> wrote:
>> > Andreas,
>> >
>> > Here is my code snippet.
>> >
>> > String contentType = multipart/related;
>> >  boundary=MIMEBoundaryurn_uuid_D988AB74BC9802BDC21229577126047;
>> >  type="text/xml";
>> >  start="<0.urn:uuid:d988ab74bc9802bdc21229577126...@apache.org>"
>> >
>> > MimeHeaders mimeHeaders = new MimeHeaders();
>> > mimeHeaders.addHeader("Content-Type", contentType);
>> > // Create the SOAP Message using mimeHeader and inputStream
>> > MessageFactory mf = MessageFactory.newInstance();
>> > SOAPMessage soapMsg = mf.createMessage(mimeHeaders, in);
>> >
>> > The inputstream is a SOAPMessage with attachments. Now the newly created
>> > soapMsg in above code snippet does not contain any attachment parts.
>> >
>> > I am trying to get attachment parts in the following code snippet:
>> >
>> > List attachments = new ArrayList()
>> > if (soapMsg.countAttachments() > 0) {
>> >         Iterator itr = soapMsg.getAttachments();
>> >         while (itr.hasNext()) {
>> >           AttachmentPart att = (AttachmentPart) itr.next();
>> >           DataHandler dh = att.getDataHandler();
>> >           attachments.add(dh);
>> >         }
>> >       }
>> >
>> > The attachment list is always empty. I am using following jars:
>> >
>> > axiom-api-SNAPSHOT.jar (modified on 16th Dec, 2008)
>> > axiom-dom-SNAPSHOT.jar (modified on 16th Dec, 2008)
>> > axiom-impl-SNAPSHOT.jar (modified on 16th Dec, 2008)
>> > axis2-saaj-SNAPSHOT.jar (modified on 12th Dec, 2008)
>> > axis2-saaj-api-1.4.jar (modified on 4th April, 2008)
>> >
>> > Chinmoy
>> >
>> >
>> >
>> > On Thu, Dec 18, 2008 at 6:49 AM, Andreas Veithen
>> > <andreas.veit...@gmail.com>
>> > wrote:
>> >>
>> >> Chinmoy,
>> >>
>> >> Can you post the code that demonstrates the problem?
>> >>
>> >> Andreas
>> >>
>> >> On Wed, Dec 17, 2008 at 13:40, Chinmoy Chakraborty <cch...@gmail.com>
>> >> wrote:
>> >> > Hi All,
>> >> >
>> >> > I am creating SOAPMessage from inputstream. The inputstream is SOAP
>> >> > with
>> >> > attachments. But the attachmentParts becomes zero in the newly
>> >> > created
>> >> > SOAPMessage though the content type is "multipart/related".
>> >> >
>> >> > Why it is not created attachments when I am creating SOAP from
>> >> > inputstream
>> >> > (with attachments)? I am using axiom-api-SNAPSHOT.jar,
>> >> > axiom-dom-SNAPSHOT.jar, axiom-impl-SNAPSHOT.jar.(Axis2 1.4.1)
>> >> >
>> >> > Chinmoy
>> >
>> >
>
>

Reply via email to