You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Brad <br...@javawork.co.uk> on 2008/08/01 00:45:38 UTC

Re: CXF and fileupload

There you go, plenty of options. I'd recommend you go with Sergey's
suggestions as he wrote the JAX-RS implementation for CXF and actually
knows what he's talking about :-)

On Thu, Jul 31, 2008 at 10:52 PM, Sergey Beryozkin
<se...@iona.com> wrote:
> This is probably even simpler, thanks, You can use an InputStream in the
> signature - if you don't want to deal with HttpServletRequests
>
> -----Original Message-----
> From: bradmoody@gmail.com [mailto:bradmoody@gmail.com] On Behalf Of
> brad@javawork.co.uk
> Sent: 31 July 2008 19:01
> To: users@cxf.apache.org
> Subject: Re: CXF and fileupload
>
> No Worries :-)
>
> If you get FileUpload from apache commons then you can use its
> multipart request class to parse the http request on the server side.
>
> If I remember correctly, to get the HttpServletRequest object in your
> service method include this method parameter:
>
> @Context HttpServletRequest req
>
> You can then parse the req object with the FileUpload multipart request
> object and get access to your files.
>
> Hope that helps.
>
> On 7/31/08, deniak <de...@gmail.com> wrote:
>>
>> Ok, let's say I set the requestentity with a MultipartRequestEntity.
>>
>>   File zip = new File("/path/fileToUpload.zip");
>>   File xml = new File("/path/fileToUpload.xml");
>>   PostMethod filePost = new PostMethod("http://host/some_path");
>>   Part[] parts = {
>>       new FilePart(xml.getName(), xml)
>>       new FilePart(zip.getName(), zip)
>>   };
>>   filePost.setRequestEntity(
>>       new MultipartRequestEntity(parts, filePost.getParams())
>>       );
>>
>>
>> How can I deal with this MultipartRequestEntity on the server side with
> CXF?
>> I know I may ask some stupid questions but it really drives me crazy :s
>>
>> Thanks for your help
>>
>>
>>
>>
>> Brad-77 wrote:
>>>
>>> Sounds like http request with an attached file to me, which I believe
>>> requires a multipart request.
>>>
>>> See 3.7.2 in http://www.ietf.org/rfc/rfc2616.txt
>>>
>>> On Thu, Jul 31, 2008 at 2:26 PM, deniak <de...@gmail.com> wrote:
>>>>
>>>> Actually, I just want to send a xml file and a zip file with my client
>>>> and then handle these 2 files on my server using CXF.
>>>>
>>>> It's easy with just a XML file like described in the CXF samples but
>>>> there's
>>>> nothing about
>>>> uploading a file
>>>>
>>>>
>>>>
>>>>
>>>> Brad-77 wrote:
>>>>>
>>>>> So if I'm reading this correctly you just want to read the data out of
>>>>> a file and send it as the body in a PUT request?
>>>>>
>>>>> Or is there more to it than that?
>>>>>
>>>>> On Thu, Jul 31, 2008 at 1:56 PM, deniak <de...@gmail.com>
> wrote:
>>>>>>
>>>>>> I forgot to mention I need to use rest web services
>>>>>>
>>>>>>
>>>>>> Benson Margulies-4 wrote:
>>>>>>>
>>>>>>> Well, CXF supports MTOM and SwA.
>>>>>>>
>>>>>>> On Thu, Jul 31, 2008 at 8:34 AM, deniak <de...@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> Actually, i need to use a put method and I was wondering how cxf can
>>>>>>>> handle
>>>>>>>> it
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Brad-77 wrote:
>>>>>>>> >
>>>>>>>> > Hi,
>>>>>>>> >
>>>>>>>> > if you mean using HTML form POSTs then yes, its pretty easy with
>>>>>>>> > commons FileUpload: http://commons.apache.org/fileupload/
>>>>>>>> >
>>>>>>>> > You need to get access the the HTTP request object which you can
>>>>>>>> pass
>>>>>>>> > to the mime multipart request class in FileUploads. From there you
>>>>>>>> can
>>>>>>>> > iterate through the request parts, one of which will be your file.
>>>>>>>> >
>>>>>>>> > Hope that helps.
>>>>>>>> >
>>>>>>>> > Brad.
>>>>>>>> >
>>>>>>>> > On Thu, Jul 31, 2008 at 1:06 PM, deniak <de...@gmail.com>
>>>>>>>> wrote:
>>>>>>>> >>
>>>>>>>> >> Hi,
>>>>>>>> >>
>>>>>>>> >> Has anyone ever dealt with fileupload using cxf?
>>>>>>>> >> I mean send a file to the server and get it with cxf?
>>>>>>>> >> --
>>>>>>>> >> View this message in context:
>>>>>>>> >> http://www.nabble.com/CXF-and-fileupload-tp18753132p18753132.html
>>>>>>>> >> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>>> >>
>>>>>>>> >>
>>>>>>>> >
>>>>>>>> >
>>>>>>>>
>>>>>>>> --
>>>>>>>> View this message in context:
>>>>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18753583.html
>>>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18753963.html
>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18754544.html
>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18758727.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
>>
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>

Re: CXF and fileupload

Posted by Sergey Beryozkin <se...@iona.com>.
So now everyone will know who to blame for all those implementation bugs :-) Lets just say that I just contributed to it during the 
last few months - Jervis Liu was there at the start. And seems like your option is very simple, no need to do custom message readers

Cheers, Sergey

> There you go, plenty of options. I'd recommend you go with Sergey's
> suggestions as he wrote the JAX-RS implementation for CXF and actually
> knows what he's talking about :-)
>

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: CXF and fileupload

Posted by deniak <de...@gmail.com>.
As I have a putmethod in my client, I'm not sure if I can use FileUpload on
the server side.
I tried that code but "ServletFileUpload.isMultipartContent(request)"
returns me false...





Arul Dhesiaseelan wrote:
> 
> Some code to start with FileUpload...
> 
> DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
> File repositoryPath = new File("/temp");
> diskFileItemFactory.setRepository(repositoryPath);
> 
> ServletFileUpload servletFileUpload = new 
> ServletFileUpload(diskFileItemFactory);
> 
> if (ServletFileUpload.isMultipartContent(request)){//injected sevlet 
> request goes here
>   // Parse the HTTP request...
>   List<FileItem> fileItemsList = 
> servletFileUpload.parseRequest(request);//injected sevlet request goes
> here
>   //do whatever you need to do with a file here (FileItems)
> }
> 
> HTH.
> 
> -Arul
> 
> deniak wrote:
>> All right, thanks for your ideas. It's really helpful.
>> I tried the simplest solution just to know if it works...
>> My client is still the same.
>>
>> I tried to add this code on the server side:
>> private @Resource HttpServletRequest requestObject;
>>
>> but I don't know how I can get my 2 files with the HttpServletRequest...
>> Did I miss something??
>>
>>
>>
>>
>> Brad-77 wrote:
>>   
>>> There you go, plenty of options. I'd recommend you go with Sergey's
>>> suggestions as he wrote the JAX-RS implementation for CXF and actually
>>> knows what he's talking about :-)
>>>
>>> On Thu, Jul 31, 2008 at 10:52 PM, Sergey Beryozkin
>>> <se...@iona.com> wrote:
>>>     
>>>> This is probably even simpler, thanks, You can use an InputStream in
>>>> the
>>>> signature - if you don't want to deal with HttpServletRequests
>>>>
>>>> -----Original Message-----
>>>> From: bradmoody@gmail.com [mailto:bradmoody@gmail.com] On Behalf Of
>>>> brad@javawork.co.uk
>>>> Sent: 31 July 2008 19:01
>>>> To: users@cxf.apache.org
>>>> Subject: Re: CXF and fileupload
>>>>
>>>> No Worries :-)
>>>>
>>>> If you get FileUpload from apache commons then you can use its
>>>> multipart request class to parse the http request on the server side.
>>>>
>>>> If I remember correctly, to get the HttpServletRequest object in your
>>>> service method include this method parameter:
>>>>
>>>> @Context HttpServletRequest req
>>>>
>>>> You can then parse the req object with the FileUpload multipart request
>>>> object and get access to your files.
>>>>
>>>> Hope that helps.
>>>>
>>>> On 7/31/08, deniak <de...@gmail.com> wrote:
>>>>       
>>>>> Ok, let's say I set the requestentity with a MultipartRequestEntity.
>>>>>
>>>>>   File zip = new File("/path/fileToUpload.zip");
>>>>>   File xml = new File("/path/fileToUpload.xml");
>>>>>   PostMethod filePost = new PostMethod("http://host/some_path");
>>>>>   Part[] parts = {
>>>>>       new FilePart(xml.getName(), xml)
>>>>>       new FilePart(zip.getName(), zip)
>>>>>   };
>>>>>   filePost.setRequestEntity(
>>>>>       new MultipartRequestEntity(parts, filePost.getParams())
>>>>>       );
>>>>>
>>>>>
>>>>> How can I deal with this MultipartRequestEntity on the server side
>>>>> with
>>>>>         
>>>> CXF?
>>>>       
>>>>> I know I may ask some stupid questions but it really drives me crazy
>>>>> :s
>>>>>
>>>>> Thanks for your help
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Brad-77 wrote:
>>>>>         
>>>>>> Sounds like http request with an attached file to me, which I believe
>>>>>> requires a multipart request.
>>>>>>
>>>>>> See 3.7.2 in http://www.ietf.org/rfc/rfc2616.txt
>>>>>>
>>>>>> On Thu, Jul 31, 2008 at 2:26 PM, deniak <de...@gmail.com>
>>>>>> wrote:
>>>>>>           
>>>>>>> Actually, I just want to send a xml file and a zip file with my
>>>>>>> client
>>>>>>> and then handle these 2 files on my server using CXF.
>>>>>>>
>>>>>>> It's easy with just a XML file like described in the CXF samples but
>>>>>>> there's
>>>>>>> nothing about
>>>>>>> uploading a file
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Brad-77 wrote:
>>>>>>>             
>>>>>>>> So if I'm reading this correctly you just want to read the data out
>>>>>>>> of
>>>>>>>> a file and send it as the body in a PUT request?
>>>>>>>>
>>>>>>>> Or is there more to it than that?
>>>>>>>>
>>>>>>>> On Thu, Jul 31, 2008 at 1:56 PM, deniak <de...@gmail.com>
>>>>>>>>               
>>>> wrote:
>>>>       
>>>>>>>>> I forgot to mention I need to use rest web services
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Benson Margulies-4 wrote:
>>>>>>>>>                 
>>>>>>>>>> Well, CXF supports MTOM and SwA.
>>>>>>>>>>
>>>>>>>>>> On Thu, Jul 31, 2008 at 8:34 AM, deniak <de...@gmail.com>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>                   
>>>>>>>>>>> Actually, i need to use a put method and I was wondering how cxf
>>>>>>>>>>> can
>>>>>>>>>>> handle
>>>>>>>>>>> it
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Brad-77 wrote:
>>>>>>>>>>>                     
>>>>>>>>>>>> Hi,
>>>>>>>>>>>>
>>>>>>>>>>>> if you mean using HTML form POSTs then yes, its pretty easy
>>>>>>>>>>>> with
>>>>>>>>>>>> commons FileUpload: http://commons.apache.org/fileupload/
>>>>>>>>>>>>
>>>>>>>>>>>> You need to get access the the HTTP request object which you
>>>>>>>>>>>> can
>>>>>>>>>>>>                       
>>>>>>>>>>> pass
>>>>>>>>>>>                     
>>>>>>>>>>>> to the mime multipart request class in FileUploads. From there
>>>>>>>>>>>>                       
>>>>>>>>>>> you
>>>>>>>>>>> can
>>>>>>>>>>>                     
>>>>>>>>>>>> iterate through the request parts, one of which will be your
>>>>>>>>>>>>                       
>>>>>>>>>>> file.
>>>>>>>>>>>                     
>>>>>>>>>>>> Hope that helps.
>>>>>>>>>>>>
>>>>>>>>>>>> Brad.
>>>>>>>>>>>>
>>>>>>>>>>>> On Thu, Jul 31, 2008 at 1:06 PM, deniak
>>>>>>>>>>>>                       
>>>>>>>>>>> <de...@gmail.com>
>>>>>>>>>>> wrote:
>>>>>>>>>>>                     
>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>
>>>>>>>>>>>>> Has anyone ever dealt with fileupload using cxf?
>>>>>>>>>>>>> I mean send a file to the server and get it with cxf?
>>>>>>>>>>>>> --
>>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>>
>>>>>>>>>>>>>                         
>>>>>>>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18753132.html
>>>>>>>>>>>                     
>>>>>>>>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                         
>>>>>>>>>>>>                       
>>>>>>>>>>> --
>>>>>>>>>>> View this message in context:
>>>>>>>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18753583.html
>>>>>>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                     
>>>>>>>>>>                   
>>>>>>>>> --
>>>>>>>>> View this message in context:
>>>>>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18753963.html
>>>>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                 
>>>>>>>>               
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18754544.html
>>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>>             
>>>>>>           
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18758727.html
>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>>         
>>>> ----------------------------
>>>> IONA Technologies PLC (registered in Ireland)
>>>> Registered Number: 171387
>>>> Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
>>>> Ireland
>>>>
>>>>       
>>>     
>>
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/CXF-and-fileupload-tp18753132p18779019.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF and fileupload

Posted by Arul Dhesiaseelan <ar...@fluxcorp.com>.
Some code to start with FileUpload...

DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
File repositoryPath = new File("/temp");
diskFileItemFactory.setRepository(repositoryPath);

ServletFileUpload servletFileUpload = new 
ServletFileUpload(diskFileItemFactory);

if (ServletFileUpload.isMultipartContent(request)){//injected sevlet 
request goes here
  // Parse the HTTP request...
  List<FileItem> fileItemsList = 
servletFileUpload.parseRequest(request);//injected sevlet request goes here
  //do whatever you need to do with a file here (FileItems)
}

HTH.

-Arul

deniak wrote:
> All right, thanks for your ideas. It's really helpful.
> I tried the simplest solution just to know if it works...
> My client is still the same.
>
> I tried to add this code on the server side:
> private @Resource HttpServletRequest requestObject;
>
> but I don't know how I can get my 2 files with the HttpServletRequest...
> Did I miss something??
>
>
>
>
> Brad-77 wrote:
>   
>> There you go, plenty of options. I'd recommend you go with Sergey's
>> suggestions as he wrote the JAX-RS implementation for CXF and actually
>> knows what he's talking about :-)
>>
>> On Thu, Jul 31, 2008 at 10:52 PM, Sergey Beryozkin
>> <se...@iona.com> wrote:
>>     
>>> This is probably even simpler, thanks, You can use an InputStream in the
>>> signature - if you don't want to deal with HttpServletRequests
>>>
>>> -----Original Message-----
>>> From: bradmoody@gmail.com [mailto:bradmoody@gmail.com] On Behalf Of
>>> brad@javawork.co.uk
>>> Sent: 31 July 2008 19:01
>>> To: users@cxf.apache.org
>>> Subject: Re: CXF and fileupload
>>>
>>> No Worries :-)
>>>
>>> If you get FileUpload from apache commons then you can use its
>>> multipart request class to parse the http request on the server side.
>>>
>>> If I remember correctly, to get the HttpServletRequest object in your
>>> service method include this method parameter:
>>>
>>> @Context HttpServletRequest req
>>>
>>> You can then parse the req object with the FileUpload multipart request
>>> object and get access to your files.
>>>
>>> Hope that helps.
>>>
>>> On 7/31/08, deniak <de...@gmail.com> wrote:
>>>       
>>>> Ok, let's say I set the requestentity with a MultipartRequestEntity.
>>>>
>>>>   File zip = new File("/path/fileToUpload.zip");
>>>>   File xml = new File("/path/fileToUpload.xml");
>>>>   PostMethod filePost = new PostMethod("http://host/some_path");
>>>>   Part[] parts = {
>>>>       new FilePart(xml.getName(), xml)
>>>>       new FilePart(zip.getName(), zip)
>>>>   };
>>>>   filePost.setRequestEntity(
>>>>       new MultipartRequestEntity(parts, filePost.getParams())
>>>>       );
>>>>
>>>>
>>>> How can I deal with this MultipartRequestEntity on the server side with
>>>>         
>>> CXF?
>>>       
>>>> I know I may ask some stupid questions but it really drives me crazy :s
>>>>
>>>> Thanks for your help
>>>>
>>>>
>>>>
>>>>
>>>> Brad-77 wrote:
>>>>         
>>>>> Sounds like http request with an attached file to me, which I believe
>>>>> requires a multipart request.
>>>>>
>>>>> See 3.7.2 in http://www.ietf.org/rfc/rfc2616.txt
>>>>>
>>>>> On Thu, Jul 31, 2008 at 2:26 PM, deniak <de...@gmail.com>
>>>>> wrote:
>>>>>           
>>>>>> Actually, I just want to send a xml file and a zip file with my client
>>>>>> and then handle these 2 files on my server using CXF.
>>>>>>
>>>>>> It's easy with just a XML file like described in the CXF samples but
>>>>>> there's
>>>>>> nothing about
>>>>>> uploading a file
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Brad-77 wrote:
>>>>>>             
>>>>>>> So if I'm reading this correctly you just want to read the data out
>>>>>>> of
>>>>>>> a file and send it as the body in a PUT request?
>>>>>>>
>>>>>>> Or is there more to it than that?
>>>>>>>
>>>>>>> On Thu, Jul 31, 2008 at 1:56 PM, deniak <de...@gmail.com>
>>>>>>>               
>>> wrote:
>>>       
>>>>>>>> I forgot to mention I need to use rest web services
>>>>>>>>
>>>>>>>>
>>>>>>>> Benson Margulies-4 wrote:
>>>>>>>>                 
>>>>>>>>> Well, CXF supports MTOM and SwA.
>>>>>>>>>
>>>>>>>>> On Thu, Jul 31, 2008 at 8:34 AM, deniak <de...@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> Actually, i need to use a put method and I was wondering how cxf
>>>>>>>>>> can
>>>>>>>>>> handle
>>>>>>>>>> it
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Brad-77 wrote:
>>>>>>>>>>                     
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>> if you mean using HTML form POSTs then yes, its pretty easy with
>>>>>>>>>>> commons FileUpload: http://commons.apache.org/fileupload/
>>>>>>>>>>>
>>>>>>>>>>> You need to get access the the HTTP request object which you can
>>>>>>>>>>>                       
>>>>>>>>>> pass
>>>>>>>>>>                     
>>>>>>>>>>> to the mime multipart request class in FileUploads. From there
>>>>>>>>>>>                       
>>>>>>>>>> you
>>>>>>>>>> can
>>>>>>>>>>                     
>>>>>>>>>>> iterate through the request parts, one of which will be your
>>>>>>>>>>>                       
>>>>>>>>>> file.
>>>>>>>>>>                     
>>>>>>>>>>> Hope that helps.
>>>>>>>>>>>
>>>>>>>>>>> Brad.
>>>>>>>>>>>
>>>>>>>>>>> On Thu, Jul 31, 2008 at 1:06 PM, deniak
>>>>>>>>>>>                       
>>>>>>>>>> <de...@gmail.com>
>>>>>>>>>> wrote:
>>>>>>>>>>                     
>>>>>>>>>>>> Hi,
>>>>>>>>>>>>
>>>>>>>>>>>> Has anyone ever dealt with fileupload using cxf?
>>>>>>>>>>>> I mean send a file to the server and get it with cxf?
>>>>>>>>>>>> --
>>>>>>>>>>>> View this message in context:
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18753132.html
>>>>>>>>>>                     
>>>>>>>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>                       
>>>>>>>>>> --
>>>>>>>>>> View this message in context:
>>>>>>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18753583.html
>>>>>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>                   
>>>>>>>> --
>>>>>>>> View this message in context:
>>>>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18753963.html
>>>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>               
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18754544.html
>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>>             
>>>>>           
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18758727.html
>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>
>>>>
>>>>         
>>> ----------------------------
>>> IONA Technologies PLC (registered in Ireland)
>>> Registered Number: 171387
>>> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>>>
>>>       
>>     
>
>   


Unable to locate NamespaceHandler

Posted by Steve Carton <st...@retrievalsystems.com>.
I've been trying to solve this problem:

BeanDefinitionParsingException: Configuration problem: Unable to locate
NamespaceHandler for namespace [http://cxf.apache.org/jaxws]

I've read some suggestions in the forum, and I added the
cxf-rt-frontend-jaxws-2.1.1.jar to the WEB-INF/lib folder. 

I've successfully deployed my application under tomcat on two machines
(WinXP and Linux, both running Java 1.6 and both running Tomcat 6). The
application starts successfully (and did before I added the
cxf-rt-frontend-jaxws-2.1.1.jar to the WEB-INF/lib folder) and I can
access the exposed web services. 

But on two other machines, (one WinXP and one linux, both running Java
1.6 and Tomcat 6), I get this above exception. Can anyone shed some
light on the nature of the problem and what I can do to fix it? I don't
even know what it means.

Thanks,

Steve Carton


()2008-07-31 16:10:55,734 ERROR
[org.springframework.web.context.ContextLoader] - Context initialization
failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException
: Configuration problem: Unable to locate NamespaceHandler for namespace
[http://cxf.apache.org/jaxws]
Offending resource: ServletContext resource [/WEB-INF/application.xml]
	at
org.springframework.beans.factory.parsing.FailFastProblemReporter.error(
FailFastProblemReporter.java:57)
	at
org.springframework.beans.factory.parsing.ReaderContext.error(ReaderCont
ext.java:64)
	at
org.springframework.beans.factory.parsing.ReaderContext.error(ReaderCont
ext.java:55)
...

Re: CXF and fileupload

Posted by deniak <de...@gmail.com>.
All right, thanks for your ideas. It's really helpful.
I tried the simplest solution just to know if it works...
My client is still the same.

I tried to add this code on the server side:
private @Resource HttpServletRequest requestObject;

but I don't know how I can get my 2 files with the HttpServletRequest...
Did I miss something??




Brad-77 wrote:
> 
> There you go, plenty of options. I'd recommend you go with Sergey's
> suggestions as he wrote the JAX-RS implementation for CXF and actually
> knows what he's talking about :-)
> 
> On Thu, Jul 31, 2008 at 10:52 PM, Sergey Beryozkin
> <se...@iona.com> wrote:
>> This is probably even simpler, thanks, You can use an InputStream in the
>> signature - if you don't want to deal with HttpServletRequests
>>
>> -----Original Message-----
>> From: bradmoody@gmail.com [mailto:bradmoody@gmail.com] On Behalf Of
>> brad@javawork.co.uk
>> Sent: 31 July 2008 19:01
>> To: users@cxf.apache.org
>> Subject: Re: CXF and fileupload
>>
>> No Worries :-)
>>
>> If you get FileUpload from apache commons then you can use its
>> multipart request class to parse the http request on the server side.
>>
>> If I remember correctly, to get the HttpServletRequest object in your
>> service method include this method parameter:
>>
>> @Context HttpServletRequest req
>>
>> You can then parse the req object with the FileUpload multipart request
>> object and get access to your files.
>>
>> Hope that helps.
>>
>> On 7/31/08, deniak <de...@gmail.com> wrote:
>>>
>>> Ok, let's say I set the requestentity with a MultipartRequestEntity.
>>>
>>>   File zip = new File("/path/fileToUpload.zip");
>>>   File xml = new File("/path/fileToUpload.xml");
>>>   PostMethod filePost = new PostMethod("http://host/some_path");
>>>   Part[] parts = {
>>>       new FilePart(xml.getName(), xml)
>>>       new FilePart(zip.getName(), zip)
>>>   };
>>>   filePost.setRequestEntity(
>>>       new MultipartRequestEntity(parts, filePost.getParams())
>>>       );
>>>
>>>
>>> How can I deal with this MultipartRequestEntity on the server side with
>> CXF?
>>> I know I may ask some stupid questions but it really drives me crazy :s
>>>
>>> Thanks for your help
>>>
>>>
>>>
>>>
>>> Brad-77 wrote:
>>>>
>>>> Sounds like http request with an attached file to me, which I believe
>>>> requires a multipart request.
>>>>
>>>> See 3.7.2 in http://www.ietf.org/rfc/rfc2616.txt
>>>>
>>>> On Thu, Jul 31, 2008 at 2:26 PM, deniak <de...@gmail.com>
>>>> wrote:
>>>>>
>>>>> Actually, I just want to send a xml file and a zip file with my client
>>>>> and then handle these 2 files on my server using CXF.
>>>>>
>>>>> It's easy with just a XML file like described in the CXF samples but
>>>>> there's
>>>>> nothing about
>>>>> uploading a file
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Brad-77 wrote:
>>>>>>
>>>>>> So if I'm reading this correctly you just want to read the data out
>>>>>> of
>>>>>> a file and send it as the body in a PUT request?
>>>>>>
>>>>>> Or is there more to it than that?
>>>>>>
>>>>>> On Thu, Jul 31, 2008 at 1:56 PM, deniak <de...@gmail.com>
>> wrote:
>>>>>>>
>>>>>>> I forgot to mention I need to use rest web services
>>>>>>>
>>>>>>>
>>>>>>> Benson Margulies-4 wrote:
>>>>>>>>
>>>>>>>> Well, CXF supports MTOM and SwA.
>>>>>>>>
>>>>>>>> On Thu, Jul 31, 2008 at 8:34 AM, deniak <de...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Actually, i need to use a put method and I was wondering how cxf
>>>>>>>>> can
>>>>>>>>> handle
>>>>>>>>> it
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Brad-77 wrote:
>>>>>>>>> >
>>>>>>>>> > Hi,
>>>>>>>>> >
>>>>>>>>> > if you mean using HTML form POSTs then yes, its pretty easy with
>>>>>>>>> > commons FileUpload: http://commons.apache.org/fileupload/
>>>>>>>>> >
>>>>>>>>> > You need to get access the the HTTP request object which you can
>>>>>>>>> pass
>>>>>>>>> > to the mime multipart request class in FileUploads. From there
>>>>>>>>> you
>>>>>>>>> can
>>>>>>>>> > iterate through the request parts, one of which will be your
>>>>>>>>> file.
>>>>>>>>> >
>>>>>>>>> > Hope that helps.
>>>>>>>>> >
>>>>>>>>> > Brad.
>>>>>>>>> >
>>>>>>>>> > On Thu, Jul 31, 2008 at 1:06 PM, deniak
>>>>>>>>> <de...@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>> >>
>>>>>>>>> >> Hi,
>>>>>>>>> >>
>>>>>>>>> >> Has anyone ever dealt with fileupload using cxf?
>>>>>>>>> >> I mean send a file to the server and get it with cxf?
>>>>>>>>> >> --
>>>>>>>>> >> View this message in context:
>>>>>>>>> >>
>>>>>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18753132.html
>>>>>>>>> >> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>>>> >>
>>>>>>>>> >>
>>>>>>>>> >
>>>>>>>>> >
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> View this message in context:
>>>>>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18753583.html
>>>>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18753963.html
>>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18754544.html
>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/CXF-and-fileupload-tp18753132p18758727.html
>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>
>>>
>>
>> ----------------------------
>> IONA Technologies PLC (registered in Ireland)
>> Registered Number: 171387
>> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/CXF-and-fileupload-tp18753132p18773581.html
Sent from the cxf-user mailing list archive at Nabble.com.