Hi all,

if i make the writeTo() of a message with attachment it write only the
envelope, skipping the rest.. it's correct? 
If it is, how do i can write the entire message (so i can rebuild it for
later uses)? 



Thx 4 any help,
Lorenzo


Sample service to test it:

import java.io.File;
import java.io.FileOutputStream;
import java.util.Iterator;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.MimeHeader;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.Provider;
import javax.xml.ws.ServiceMode;
import javax.xml.ws.WebServiceProvider;
import javax.xml.ws.Service.Mode;

@ServiceMode(value=Mode.MESSAGE)
@WebServiceProvider

public class attachmentTest implements Provider<SOAPMessage>{
        
        public SOAPMessage invoke(SOAPMessage request){
                try{
                        System.out.println("Test write resume");
                        System.out.println("SOAPMessage class : " +
request.getClass().getName()); 
                        
                        File file = new File("/var/axis2/test/SOAPMessage.msg");
                        FileOutputStream fos = new FileOutputStream(file);
                        request..writeTo(fos);
                        fos.close();
                        
                        Iterator it = request.getMimeHeaders().getAllHeaders();
                        while(it.hasNext()){
                                MimeHeader mh = (MimeHeader) it.next();
                                System.out.println("Header >> " + mh.getName() 
+ " : " + mh.getValue());
                        }
                        Iterator att = request.getAttachments();
                        while(att.hasNext()){
                                AttachmentPart attpart = (AttachmentPart) 
att.next();
                                System.out.println("Attachment >> " + 
attpart.getContentId() );
                        }
                }
                catch(Exception e){
                        System.out.println("Something goes wrong!! : " + 
e.toString());
                }
                return request;
        }
}


This is the output for my message sample:

10:37:45,149 INFO  [STDOUT] Test write resume
10:37:45,149 INFO  [STDOUT] SOAPMessage class :
org.apache.axis2.saaj.SOAPMessageImpl
10:37:45,150 INFO  [STDOUT] Header >> content-length : 1443
10:37:45,150 INFO  [STDOUT] Header >> cache-control : no-cache
10:37:45,150 INFO  [STDOUT] Header >> host : 127.0.0.1:8000
10:37:45,150 INFO  [STDOUT] Header >> user-agent : Axis/1.4
10:37:45,150 INFO  [STDOUT] Header >> pragma : no-cache
10:37:45,150 INFO  [STDOUT] Header >> content-type : multipart/related
10:37:45,151 INFO  [STDOUT] Header >> accept : application/soap+xml,
application/dime, multipart/related, text/*
10:37:45,151 INFO  [STDOUT] Header >> soapaction : ""
10:37:45,151 INFO  [STDOUT] Attachment >> 79DCD4A4606040B6C0FD77C51F77E014
10:37:45,151 INFO  [STDOUT] Attachment >> AEAD96EABAA03E66BB4C15E3DAC6E4A9

and this is the content of the file written:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";><soapenv:Body><eseguiServizio
xmlns="http://spcoop.it/cart/pdd-test";><Richiesta>&lt;persona nome="mario"
cognome="rossi"/></Richiesta><attachInZIP1 xmlns=""
href="cid:79DCD4A4606040B6C0FD77C51F77E014" /><attachInZIP2 xmlns=""
href="cid:AEAD96EABAA03E66BB4C15E3DAC6E4A9"
/></eseguiServizio></soapenv:Body></soapenv:Envelope>




-- 
View this message in context: 
http://www.nabble.com/-Axis2--saaj-SOAPMessage-writeTo-tf4638927.html#a13249324
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to