Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

Passing large file via webservice

Thread view: 
8 - 29 Nov 2005 15:49 GMT
Hi,

I have a webservice project. It requires pass the content of a file
between the services and their clients. The file can be as big as 5M.
We use Oracle 10g application server.

I defined an interface. Use the byte[] to pass the content of a file.
It works for small size files. However, to sending a 1M size of a file,
it took about 10 minutes, and failed with the following exceptions:
Exception in thread "main" [SOAPException: faultCode=SOAP-ENV:Server;
msg= [java
.lang.OutOfMemoryError]]
       at proxy.
SubmitLargeFileIFProxy.makeSOAPCallRPC(SubmitLargeFileIFProxy.java:102)
       at proxy.
SubmitLargeFileIFProxy.submit(SubmitLargeFileIFProxy.java:78)
       at SubmitLargeFile.main(SubmitLargeFile.java:44)

I used -Xmx512m in server side, and it ran out of memory.

So I have at least two problems. It took too long even if it handles a
small file. It took too much memory space. I guess it is something to
do with binding. The byte[] is mapped to xsd:base64Binary. I tried
Byte[], it comes with same mapping, and same behavior. I also tried to
hide the byte[] in an object, which implements Serializable. Each time,
the generated wsdl shows the byte[] or Byte[] are mapped to
xsd:base64Binary.

Did I do anything wrong? Is there any better way to send a file via
webservice?

Thanks a lot,

Peter

--------------------------------------------------------------------------------------------
Here is the list of interface.

import java.rmi.Remote;
import java.rmi.RemoteException;

public interface SubmitLargeFileIF extends Remote {
   public String submit(String fileName, byte[] fileContent, String
otherInfo) throws RemoteException;
}

Here is the wsdl generated by oracle toolkit
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="SubmitLargeFileImpl"
       targetNamespace="http://tempuri.org/SubmitLargeFileImpl.wsdl"
       xmlns="http://schemas.xmlsoap.org/wsdl/"
       xmlns:tns="http://tempuri.org/SubmitLargeFileImpl.wsdl"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" >

 <documentation>
 WSDL for Service: SubmitLargeFileImpl, generated by Oracle WSDL
toolkit (version: 1.1)
 </documentation>

 <types>
   <schema
targetNamespace="http://tempuri.org/SubmitLargeFileImpl.xsd"
xmlns:tns="http://tempuri.org/SubmitLargeFileImpl.xsd"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
 </types>

 <message name="submitInput">
   <part name="param0" type="xsd:string"/>
   <part name="param1" type="xsd:base64Binary"/>
   <part name="param2" type="xsd:string"/>
 </message>
 <message name="submitOutput">
   <part name="return" type="xsd:string"/>
 </message>

 <portType name="SubmitLargeFileImplPortType">
   <operation name="submit">
     <input message="tns:submitInput"/>
     <output message="tns:submitOutput"/>
   </operation>
 </portType>

 <binding name="SubmitLargeFileImplBinding"
type="tns:SubmitLargeFileImplPortType">
   <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="rpc"/>
   <operation name="submit">
     <soap:operation soapAction="urn:SubmitLargeFileImpl/submit"/>
     <input>
       <soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:SubmitLargeFileImpl"/>
     </input>
     <output>
       <soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:SubmitLargeFileImpl"/>
     </output>
   </operation>
 </binding>

 <service name="SubmitLargeFileImpl">
   <port name="SubmitLargeFileImplPort"
binding="tns:SubmitLargeFileImplBinding">
     <soap:address
location="http://192.168.1.201:80/submitLargeFile/submit"/>
   </port>
 </service>

</definitions>
adamspe@gmail.com - 29 Nov 2005 16:29 GMT
Transfering files as byte arrays within SOAP messages is obviously not
going to be scalable, as you're seeing.  SOAP with attachments might be
a better way to go, I'm not really sure how scalable it will be though
either.  If you're willing to divorce the file transfer from SOAP basic
HTTP PUT/POST would be more efficient avoiding multipart MIME and the
need to examine the incoming streams in search of boundaries.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.