Announcement Announcement Module
Collapse
No announcement yet.
having trouble with Attachments with AxiomSoapMessageFactory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • having trouble with Attachments with AxiomSoapMessageFactory

    Hi guys,

    I seem to be having some trouble with Attachments when sending an attachment from a Spring WS Client. I'm using AxiomSoapMessageFactory.

    Here is my code that invokes the send and receive:

    public void customAttachmentSendAndReceive(String endpoint, String soapAction) {

    FileDataSource fds = new FileDataSource(new
    File("C:\\dev\\dummy_attachments\\dummy.csv"));


    UpdateInfo req = new UpdateInfo();
    req.setUserName("difrangor");
    req.setChangeDateTime(new Date());

    DataHandler handler = new DataHandler(fds);

    webServiceTemplate.setMessageFactory(messageFactor y);
    webServiceTemplate.setMarshaller(marshaller);
    webServiceTemplate.setUnmarshaller(unmarshaller);



    Object res = webServiceTemplate.marshalSendAndReceive(endpoint, req, new RTVAttachmentMessageCallback(soapAction, handler, "dummyName"));
    System.out.println("GOT RESULT OF CLASS: " + res.getClass());

    }

    ----------------------------------------------
    I know that this dummy.csv exists in this location, because I have tried this same attachment with SOAPUI without getting this error.
    Here is my Callback class:


    public class AttachmentMessageCallback implements WebServiceMessageCallback {

    private String soapAction;
    private DataHandler attachHandler;
    private String attachName;

    public AttachmentMessageCallback(String soapAction, DataHandler attachHandler, String attachName) {
    super();
    this.soapAction = soapAction;
    this.attachHandler = attachHandler;
    this.attachName = attachName;
    }

    public void doWithMessage(WebServiceMessage wsMsg) throws IOException, TransformerException {
    AxiomSoapMessage axiomSoap = (AxiomSoapMessage)wsMsg;
    axiomSoap.setSoapAction(soapAction);
    axiomSoap.addAttachment(attachName, attachHandler);

    }

    public DataHandler getAttachHandler() {
    return attachHandler;
    }

    public void setAttachHandler(DataHandler attachHandler) {
    this.attachHandler = attachHandler;
    }

    public String getAttachName() {
    return attachName;
    }

    public void setAttachName(String attachName) {
    this.attachName = attachName;
    }

    public String getSoapAction() {
    return soapAction;
    }

    public void setSoapAction(String soapAction) {
    this.soapAction = soapAction;
    }

    }

    ----------------------------------------------------
    The message goes through fine, but at the server side we have TIBCO Business Works and that is complaining with the following exception:

    java.lang.IllegalStateException: Found something other than a middle boundary at start of container part.
    at com.tibco.net.mime.MimeContainerInputPartImpl.byte (MimeContainerInputPartImpl.java:283)
    at com.tibco.net.mime.MimeContainerInputPartImpl.<ini t>(MimeContainerInputPartImpl.java:30)
    at com.tibco.net.mime.MimeMessageFactory.parseMimeMes sage(MimeMessageFactory.java:96)
    at com.tibco.xml.soap.helpers.HttpHelper.readTranspor tMessage(HttpHelper.java:262)
    at com.tibco.plugin.share.http.SoapHttpTransportAppli cation.if(SoapHttpTransportApplication.java:151)
    at com.tibco.plugin.share.http.SoapHttpTransportAppli cation.processMessage(SoapHttpTransportApplication .java:122)
    at com.tibco.plugin.share.http.TransportApplicationDe mux.processMessage(TransportApplicationDemux.java: 36)
    at com.tibco.plugin.share.http.TransportApplicationDe mux.processMessage(TransportApplicationDemux.java: 36)
    at com.tibco.plugin.share.http.HttpServer.processMess age(HttpServer.java:22)
    at com.tibco.plugin.share.http.HttpServerDispatcher.p rocessMessage(HttpServerDispatcher.java:42)
    at com.tibco.plugin.share.http.servlet.BwServlet.a(Bw Servlet.java:91)
    at com.tibco.plugin.share.http.servlet.BwServlet.doPo st(BwServlet.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:256)
    at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
    at org.apache.catalina.valves.CertificatesValve.invok e(CertificatesValve.java:246)
    at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:641)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
    at org.apache.catalina.core.StandardContext.invoke(St andardContext.java:2416)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
    at org.apache.catalina.valves.ErrorDispatcherValve.in voke(ErrorDispatcherValve.java:171)
    at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:641)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:172)
    at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:641)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
    at org.apache.coyote.tomcat4.CoyoteAdapter.service(Co yoteAdapter.java:223)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:601)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:392)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:565)
    at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:619)
    at java.lang.Thread.run(Thread.java:534)

    ------------------------------------------------------

    Now I know that this attachment works because I have tried to send it with SOAPUI and it does not give this exception. I have tried to trap the request with Parox Proxy and here's my Request Information:

    ------------------------------------------------
    SPRINGWS REQUEST
    ------------------------------------------------

    POST http://corp.mycompany.net:9091/myService/myWS HTTP/1.1
    Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_FFB0A1BADC5C10BD2A11 84283568001; type="text/xml"; start="<0.urn:uuid:FFB0A1BADC5C10BD2A1184283568002 @apache.org>"; charset="UTF-8"
    SOAPAction: /Upload/UploadWithAttachmentService
    User-Agent: Java1.5.0_06 Paros/3.2.13
    Host: corp.mycompany.net:9091
    Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Proxy-Connection: Keep-Alive
    Content-Length: 337

    <?xml version='1.0' encoding='UTF-8'?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
    <axis2ns1:updateInfo xmlns:axis2ns1="http://www.mycompany.com/mysvc">
    <axis2ns1:changeDateTime>2007-07-12T19:39:16.062-04:00</axis2ns1:changeDateTime>
    </axis2ns1:updateInfo>
    </soapenv:Body>
    </soapenv:Envelope>

    ----------------------------------------------------------
    Also for reference, here's SOAPUI's Request that does not produce an Error

    -----------------------------------------------------------
    SOAPUI REQUEST
    -----------------------------------------------------------

    POST http://corp.mycompany.net:9091/myService/myWS HTTP/1.1
    SOAPAction: "/Upload/UploadWithAttachmentService"
    Content-Type: multipart/related; type="text/xml"; start="<[email protected]>"; boundary="----=_Part_0_7979252.1184280931453"
    MIME-Version: 1.0
    User-Agent: Jakarta Commons-HttpClient/3.0.1 Paros/3.2.13
    Host: corp.mycompany.net:9091
    Proxy-Connection: Keep-Alive
    Content-Length: 690

    -------------------------------------


    ------=_Part_0_7979252.1184280931453
    Content-Type: text/xml; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    Content-ID: <[email protected]>

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mysvc="http://www.mycompany.com/mysvc">
    <soapenv:Header/>
    <soapenv:Body>
    <mysvc:updateInfo>
    <mysvc:changeDateTime>01/01/2007</mysvc:changeDateTime>
    </mysvc:updateInfo>
    </soapenv:Body>
    </soapenv:Envelope>
    ------=_Part_0_7979252.1184280931453
    Content-Type: application/octet-stream
    Content-Transfer-Encoding: binary

    a,b,c,d
    e,f,g,h
    i,j,k,l
    ------=_Part_0_7979252.1184280931453--

    Any ideas?

    Amarish

  • #2
    It seems like the spring-ws request does not contain an attachment. Is that correct?

    You could try using SAAJ instead of AXIOM, and see whether that helps. Axiom used to have some issues with regard to SwA attachments, but I thought there were solved now.

    Comment


    • #3
      still not Working with last Spring WS and Axiom

      I tried to add an attachment in a Client Interceptor using last Spring Web Services (1.5.0) and Axiom release (1.2.5) and still this code doesn't create any attachment

      Code:
      DataHandler dataHandler = new DataHandler(foto.getImmagine(),
      				"application/octet-stream");
      
      AxiomSoapMessage axiomMsg = (AxiomSoapMessage) messageContext
      				.getRequest();
      axiomMsg.addAttachment("foto_allegata", dataHandler);

      Anyone succeeded generating an attachment with Axiom? and How?

      Luciano

      Comment

      Working...
      X