axis1.4 client sending file by using Mtom

2.1k views Asked by At

I am trying to send a file with an axis1.4 client to a jaxws service. My client code is like below.

System.out.println(service.getCalcImplPort().getFile(new DataHandler(new DataSource() {

            @Override
            public OutputStream getOutputStream() throws IOException {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public String getName() {
                // TODO Auto-generated method stub
                return "abc.txt";
            }

            @Override
            public InputStream getInputStream() throws IOException {
                InputStream bs = new ByteArrayInputStream("Hello world".getBytes());
                return bs;
            }

            @Override
            public String getContentType() {
                // TODO Auto-generated method stub
                return "application/soap+xml";
            }
        })));

When I look from tcpmon I see that message below is generated.

------=_Part_0_1601756168.1386618236799

Content-Type: text/xml; charset=UTF-8 Content-Transfer-Encoding: binary Content-Id:

------=_Part_0_1601756168.1386618236799 Content-Type: application/soap+xml Content-Transfer-Encoding: binary Content-Id:

hello world ------=_Part_0_1601756168.1386618236799--

XML part is

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><getFile xmlns="http://ws.kasim.com/"><arg0 href="cid:5C354342D8307DD2EC87841AD94BCCB0" xsi:type="xsd:base64Binary" xmlns=""/></getFile></soapenv:Body></soapenv:Envelope>

When i check at the server side I see that DataHandler parameter of service does not have the data sent. First of all is this a valid mtom message? and if not can anybody tell me please what is missing here ?

Thank you.

1

There are 1 answers

0
cacert On BEST ANSWER

I found solution after long search in internet. The problem was I was not setting the mtom property in client stub file. After I added the code below it started working. I did not delete the question may be somebody else need it.

call.setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT, Call.ATTACHMENT_ENCAPSULATION_FORMAT_MTOM);