You aren't using CXF:

 
com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:110)
>       at
> com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
>       at

That's the JAX-WS RI built into the JDK which cannot handle streaming MTOM 
without a bunch of extra custom configuration and annotations.  Check you 
classpath to make sure the CXF JAX-WS implementation is there.


Dan



On Jun 18, 2013, at 7:24 PM, shamikb <[email protected]> wrote:

> Hi,
> 
> I'm struggling to read a large file transmitted through a SOAP based web
> service. The client code is failing with Out of memory exception. I'm using
> MTOM to send the binary data, hoping that would be able to take care of
> transmitting and reading large file. The file size in question is 750mb. I'm
> using apache cxf. Here's the web services endpoint implementation.
> 
> @MTOM
> @WebService(endpointInterface =
> "com.test.contentservice.service.IContentService")
> @BindingType(value=javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING)
> public class ContentServiceImpl implements IContentService {
> 
> @Override
>    public ContentResponse getFile(ContentRequest req) {
>        ContentResponse res = new ContentResponse();
>        try {
>            File file = this.contentManager.getFile(req);
>            DataSource source = new FileDataSource(file);
>            DataHandler dataHandler = new DataHandler(source);
>            res.setFileData(dataHandler);
>            res.setFileName(file.getName());
>        } catch (Exception ex) {
>        }
>        return res;
>    }
> 
> 
> I've turned on MTOM through spring , Spring entry :
> 
> <jaxws:endpoint id="contentService" implementor="#contentServiceImpl"
>        address="/contentservice">
>        <jaxws:dataBinding>
>            <bean class="org.apache.cxf.jaxb.JAXBDataBinding">
>                <property name="marshallerProperties">
>                    <map>
>                        <entry>
>                            <key>
>                                <value>jaxb.encoding</value>
>                            </key>
>                            <value>UTF-8</value>
>                        </entry>
>                    </map>
>                </property>
>            </bean>
>        </jaxws:dataBinding>
>        <jaxws:properties>
>            <entry key="mtom-enabled" value="true" />
>        </jaxws:properties>
>    </jaxws:endpoint>
> 
> The client code is generated using cxf wsdl2java tool. Here's a sample
> client code
> 
> ContentResponse res =  new ContentResponse();
>        try{
>            res = getRegisterPort().getFile(req);
>            DataHandler dataHandler = res.getFileData();
>            if(dataHandler!=null){
>                    final InputStream in = dataHandler.getInputStream(); 
>                    byte[] bytes = IOUtils.toByteArray(in);
>            }
>        }catch (Exception ex) {
>            LOGGER.error("Error in invoking getContent service",ex);
>        }
> 
> Here's the response object
> 
> @XmlAccessorType( XmlAccessType.FIELD )
> public class ContentResponse extends ContentServiceResponseBase {
> 
>    private String content;
>    private String source;
>    private String fileName;
>    @XmlMimeType("application/octet-stream")
>    private DataHandler fileData;
> // Getter / Setter ...
> }
> 
> Turned on mtom in client code :
> 
> final BindingProvider bpAdmin = (BindingProvider) port;
>               
> bpAdmin.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
> curlUrl);
>               SOAPBinding binding = (SOAPBinding)bpAdmin.getBinding();
>               binding.setMTOMEnabled(true);
> 
> 
> jvm entry is as follows :
> 
> -Xms64m -Xmx6144m
> 
> And the exception :
> 
> Exception in thread "taskExecutor-12" java.lang.OutOfMemoryError: Java heap
> space
>       at java.util.Arrays.copyOf(Arrays.java:2882)
>       at
> java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
>       at
> java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:515)
>       at java.lang.StringBuilder.append(StringBuilder.java:189)
>       at
> com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleCharacters(StAXStreamConnector.java:312)
>       at
> com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:176)
>       at
> com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:349)
>       at
> com.sun.xml.internal.bind.v2.runtime.BridgeImpl.unmarshal(BridgeImpl.java:109)
>       at com.sun.xml.internal.bind.api.Bridge.unmarshal(Bridge.java:222)
>       at
> com.sun.xml.internal.ws.client.sei.ResponseBuilder$DocLit.readResponse(ResponseBuilder.java:514)
>       at
> com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:110)
>       at
> com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
>       at
> com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
>       at $Proxy33.getFile(Unknown Source)
> 
> 
> Not sure what I'm missing here, any pointer will be highly appreciated.
> 
> - Thanks
> 
> 
> 
> 
> --
> View this message in context: 
> http://cxf.547215.n5.nabble.com/Out-of-memory-exception-while-retrieving-large-file-using-CXF-SOAP-webservice-tp5729463.html
> Sent from the cxf-user mailing list archive at Nabble.com.

-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to