Re: [xfire-user] How to download large file from service side to client?
Hi, Try add this function to MTOM exmaple that is shipped with XFire public DataHandler echoData(DataHandler handler) { try { System.out.println(handler.getContent().toString()); } catch (IOException e) { e.printStackTrace(); } return handler; } Add it to interface too. Client side code : File file = new File(c:\\temp\\pic1.png); DataSource fileSource = new FileDataSource(file); DataHandler dataHandlerResult2 = service.echoData(new DataHandler(fileSource)); fileSource = dataHandlerResult2.getDataSource(); try { InputStream in = fileSource.getInputStream(); File outputFile = new File(c:\\temp\\outputpic1.png); OutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile)); byte[] buffer = new byte[2048]; int len; while ((len = in.read(buffer)) 0) { out.write(buffer, 0, len); } in.close(); out.flush(); out.close(); System.out.println(file saved.); } catch ( IOException e1 ) { // TODO Auto-generated catch block e1.printStackTrace(); } You should run original MTOM example first to be sure you have all libraries in place. I am not able to run XFire MTOM under Oracle OC4J 10.1.2 and 10.1.3, but Weblogic 8.1 SP6 works fine. Regards, Zdenek On 4/23/07, seego [EMAIL PROTECTED] wrote: Hi, Can someone post an example how to obtain file from serivce? I mean something like this: . Client client = Client.getInstance(service); ... DataHandler dh = service.getFile(file_name_on_server); For a while I have been trying to solve the problem and had no luck so far. Funny thing is that I can replicate XFire MTOM examples where client sends an instance of DataHandler or DataSource to service and receives content as a String. I assume, if these examples run in my environment than I have properly configured my service and client. So, why service.getStringFrom(new DataHandler(new FileDataSource(file_name_on_clien))) works, and DataHandler dh = service.getFile(file_name_on_server) doesn't? You may look at the detailed description of the problem here: http://www.nabble.com/MTOM.-Can-my-webservice-return-DataHandler--tf3607587.html Or, may be you can explain the reason for NullPointerException I am getting? -- View this message in context: http://www.nabble.com/How-to-download-large-file-from-service-side-to-client--tf3632140.html#a10141755 Sent from the XFire - User mailing list archive at Nabble.com. - To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email - To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
Re: [xfire-user] How to download large file from service side to client?
You can also try to use slightly different approach, your server method can return only a url to file exposed by http server and then you can download file with regular ( no webservice ) code. On 4/24/07, Zdeněk Vráblík [EMAIL PROTECTED] wrote: Hi, Try add this function to MTOM exmaple that is shipped with XFire public DataHandler echoData(DataHandler handler) { try { System.out.println(handler.getContent().toString()); } catch (IOException e) { e.printStackTrace(); } return handler; } Add it to interface too. Client side code : File file = new File(c:\\temp\\pic1.png); DataSource fileSource = new FileDataSource(file); DataHandler dataHandlerResult2 = service.echoData(new DataHandler(fileSource)); fileSource = dataHandlerResult2.getDataSource(); try { InputStream in = fileSource.getInputStream(); File outputFile = new File(c:\\temp\\outputpic1.png); OutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile)); byte[] buffer = new byte[2048]; int len; while ((len = in.read(buffer)) 0) { out.write(buffer, 0, len); } in.close(); out.flush(); out.close(); System.out.println(file saved.); } catch ( IOException e1 ) { // TODO Auto-generated catch block e1.printStackTrace(); } You should run original MTOM example first to be sure you have all libraries in place. I am not able to run XFire MTOM under Oracle OC4J 10.1.2 and 10.1.3, but Weblogic 8.1 SP6 works fine. Regards, Zdenek On 4/23/07, seego [EMAIL PROTECTED] wrote: Hi, Can someone post an example how to obtain file from serivce? I mean something like this: . Client client = Client.getInstance(service); ... DataHandler dh = service.getFile(file_name_on_server); For a while I have been trying to solve the problem and had no luck so far. Funny thing is that I can replicate XFire MTOM examples where client sends an instance of DataHandler or DataSource to service and receives content as a String. I assume, if these examples run in my environment than I have properly configured my service and client. So, why service.getStringFrom(new DataHandler(new FileDataSource(file_name_on_clien))) works, and DataHandler dh = service.getFile(file_name_on_server) doesn't? You may look at the detailed description of the problem here: http://www.nabble.com/MTOM.-Can-my-webservice-return-DataHandler--tf3607587.html Or, may be you can explain the reason for NullPointerException I am getting? -- View this message in context: http://www.nabble.com/How-to-download-large-file-from-service-side-to-client--tf3632140.html#a10141755 Sent from the XFire - User mailing list archive at Nabble.com. - To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email - To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email -- - When one of our products stops working, we'll blame another vendor within 24 hours.
Re: [xfire-user] How to download large file from service side to client?
Zdeněk, I have tried this. No luck. I am using Tomcat5 to expose my service. I have included the modified xfire examples http://www.nabble.com/file/8067/mtom.zip mtom.zip . They are easy to build with maven. Can you check if it works for you, when you have time. When I execute my MTOMClient.class I get this: Result : [EMAIL PROTECTED] Result : [EMAIL PROTECTED] Result : [EMAIL PROTECTED] Exception in thread main org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89) at org.codehaus.xfire.client.Client.onReceive(Client.java:391) at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139) at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48) at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26) at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131) at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75) at org.codehaus.xfire.client.Client.invoke(Client.java:335) at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77) at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57) at $Proxy0.testDataHandlerOut(Unknown Source) at org.codehaus.xfire.mtom.MTOMClient.main(MTOMClient.java:49) Caused by: java.lang.NullPointerException at org.codehaus.xfire.attachments.AttachmentUtil.getAttachment(AttachmentUtil.java:33) at org.codehaus.xfire.aegis.type.mtom.AbstractXOPType.readInclude(AbstractXOPType.java:58) at org.codehaus.xfire.aegis.type.mtom.AbstractXOPType.readObject(AbstractXOPType.java:45) at org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindingProvider.java:162) at org.codehaus.xfire.service.binding.AbstractBinding.read(AbstractBinding.java:206) at org.codehaus.xfire.service.binding.WrappedBinding.readMessage(WrappedBinding.java:50) at org.codehaus.xfire.soap.handler.SoapBodyHandler.invoke(SoapBodyHandler.java:42) at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131) at org.codehaus.xfire.client.Client.onReceive(Client.java:387) ... 10 more You should run original MTOM example first to be sure you have all libraries in place. I am not able to run XFire MTOM under Oracle OC4J 10.1.2 and 10.1.3, but Weblogic 8.1 SP6 works fine. Regards, Zdenek -- View this message in context: http://www.nabble.com/How-to-download-large-file-from-service-side-to-client--tf3632140.html#a10161135 Sent from the XFire - User mailing list archive at Nabble.com. - To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
Re: [xfire-user] How to download large file from service side to client?
Hi, it looks correct. Does the file exists? org.codehaus.xfire.attachments.AttachmentUtil.getAttachment(AttachmentUtil.java:33) It couses NullPointerException here. Try create File object from path then check if file exists and create FileDataSource and DataHandler. Regards, Zdenek On 4/24/07, seego [EMAIL PROTECTED] wrote: Zdeněk, I have tried this. No luck. I am using Tomcat5 to expose my service. I have included the modified xfire examples http://www.nabble.com/file/8067/mtom.zip mtom.zip . They are easy to build with maven. Can you check if it works for you, when you have time. When I execute my MTOMClient.class I get this: Result : [EMAIL PROTECTED] Result : [EMAIL PROTECTED] Result : [EMAIL PROTECTED] Exception in thread main org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89) at org.codehaus.xfire.client.Client.onReceive(Client.java:391) at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139) at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48) at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26) at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131) at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75) at org.codehaus.xfire.client.Client.invoke(Client.java:335) at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77) at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57) at $Proxy0.testDataHandlerOut(Unknown Source) at org.codehaus.xfire.mtom.MTOMClient.main(MTOMClient.java:49) Caused by: java.lang.NullPointerException at org.codehaus.xfire.attachments.AttachmentUtil.getAttachment(AttachmentUtil.java:33) at org.codehaus.xfire.aegis.type.mtom.AbstractXOPType.readInclude(AbstractXOPType.java:58) at org.codehaus.xfire.aegis.type.mtom.AbstractXOPType.readObject(AbstractXOPType.java:45) at org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindingProvider.java:162) at org.codehaus.xfire.service.binding.AbstractBinding.read(AbstractBinding.java:206) at org.codehaus.xfire.service.binding.WrappedBinding.readMessage(WrappedBinding.java:50) at org.codehaus.xfire.soap.handler.SoapBodyHandler.invoke(SoapBodyHandler.java:42) at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131) at org.codehaus.xfire.client.Client.onReceive(Client.java:387) ... 10 more You should run original MTOM example first to be sure you have all libraries in place. I am not able to run XFire MTOM under Oracle OC4J 10.1.2 and 10.1.3, but Weblogic 8.1 SP6 works fine. Regards, Zdenek -- View this message in context: http://www.nabble.com/How-to-download-large-file-from-service-side-to-client--tf3632140.html#a10161135 Sent from the XFire - User mailing list archive at Nabble.com. - To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
Re: [xfire-user] How to download large file from service side to client?
Hi Tomek, Hi Seego, I have tested it. It works fine. java 1.5 build 11 Tomcat 5.5 last stable XFire 1.2.5 (I copied content of xfire lib directory into Tomcat55\shared\lib\ and restarted Tomcat) Maven 2.0.6 EasyEclipse 1.2.1 I downloaded your zip file, then I created file in temp directory with some data. mvn eclipse:eclipse ( I run client from eclipse) mvn install war:war than I copied created war file into Tomcat webapp directory wsdl document http://localhost:8080/xfire-mtom/services/MTOMService?wsdl I run client application from eclipse. Everything was ok. Í have got content with this code: System.out.print(result + dh2.getContent().toString()); Which Tomcat version do you use? Which java do you use? I have tested my code with java 1.4.2 build 6 and java 5 several builds. There must be problem in your your enviroment, libs ... Regards, Zdenek On 4/24/07, Tomek Sztelak [EMAIL PROTECTED] wrote: Create jira issue and attach your sample project there. I'll try to take a look when find some free time :) On 4/24/07, seego [EMAIL PROTECTED] wrote: Zdeněk, The exception occurs on the client side. AttachementUtil.class exists. File exists, otherwise it would throw IOException of FileNoFoundException. If I use tcpmon as a proxy between my service and client, I can intercept the SOAP request and SOAP responce. It seems that service responds correcly, but the client gets confused for some reason I am 100% shure that it is not a problem of missing classes or file. I just need someone to confirm that it doesn't work, so I can move forward with my project. Thanks. Zdeněk Vráblík-3 wrote: Hi, it looks correct. Does the file exists? org.codehaus.xfire.attachments.AttachmentUtil.getAttachment(AttachmentUtil.java:33) It couses NullPointerException here. Try create File object from path then check if file exists and create FileDataSource and DataHandler. Regards, Zdenek On 4/24/07, seego [EMAIL PROTECTED] wrote: Zdeněk, I have tried this. No luck. I am using Tomcat5 to expose my service. I have included the modified xfire examples http://www.nabble.com/file/8067/mtom.zip mtom.zip . They are easy to build with maven. Can you check if it works for you, when you have time. When I execute my MTOMClient.class I get this: Result : [EMAIL PROTECTED] Result : [EMAIL PROTECTED] Result : [EMAIL PROTECTED] Exception in thread main org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89) at org.codehaus.xfire.client.Client.onReceive(Client.java:391) at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139) at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48) at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26) at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131) at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75) at org.codehaus.xfire.client.Client.invoke(Client.java:335) at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77) at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57) at $Proxy0.testDataHandlerOut(Unknown Source) at org.codehaus.xfire.mtom.MTOMClient.main(MTOMClient.java:49) Caused by: java.lang.NullPointerException at org.codehaus.xfire.attachments.AttachmentUtil.getAttachment(AttachmentUtil.java:33) at org.codehaus.xfire.aegis.type.mtom.AbstractXOPType.readInclude(AbstractXOPType.java:58) at org.codehaus.xfire.aegis.type.mtom.AbstractXOPType.readObject(AbstractXOPType.java:45) at org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindingProvider.java:162) at org.codehaus.xfire.service.binding.AbstractBinding.read(AbstractBinding.java:206) at org.codehaus.xfire.service.binding.WrappedBinding.readMessage(WrappedBinding.java:50) at org.codehaus.xfire.soap.handler.SoapBodyHandler.invoke(SoapBodyHandler.java:42) at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131) at org.codehaus.xfire.client.Client.onReceive(Client.java:387) ... 10 more You should run original MTOM example first to be sure you have all libraries in place. I am not able to run XFire MTOM under Oracle OC4J 10.1.2 and 10.1.3, but Weblogic 8.1 SP6 works fine. Regards, Zdenek -- View this message in context: