Hi guys,

I try to sent a file (jpg or pdf) to my Webservice using MTOM.
When I try to write the file to disk, the file is only 1 k big and contains 
different data then I expect.
I test the service with attachment through SOAP.

What do I do wrong?

Service Implementation:

@WebService(endpointInterface = "zz.com.HelloWorld")
public class HelloWorldImpl implements HelloWorld {

    public int uploadData(
            @XmlMimeType("*/*") DataHandler code) {
        try {
            OutputStream fos = new FileOutputStream(new File("c:\\MTOM.jpg"));

            InputStream fis = code.getInputStream();

            byte[] b = new byte[1000000];
            int bytesRead = 0;
            while ((bytesRead = fis.read(b)) != -1) {
                fos.write(b, 0, bytesRead);
            }
            fos.flush();
            fos.close();
            fis.close();

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return 0;
    }
}

BEANS.XML

<jaxws:endpoint id="helloWorld" implementor="zz.com.HelloWorldImpl"
        address="/HelloWorld">

        <jaxws:properties>
            <entry key="mtom-enabled" value="true" />
            <entry key="mtom-threshold" value="0" />
        </jaxws:properties>

    </jaxws:endpoint>

                                          

Reply via email to