Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Best way to pass large xml documents as input in SOAP Web service  RSS feed

 
asmita singh
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am creating a webservice which needs to get huge xml documents as input from Client (Uploader). I tried to create a service with the below code but it gives me OutOfMemory Exception. Whats the best way to do this?
public String attachAnyFile(DataHandler dataHandler, String file)
{
String filename="";
try {
//DataHandler dataHandler=new DataHandler(fileDataSource);
File f=new File("C:/"+file);
filename=f.getName();
System.out.println("\n\t Writing to File /" + filename);
BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream("C:/WS Projects/CMSWS/"+file));
BufferedInputStream bin = new BufferedInputStream(dataHandler.getInputStream());

byte[] buffer = new byte[256];
while (true)
{
int bytesRead = bin.read(buffer);
if (bytesRead == -1)
break;
bout.write(buffer, 0, bytesRead);
}
bin.close();
bout.close();


Thanks for help!
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How big a file are we talking about? Have you changed the memory settings of the JVM from their defaults? If not, try that first.
 
asmita singh
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:How big a file are we talking about? Have you changed the memory settings of the JVM from their defaults? If not, try that first.


We are talking about File about 30 MB in size and will be in multitudes based on number of concurrent requests the web service receives. Max number of concurrent users will be 6.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, that's sizable. Are you sending it as a SOAP attachment? Otherwise, the performance will most likely suck no matter what you do.

Ulf Dittmer wrote:Have you changed the memory settings of the JVM from their defaults? If not, try that first.
 
asmita singh
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:OK, that's sizable. Are you sending it as a SOAP attachment? Otherwise, the performance will most likely suck no matter what you do.

Ulf Dittmer wrote:Have you changed the memory settings of the JVM from their defaults? If not, try that first.


Yes, I intend to send it as a SOAP attachment. I went with the approach I posted in the Code snippet above. Will this work in real time situation? If not then can you guide me through what is the most optimum way to achieve Passing XML file as input?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'm not sure what that code snippet does - it doesn't seem to involve SOAP ... ?

Real time? Nothing about Java is real time (not unless you use a special JVM, anyway, and even then handling 30MB of data is not going to be happening on a real-time basis); is that really what you want?

I'll ask a third time:
Ulf Dittmer wrote:Have you changed the memory settings of the JVM from their defaults? If not, try that first.
 
asmita singh
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Well, I'm not sure what that code snippet does - it doesn't seem to involve SOAP ... ?

Real time? Nothing about Java is real time (not unless you use a special JVM, anyway, and even then handling 30MB of data is not going to be happening on a real-time basis); is that really what you want?

I'll ask a third time:
Ulf Dittmer wrote:Have you changed the memory settings of the JVM from their defaults? If not, try that first.


Yes, I need the input xml files to be processed realtime. they will also lead to generation of output xml files which will be send as webservice response.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest that you don't know what the phrase "real time" means in computer science. Perhaps you could rephrase your requirements so as not to include that phrase?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!