Problem with attachment retrieval MTOM (CXF 2.0.4)

2008-02-08 Thread Ronald Pieterse

I have a service with which I would like to upload and download files. The
uploading part goes great - I make the upload call like so:

UploadFileType uft = new UploadFileType();
uft.setFileName(somefilename.zip);
uft.setData(new DataHandler(new
FileDataSource(/var/tmp/somefilename.zip)));
service.uploadFile(uft);

then on the server I do:

FileOutputStream fos = new FileOutputStream(new 
File(/var/tmp/ +
file.getFileName()));
ByteArrayInputStream bis = (ByteArrayInputStream)
file.getData().getContent();

byte[] buffer = new byte[2048];
int bytesRead = bis.read(buffer);
while (bytesRead = 0) {
fos.write(buffer, 0, bytesRead);
bytesRead = bis.read(buffer);
}
...

and the file is uploaded. I though that if I just copy / paste and switch
server code to client code and vice versa the download part would work too.
It does indeed work until I try to do:

bis = (ByteArrayInputStream) file.getData().getContent();

At that line a ClassCastException is thrown for the DelegatingInputStream on
which I can find nothing. How do I handle this?

The exception that is thrown:

java.lang.ClassCastException:
org.apache.cxf.attachment.DelegatingInputStream
at
com.tripolis.api.prototype.client.PrototypeServiceTest.testFileDownload(PrototypeServiceTest.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at
org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


-- 
View this message in context: 
http://www.nabble.com/Problem-with-attachment-retrieval-MTOM-%28CXF-2.0.4%29-tp15352705p15352705.html
Sent from the cxf-user mailing list archive at Nabble.com.



Making calls in parallel to service method throws exception

2008-02-07 Thread Ronald Pieterse

I created a service method that allows file uploading (MTOM) and I want to be
able to call that method many times in parallel if possible. If I just start
my test class a couple of times really fast after each other (in eclipse) I
see that it works but I'm only able to start it about 3 times that way. What
I really want is to be able to test this in a nicer way, like in a test case
- I found a nice parallel junit jar for that.
Anyway when I try to use that (even with only 2 threads) it will only upload
the last file and for all the other calls before the server throws the
following exception:

Interceptor has thrown exception, unwinding now
org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader.
at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:191)
at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:56)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:208)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:77)
at
org.apache.cxf.transport.servlet.ServletDestination.doMessage(ServletDestination.java:79)
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:264)
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
at
org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:170)
at
org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:148)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:154)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:92)
at
com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:106)
at
com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:173)
at
com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)
at 
com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:274)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:511)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:520)
at com.caucho.util.ThreadPool.run(ThreadPool.java:442)
at java.lang.Thread.run(Unknown Source)
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
 at [row,col {unknown-source}]: [1,0]
at 
com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:661)
at 
com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2134)
at
com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2040)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1069)
at 
com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1095)
at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:85)
... 18 more

Anyone any idea what the problem might be?

I'm using CXF 2.0.4
-- 
View this message in context: 
http://www.nabble.com/Making-calls-in-parallel-to-service-method-throws-exception-tp15331030p15331030.html
Sent from the cxf-user mailing list archive at Nabble.com.



Re: Stack trace of custom exception visible on server

2008-01-16 Thread Ronald Pieterse

Unfortunately this doesn't work either. I use Log4J and tried to set the
levels for the interceptor to FATAL even, but the exception gets logged on
the server anyway.
This is very annoying. My testcases are flooded with exceptions.
Has anyone even encountered this problem? Is it a bug? How would the
formatter idea that was suggested before work anyway?


dkulp wrote:
 
 
 I don't think there is an (easy) way.
 
 With a logging.properties file, you could turn OFF the logging for the 
 org.apache.cxf.phase.PhaseInterceptorChain logger. (set level to WARNING 
 or similar)  Nothing would get logged then.
 
 The hard way would be to write a custom formatter that you would set for 
 that logger that would not log the stack trace.   That would definitely 
 suck.
 
 Dan
 
 
 
 On Wednesday 07 November 2007, Ronald Pieterse wrote:
 Anyone any ideas?

 Ronald Pieterse wrote:
  When I throw a custom exception from the server to the client the
  stack trace also appears in the server logs. How can I stop that? I
  just want to print out one line saying the exception is thrown -
  that's all.
 
 
 
 -- 
 J. Daniel Kulp
 Principal Engineer
 IONA
 P: 781-902-8727C: 508-380-7194
 [EMAIL PROTECTED]
 http://www.dankulp.com/blog
 
 

-- 
View this message in context: 
http://www.nabble.com/Stack-trace-of-custom-exception-visible-on-server-tp13464546p14877655.html
Sent from the cxf-user mailing list archive at Nabble.com.



Date object input parameter 'argument type mismatch'

2007-11-19 Thread Ronald Pieterse

I have my services running almost perfectly now, just one weird thing
happening now that used to work in a previous version; it definitely worked
in XFire.

Problem:
I have an interface and implementation for my service and use annotations to
create the wsdl file. This all works fine except in my method where I use a
Date object
as input parameter. 
First of all I noticed that the generated (Axis 1) client accepts a Calendar
object instead of a Date object. 
Then when I envoke the method a 'java.lang.IllegalArgumentException:
argument type mismatch' is thrown. What should I do to get this working?
In SoapUI it works fine! So I suspect it's in the client code?

I have been looking and trying for 2 days now and need to get it fixed asap.

I use CXF 2.0.2-incubator with Java 5

THNX
-- 
View this message in context: 
http://www.nabble.com/Date-object-input-parameter-%27argument-type-mismatch%27-tf4835686.html#a13834424
Sent from the cxf-user mailing list archive at Nabble.com.



Re: Stack trace of custom exception visible on server

2007-11-07 Thread Ronald Pieterse

Anyone any ideas?


Ronald Pieterse wrote:
 
 When I throw a custom exception from the server to the client the stack
 trace also appears in the server logs. How can I stop that?
 I just want to print out one line saying the exception is thrown - that's
 all.
 

-- 
View this message in context: 
http://www.nabble.com/Stack-trace-of-custom-exception-visible-on-server-tf4710680.html#a13637582
Sent from the cxf-user mailing list archive at Nabble.com.



Setting SOAP header in SOAP response

2007-10-26 Thread Ronald Pieterse

Hello,

I'm trying to set a header in the SOAP response of all my calls.This header
must just contain the version of my service implementation. I'm trying to do
this using an OUT interceptor (extends AbstractSoapInterceptor) which is
defined in my spring file:


bean id=soapHeaderSetter
class=my.package.SoapHeaderSetter /

cxf:bus
cxf:inInterceptors /
cxf:outInterceptors
ref bean=soapHeaderSetter /
/cxf:outInterceptors
cxf:inFaultInterceptors /
/cxf:bus


The interceptor kicks in alright when I go back to the client but it's
unclear which Phase I need to be in to add the header and also how to set
the header. Do I just get the headers (btw there are no response headers
available - is that correct?) and then add one to the list like this:


soapMsg.getHeaders().add(new Header(new
QName(http://some.namespace;), api.version=1.7));


I suspect that the way I set this header is not entirely correct :-) I could
use some help here. THNX

-- 
View this message in context: 
http://www.nabble.com/Setting-SOAP-header-in-SOAP-response-tf4697009.html#a13426234
Sent from the cxf-user mailing list archive at Nabble.com.



Re: Setting SOAP header in SOAP response

2007-10-26 Thread Ronald Pieterse

Right, The header I'm setting is not appearing when I check the response in
e.g. SoapUI. The only requirement I have is that I would like to see the
header in my response one way or the other :-)
I also have a System.out.println in my interceptor so I know it kicks in and
no exceptions are thrown so I wonder where the header went...
The response looks like this:

soap:Envelope xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/;
   soap:Body
  ns1:getDatabaseFieldsResponse xmlns:ns1=http://some.namespace/;
 databaseFields
  ...
 /databaseFields
  /ns1:getDatabaseFieldsResponse
   /soap:Body
/soap:Envelope


As you can see there's no headers available at all. Any ideas?


Ulhas Bhole wrote:
 
 Hi Roland,
 
 It's upto your requirement at which phase it should be added. I don't 
 see any problem in the way you are setting header. Do you mean to say 
 that interceptor kicks in but you don't see soap header other side?
 
 Regards,
 
 Ulhas Bhole
 
 Ronald Pieterse wrote:
 Hello,

 I'm trying to set a header in the SOAP response of all my calls.This
 header
 must just contain the version of my service implementation. I'm trying to
 do
 this using an OUT interceptor (extends AbstractSoapInterceptor) which is
 defined in my spring file:


 bean id=soapHeaderSetter
  class=my.package.SoapHeaderSetter /

  cxf:bus
  cxf:inInterceptors /
  cxf:outInterceptors
  ref bean=soapHeaderSetter /
  /cxf:outInterceptors
  cxf:inFaultInterceptors /
  /cxf:bus


 The interceptor kicks in alright when I go back to the client but it's
 unclear which Phase I need to be in to add the header and also how to set
 the header. Do I just get the headers (btw there are no response headers
 available - is that correct?) and then add one to the list like this:


 soapMsg.getHeaders().add(new Header(new
 QName(http://some.namespace;), api.version=1.7));


 I suspect that the way I set this header is not entirely correct :-) I
 could
 use some help here. THNX

   
 
 
 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/Setting-SOAP-header-in-SOAP-response-tf4697009.html#a13427417
Sent from the cxf-user mailing list archive at Nabble.com.



Re: Setting SOAP header in SOAP response

2007-10-26 Thread Ronald Pieterse

Excellent! That was it. Strange that the api says that you need to put in an
Object instead of an Element... Anyway it works like fine now. I implemented
it like so:

DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.newDocument();
Element version = doc.createElement(api-version);
version.setTextContent(2.0);

and the response is now:

soap:Envelope xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/;
   soap:Header
  api-version2.0/api-version
   /soap:Header
   soap:Body
 ...
   /soap:Body
/soap:Envelope

Thnx a lot. Good start of the weekend for me :-)


Ulhas Bhole wrote:
 
 Hi Ronald,
 
 I take back my statement from first mail that the header you are setting 
 is ok. I had a quick look through the code.
 
 Header expects the data binding that can marshal the header object you 
 set or if no databinding specified then the DOM element.
 So, instead of adding simple string create a DOM element and add the DOM 
 element to the header and you should see the exception disappearing.
 
 Regards,
 
 Ulhas Bhole
 
 Ronald Pieterse wrote:
 Ok, at least it seems to respond now but I get a ClassCast exception on
 the
 Object I try to put in the header. I try to do something like this:

 soapMsg.getHeaders().add(new Header(new QName(http://api.tripolis.com;),
 version=2.0));

 for (Header header : soapMsg.getHeaders()) {
  System.out.println(header:  + header.getName());
 }

 After setting the header I read it out of the message and it looks
 alright
 but further on the exception is thrown like this:

 [16:04:59.764] Interceptor has thrown exception, unwinding now
 [16:04:59.764] java.lang.ClassCastException: java.lang.String
 [16:04:59.764]   at
 org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:120)
 ...

 I'm almost there - I can feel it...


 Ulhas Bhole wrote:
   
 Are you checking for the DOM elements? Don't expect to see it in string 
 format.

 you need to get the handle onto the Header list and go through the list 
 to check the DOM elements and you would find it there.

 Sorry, didn;t read the complete message it looks like your interceptor 
 kicks in after the header processing is done. If you have no dependency 
 on any interceptors to be finished you can add it before Phase.WRITE.

 you can add following lines to your interceptor's constructor and it 
 should make sure that the interceptor gets called before the header 
 processing happens.

 super(Phase.WRITE);
 addBefore(SoapOutInterceptor.class.getName());


 Regards,

 Ulhas

 Ronald Pieterse wrote:
 
 Right, The header I'm setting is not appearing when I check the
 response
 in
 e.g. SoapUI. The only requirement I have is that I would like to see
 the
 header in my response one way or the other :-)
 I also have a System.out.println in my interceptor so I know it kicks
 in
 and
 no exceptions are thrown so I wonder where the header went...
 The response looks like this:

 soap:Envelope xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/;
soap:Body
   ns1:getDatabaseFieldsResponse
 xmlns:ns1=http://some.namespace/;
  databaseFields
   ...
  /databaseFields
   /ns1:getDatabaseFieldsResponse
/soap:Body
 /soap:Envelope


 As you can see there's no headers available at all. Any ideas?


 Ulhas Bhole wrote:
   
   
 Hi Roland,

 It's upto your requirement at which phase it should be added. I don't 
 see any problem in the way you are setting header. Do you mean to say 
 that interceptor kicks in but you don't see soap header other side?

 Regards,

 Ulhas Bhole

 Ronald Pieterse wrote:
 
 
 Hello,

 I'm trying to set a header in the SOAP response of all my calls.This
 header
 must just contain the version of my service implementation. I'm
 trying
 to
 do
 this using an OUT interceptor (extends AbstractSoapInterceptor) which
 is
 defined in my spring file:


 bean id=soapHeaderSetter
  class=my.package.SoapHeaderSetter /

  cxf:bus
  cxf:inInterceptors /
  cxf:outInterceptors
  ref bean=soapHeaderSetter /
  /cxf:outInterceptors
  cxf:inFaultInterceptors /
  /cxf:bus


 The interceptor kicks in alright when I go back to the client but
 it's
 unclear which Phase I need to be in to add the header and also how to
 set
 the header. Do I just get the headers (btw there are no response
 headers
 available - is that correct?) and then add one to the list like this:


 soapMsg.getHeaders().add(new Header(new
 QName(http://some.namespace;), api.version=1.7));


 I suspect that the way I set this header is not entirely correct :-)
 I
 could
 use some help here. THNX

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