Re: service caching
Looks like 2.0.5 is going to release soon, is this service caching in 2.0.5? On Wed, Mar 5, 2008 at 11:50 AM, Christopher Cheng [EMAIL PROTECTED] wrote: Looking forward to have this in the next release 2.0.5 or 2.1 :) On Tue, Mar 4, 2008 at 11:55 PM, Daniel Kulp [EMAIL PROTECTED] wrote: Willem, The issue is that they CAN be modified after that. One popular modification is to grab the EndpointInfo out of it and change the address. Other things like adding interceptors to the BindingInfo, changing properties on the service (like to enable schema validation), etc... are all modifications that affect the servicemodel. Databinding is less of an issue, but still one. For example, the databinding has an mtomThreshold and a namespaceMap that can be set programatically. In both of those cases, a modification should only affect the proxy on which the modification is made. Thus, the servicemodel would need a full clone, which may not be easy to do. It's certainly a lot more code to add. That said, I don't think it's a bad idea at all. On the contrary, it's a good idea. It's just a bit of work. Dan On Tuesday 04 March 2008, Willem Jiang wrote: Hi Dan, I think we could cache the ServiceInfo object and DataBinding object which will take lots of time to be created and can't be modified after that. Any thought? Willem Daniel Kulp wrote: On Tuesday 04 March 2008, Christopher Cheng wrote: I haven't read the codes of Axis, but I have been using it for 2 years and it doesn't have this problem. Having an overhead for 5-8 seconds is not an option for a production system in term of performance What you are saying is that all the services must implement Clonable interface? No, not the services themselves. Just our interal service model stuff that holds all the metadata. Basically, when creating a new service, we need to calculate the metadata. We should cache that if possible. Dan On Tue, Mar 4, 2008 at 4:48 AM, Daniel Kulp [EMAIL PROTECTED] wrote: Christopher, We cannot just reuse the Service model objects as they are completely modifiable at runtime. For example, one proxy could be reconfigured with new address or have additional interceptors added or similar. Those shouldn't affect others. On option that propably would make sense is to add a fast clone functionality to the entire service model so we could cache one, and then clone it whenever one is really needed. All the individual versions could be modified and not affect the original. However, doing that would be quite a bit of work as there are a LOT of classes that would need to be updated to support that. Patches towards that end would be great. :-) Dan On Monday 03 March 2008, Christopher Cheng wrote: wsdl is indeed cached in WSDLManagerImpl.definitionsMap After reading the codes, I have some questions. My workstation is a PentiumD 3GHz with 1.5GB RAM In the class org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buil d Serv iceFromWSDL(String url), setService(factory.create()); takes 3 seconds getDataBinding().initialize(getService()); takes 2 seconds These 2 methods are called even in 2nd calls. Can you also cache the services perhaps using jakarta commons-pool? or eh-cache? By the way, I found that the wsdl is put into the definitionMap twice if WSDLManagerImpl.getDefinition(URL url) is called. First in getDefintion(URL url) at line 147 and second in loadDefinition(String url) at line 201. On Mon, Mar 3, 2008 at 4:22 PM, Christopher Cheng [EMAIL PROTECTED] wrote: wsdl is indeed cached in WSDLManagerImpl.definitionsMap After reading the codes, I have some questions. My workstation is a PentiumD 3GHz with 1.5GB RAM In the class org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buil dSer viceFromWSDL(String url), setService(factory.create()); takes 3 seconds getDataBinding().initialize(getService()); takes 2 seconds These 2 methods are called even in 2nd calls. Can you also cache the services perhaps using jakarta commons-pool? or eh-cache? By the way, I found that the wsdl is put into the definitionMap twice if WSDLManagerImpl.getDefinition(URL url) is called. First in getDefintion(URL url) at line 147 and second in loadDefinition(String url) at line 201. On Mon, Mar 3, 2008 at 9:43 AM, Willem Jiang [EMAIL PROTECTED] wrote: Hi, I just went through the code, we really cache the WSDL definition in CXF. Could you send your test case and wsdl file to me ? I may need to trace it for more information. Regards, Willem Christopher Cheng wrote: I think the
Re: service caching
AFAIK, Benson did some service start up performance turning this month. Please check out the latest snapshot, there must be some great improvement in CXF :) Willem. Christopher Cheng wrote: Looks like 2.0.5 is going to release soon, is this service caching in 2.0.5? On Wed, Mar 5, 2008 at 11:50 AM, Christopher Cheng [EMAIL PROTECTED] wrote: Looking forward to have this in the next release 2.0.5 or 2.1 :) On Tue, Mar 4, 2008 at 11:55 PM, Daniel Kulp [EMAIL PROTECTED] wrote: Willem, The issue is that they CAN be modified after that. One popular modification is to grab the EndpointInfo out of it and change the address. Other things like adding interceptors to the BindingInfo, changing properties on the service (like to enable schema validation), etc... are all modifications that affect the servicemodel. Databinding is less of an issue, but still one. For example, the databinding has an mtomThreshold and a namespaceMap that can be set programatically. In both of those cases, a modification should only affect the proxy on which the modification is made. Thus, the servicemodel would need a full clone, which may not be easy to do. It's certainly a lot more code to add. That said, I don't think it's a bad idea at all. On the contrary, it's a good idea. It's just a bit of work. Dan On Tuesday 04 March 2008, Willem Jiang wrote: Hi Dan, I think we could cache the ServiceInfo object and DataBinding object which will take lots of time to be created and can't be modified after that. Any thought? Willem Daniel Kulp wrote: On Tuesday 04 March 2008, Christopher Cheng wrote: I haven't read the codes of Axis, but I have been using it for 2 years and it doesn't have this problem. Having an overhead for 5-8 seconds is not an option for a production system in term of performance What you are saying is that all the services must implement Clonable interface? No, not the services themselves. Just our interal service model stuff that holds all the metadata. Basically, when creating a new service, we need to calculate the metadata. We should cache that if possible. Dan On Tue, Mar 4, 2008 at 4:48 AM, Daniel Kulp [EMAIL PROTECTED] wrote: Christopher, We cannot just reuse the Service model objects as they are completely modifiable at runtime. For example, one proxy could be reconfigured with new address or have additional interceptors added or similar. Those shouldn't affect others. On option that propably would make sense is to add a fast clone functionality to the entire service model so we could cache one, and then clone it whenever one is really needed. All the individual versions could be modified and not affect the original. However, doing that would be quite a bit of work as there are a LOT of classes that would need to be updated to support that. Patches towards that end would be great. :-) Dan On Monday 03 March 2008, Christopher Cheng wrote: wsdl is indeed cached in WSDLManagerImpl.definitionsMap After reading the codes, I have some questions. My workstation is a PentiumD 3GHz with 1.5GB RAM In the class org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buil d Serv iceFromWSDL(String url), setService(factory.create()); takes 3 seconds getDataBinding().initialize(getService()); takes 2 seconds These 2 methods are called even in 2nd calls. Can you also cache the services perhaps using jakarta commons-pool? or eh-cache? By the way, I found that the wsdl is put into the definitionMap twice if WSDLManagerImpl.getDefinition(URL url) is called. First in getDefintion(URL url) at line 147 and second in loadDefinition(String url) at line 201. On Mon, Mar 3, 2008 at 4:22 PM, Christopher Cheng [EMAIL PROTECTED] wrote: wsdl is indeed cached in WSDLManagerImpl.definitionsMap After reading the codes, I have some questions. My workstation is a PentiumD 3GHz with 1.5GB RAM In the class org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buil dSer viceFromWSDL(String url), setService(factory.create()); takes 3 seconds getDataBinding().initialize(getService()); takes 2 seconds These 2 methods are called even in 2nd calls. Can you also cache the services perhaps using jakarta commons-pool? or eh-cache? By the way, I found that the wsdl is put into the definitionMap twice if WSDLManagerImpl.getDefinition(URL url) is called. First in getDefintion(URL url) at line 147 and second in loadDefinition(String url) at line 201. On Mon, Mar 3, 2008 at 9:43 AM, Willem Jiang [EMAIL PROTECTED] wrote: Hi, I just went through the code, we really cache the WSDL definition in CXF. Could you send your test case and wsdl file to me ? I may need to trace it for more information. Regards, Willem Christopher Cheng wrote: I think the issue is still there. I used a for loop to execute the
How to change the namespace position in the generate xml message (SOAP message)?
Hi, Recently, I'm working on a web services client using CXF. But some request messages can't be parsed by the web services server. I found the problem is related to the namespace and prefix. The correct message: ?xml version=1.0 encoding=UTF-8? CreateItemRequest xmlns=http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema; AuthenticationData ServerDef ServerNameicmnlsdb/ServerName /ServerDef LoginData UserIDicmadmin/UserID Password/Password /LoginData /AuthenticationData Item ItemXML CLAIM_1047 DATE_1047=2004-01-27 CLAIMNO_1047=1234 DESC_1047=This is a claim regarding the accident.3 properties xmlns=http://www.ibm.com/xmlns/db2/cm/api/1.0/schema; type=document/ VEHICLE_1047 VIN_1047=38 OWNER_1047 FNAME_1047=Ben LNAME_1047=Dover/ OWNER_1047 FNAME_1047=Eileen LNAME_1047=Dover/ /VEHICLE_1047 VEHICLE_1047 VIN_1047=34 OWNER_1047 FNAME_1047=I.P. LNAME_1047=Freely/ /VEHICLE_1047 ICMBASE resourceObject xmlns=http://www.ibm.com/xmlns/db2/cm/api/1.0/schema; MIMEType=image/tiff label name=base 1/ /resourceObject /ICMBASE /CLAIM_1047 /ItemXML /Item /CreateItemRequest The namespace http://www.ibm.com/xmlns/db2/cm/api/1.0/schema was put in the element that needs it in this correct message. The mesage can't be parsed by server (sent by CXF): ?xml version=1.0 encoding=UTF-8? CreateItemRequest xmlns:ns2=http://www.ibm.com/xmlns/db2/cm/api/1.0/schema; xmlns=http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema; AuthenticationData ServerDef ServerNameicmnlsdb/ServerName /ServerDef LoginData UserIDicmadmin/UserID Password/Password /LoginData /AuthenticationData Item ItemXML CLAIM_1047 DESC_1047=This is a claim regarding the accident.3 CLAIMNO_1047=1234 DATE_1047=2004-01-27 ns2:properties type=document/ VEHICLE_1047 VIN_1047=38 OWNER_1047 LNAME_1047=Dover FNAME_1047=Ben/ OWNER_1047 LNAME_1047=Dover FNAME_1047=Eileen/ /VEHICLE_1047 VEHICLE_1047 VIN_1047=34 OWNER_1047 LNAME_1047=Freely FNAME_1047=I.P./ /VEHICLE_1047 ICMBASE ns2:resourceObject MIMEType=image/tiff ns2:label name=base 1/ /ns2:resourceObject /ICMBASE /CLAIM_1047 /ItemXML /Item /CreateItemRequest The namespace http://www.ibm.com/xmlns/db2/cm/api/1.0/schema was put in the root element. Is there anyone who knows how to configure CXF to generate the XML message in accordance with the first style? Or is there possible to manually modify the generated message using out Interceptor? Actually, I have tried to use interceptor the modify the output stream: public StreamInterceptor() { super(Phase.PRE_STREAM); addBefore(SoapPreProtocolOutInterceptor.class.getName()); } public void handleMessage(Message message) { OutputStream os = message.getContent(OutputStream.class); CachedStream cs = new CachedStream(); message.setContent(OutputStream.class, cs); message.getInterceptorChain().doIntercept(message); try { cs.flush(); CachedOutputStream csnew = (CachedOutputStream) message.getContent(OutputStream.class); //FileOutputStream fileOut = new FileOutputStream(D:\\test.txt); //CachedOutputStream.copyStream(csnew.getInputStream(), fileOut, 1024); StringBuilder sb = new StringBuilder(); csnew.writeCacheTo(sb); String tmpXML = sb.toString(); System.out.println(#OLD + tmpXML); while (tmpXML.indexOf(ns2:)!=-1){ String subTmp = tmpXML.substring(tmpXML.indexOf(ns2:)); subTmp = subTmp.substring(1, subTmp.indexOf( )); tmpXML = tmpXML.replaceAll(subTmp, subTmp.substring(4) + + xmlns=\http://www.ibm.com/xmlns/db2/cm/api/1.0/schema\http://www.ibm.com/xmlns/db2/cm/api/1.0/schema/ ); System.out.println(#FIXED### + tmpXML); } InputStream in = new ByteArrayInputStream(tmpXML.getBytes()); BufferedOutputStream bos = new BufferedOutputStream(os); CachedOutputStream.copyStream(in, bos, 1024); cs.close(); in.close(); //fileOut.close(); bos.close(); os.flush(); message.setContent(OutputStream.class, os); } catch (IOException ioe) { ioe.printStackTrace(); } } But the above code can't handle the message stream with MTOM attachements. It can't get the OutputStream at all. I don't know the reason. Your help will be really appreciated. Thanks in advance! Yuval Zou
Re: When client gets fault response, it throws java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder
On Wednesday 19 March 2008, Michael Berkowitz wrote: Thanks, Daniel. I am, in fact, using build 1.6.0_04-b12. Thanks for the advice, I'll look into it. What's the ETA on 2.1? I started a discussion about that: http://www.nabble.com/Options-for-CXF-2.1.-to16158740.html Users inputs would be welcome as well. :-) Dan -Original Message- From: Daniel Kulp [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 19, 2008 4:05 PM To: cxf-user@incubator.apache.org Cc: Michael Berkowitz Subject: Re: When client gets fault response, it throws java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder Looking at the error, I guess it's Java 6? That's probably the issue. My gut feeling says it would work ok if you used a Java5 vm. Getting 2.0.x to completely work on Java 6 (up to update 3, but not update 4) can be done, but you probably need to copy a couple jars from the lib dir to the jre/lib/endorsed dir. Specifically, the saaj* jars and the jaxb* jars.I don't think 2.0.x will work at all with Java 6 update 4. Maybe if you also endorse the jaxws-api jar. CXF 2.1 will support Java 6 update 4 (but not updates 1-3). Dan On Wednesday 19 March 2008, Michael Berkowitz wrote: I've put this into Jira; I apologize if that wasn't the proper procedure. I did search quite a bit for any references to such a problem beforehand - no luck. Anyway, what I would expect is to get an exception from the invoke() that contains whatever information is in the fault message. This is killing my tester, who can never tell what's gone wrong without searching the Tomcat log for the corresponding server error. Sometimes even that doesn't show up, but that's for another email... If anyone can suggest what may be going wrong, I'm all ears. TIA. Michael -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: How to change the namespace position in the generate xml message (SOAP message)?
Yuval Zou wrote: Hi, Recently, I'm working on a web services client using CXF. But some request messages can't be parsed by the web services server. I found the problem is related to the namespace and prefix. The correct message: ?xml version=1.0 encoding=UTF-8? CreateItemRequest xmlns=http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema; [snip] /CreateItemRequest The namespace http://www.ibm.com/xmlns/db2/cm/api/1.0/schema was put in the element that needs it in this correct message. The mesage can't be parsed by server (sent by CXF): ?xml version=1.0 encoding=UTF-8? CreateItemRequest xmlns:ns2=http://www.ibm.com/xmlns/db2/cm/api/1.0/schema; xmlns=http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema; [snip] /CreateItemRequest The namespace http://www.ibm.com/xmlns/db2/cm/api/1.0/schema was put in the root element. In XML terms the two messages are exactly the same, so it's more the fault of whatever is parsing the message on the server side rather than of the XML generator in CXF. Nontheless... If you're using JAXB databinding then you may be able to do what you want using a custom namespace prefix mapper in the data binding. Something like this (not tested but you get the idea): jaxws:client ... jaxws:dataBinding bean class=org.apache.cxf.jaxb.JAXBDataBinding property name=marshallerProperties map entry key=com.sun.xml.bind.namespacePrefixMapper bean class=my.package.NoPrefixNamespaceMapper / /entry /map /property /bean /jaxws:dataBinding /jaxws:client Where NoPrefixNamespaceMapper is an implementation of com.sun.xml.bind.marshaller.NamespacePrefixMapper whose getPreferredPrefix method always returns . This should force the marshaller to only use prefixes when it absolutely has to. Ian -- Ian Roberts | Department of Computer Science [EMAIL PROTECTED] | University of Sheffield, UK
Re: How to change the namespace position in the generate xml message (SOAP message)?
The CXF JAXB binding has a custom namespace mapper which can be told to control the prefixes. You can override it for further control. However, I'm very skeptical as to the idea modifying where the prefixes are defined. You might need to just make an interceptor that rewrites the XML. On Thu, Mar 20, 2008 at 8:20 AM, Ian Roberts [EMAIL PROTECTED] wrote: Yuval Zou wrote: Hi, Recently, I'm working on a web services client using CXF. But some request messages can't be parsed by the web services server. I found the problem is related to the namespace and prefix. The correct message: ?xml version=1.0 encoding=UTF-8? CreateItemRequest xmlns= http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema; [snip] /CreateItemRequest The namespace http://www.ibm.com/xmlns/db2/cm/api/1.0/schema was put in the element that needs it in this correct message. The mesage can't be parsed by server (sent by CXF): ?xml version=1.0 encoding=UTF-8? CreateItemRequest xmlns:ns2= http://www.ibm.com/xmlns/db2/cm/api/1.0/schema; xmlns=http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema; [snip] /CreateItemRequest The namespace http://www.ibm.com/xmlns/db2/cm/api/1.0/schema was put in the root element. In XML terms the two messages are exactly the same, so it's more the fault of whatever is parsing the message on the server side rather than of the XML generator in CXF. Nontheless... If you're using JAXB databinding then you may be able to do what you want using a custom namespace prefix mapper in the data binding. Something like this (not tested but you get the idea): jaxws:client ... jaxws:dataBinding bean class=org.apache.cxf.jaxb.JAXBDataBinding property name=marshallerProperties map entry key=com.sun.xml.bind.namespacePrefixMapper bean class=my.package.NoPrefixNamespaceMapper / /entry /map /property /bean /jaxws:dataBinding /jaxws:client Where NoPrefixNamespaceMapper is an implementation of com.sun.xml.bind.marshaller.NamespacePrefixMapper whose getPreferredPrefix method always returns . This should force the marshaller to only use prefixes when it absolutely has to. Ian -- Ian Roberts | Department of Computer Science [EMAIL PROTECTED] | University of Sheffield, UK
RE: When client gets fault response, it throws java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder
Actually, I'm embarrassed to say this, but I just realized that I didn't have the CXF jars in my client's classpath, just the JAX jars, so it worked okay with proper messages but didn't know what to do with faults. Putting the CXF jars (I didn't know exactly which were needed, so I took the whole distribution) in place worked. -Original Message- From: Daniel Kulp [mailto:[EMAIL PROTECTED] Sent: Thursday, March 20, 2008 2:18 PM To: cxf-user@incubator.apache.org Cc: Michael Berkowitz Subject: Re: When client gets fault response, it throws java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder On Wednesday 19 March 2008, Michael Berkowitz wrote: Thanks, Daniel. I am, in fact, using build 1.6.0_04-b12. Thanks for the advice, I'll look into it. What's the ETA on 2.1? I started a discussion about that: http://www.nabble.com/Options-for-CXF-2.1.-to16158740.html Users inputs would be welcome as well. :-) Dan -Original Message- From: Daniel Kulp [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 19, 2008 4:05 PM To: cxf-user@incubator.apache.org Cc: Michael Berkowitz Subject: Re: When client gets fault response, it throws java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder Looking at the error, I guess it's Java 6? That's probably the issue. My gut feeling says it would work ok if you used a Java5 vm. Getting 2.0.x to completely work on Java 6 (up to update 3, but not update 4) can be done, but you probably need to copy a couple jars from the lib dir to the jre/lib/endorsed dir. Specifically, the saaj* jars and the jaxb* jars.I don't think 2.0.x will work at all with Java 6 update 4. Maybe if you also endorse the jaxws-api jar. CXF 2.1 will support Java 6 update 4 (but not updates 1-3). Dan On Wednesday 19 March 2008, Michael Berkowitz wrote: I've put this into Jira; I apologize if that wasn't the proper procedure. I did search quite a bit for any references to such a problem beforehand - no luck. Anyway, what I would expect is to get an exception from the invoke() that contains whatever information is in the fault message. This is killing my tester, who can never tell what's gone wrong without searching the Tomcat log for the corresponding server error. Sometimes even that doesn't show up, but that's for another email... If anyone can suggest what may be going wrong, I'm all ears. TIA. Michael -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: How to change the namespace position in the generate xml message (SOAP message)?
This is definitely a bug for whomever is consuming that message. According to the XML rules, both messages are equivilent. Couple options: 1) Best performing option: write an interceptor that would be immediately AFTER the StaxOutInterceptor that would take the XMLStreamWriter and replace it with a new XMLStreamWriter that wrappers the original, but overwrides the start element and namespace map stuff so that it generates empty prefixes at all times. That StreamWriter might be a bit tricky to write if you aren't familliar with StAX, but it would definitely be the best performing as you wouln't break the streaming, you wouldn't need to scan the byte[], etc FYI: your interceptor will also need to set: msg.put(AbstractOutDatabindingInterceptor.DISABLE_OUTPUTSTREAM_OPTIMIZATION, Boolean.TRUE); to make sure it actually uses the new StreamWriter in all cases. 2) Next option: your CachedOutputStream stuff. This actually will work, but you need to modify things a bit. First off, it needs to be split into two interceptors: (usually, it's one interceptor.java that then has an inner class for the other. See the AttachmentOutInterceptor for example) a) First/Outer one will replace the OutputStream with the cached output stream and record the original stream. It will also then add the second one to the chain. Make sure it's stuck before the attachement stuff: super(Phase.PRE_STREAM); addBefore(AttachmentOutInterceptor.class.getName()); b) The second/inner interceptor would grab the Cached stream, do the transformation, and flush back to original stream. It would be: super(Phase.PRE_STREAM_ENDING); addAfter(AttachmentOutInterceptor.AttachmentOutEndingInterceptor .class.getName()); Dan On Thursday 20 March 2008, Yuval Zou wrote: Hi, Recently, I'm working on a web services client using CXF. But some request messages can't be parsed by the web services server. I found the problem is related to the namespace and prefix. The correct message: ?xml version=1.0 encoding=UTF-8? CreateItemRequest xmlns=http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema; AuthenticationData ServerDef ServerNameicmnlsdb/ServerName /ServerDef LoginData UserIDicmadmin/UserID Password/Password /LoginData /AuthenticationData Item ItemXML CLAIM_1047 DATE_1047=2004-01-27 CLAIMNO_1047=1234 DESC_1047=This is a claim regarding the accident.3 properties xmlns=http://www.ibm.com/xmlns/db2/cm/api/1.0/schema; type=document/ VEHICLE_1047 VIN_1047=38 OWNER_1047 FNAME_1047=Ben LNAME_1047=Dover/ OWNER_1047 FNAME_1047=Eileen LNAME_1047=Dover/ /VEHICLE_1047 VEHICLE_1047 VIN_1047=34 OWNER_1047 FNAME_1047=I.P. LNAME_1047=Freely/ /VEHICLE_1047 ICMBASE resourceObject xmlns=http://www.ibm.com/xmlns/db2/cm/api/1.0/schema; MIMEType=image/tiff label name=base 1/ /resourceObject /ICMBASE /CLAIM_1047 /ItemXML /Item /CreateItemRequest The namespace http://www.ibm.com/xmlns/db2/cm/api/1.0/schema was put in the element that needs it in this correct message. The mesage can't be parsed by server (sent by CXF): ?xml version=1.0 encoding=UTF-8? CreateItemRequest xmlns:ns2=http://www.ibm.com/xmlns/db2/cm/api/1.0/schema; xmlns=http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema; AuthenticationData ServerDef ServerNameicmnlsdb/ServerName /ServerDef LoginData UserIDicmadmin/UserID Password/Password /LoginData /AuthenticationData Item ItemXML CLAIM_1047 DESC_1047=This is a claim regarding the accident.3 CLAIMNO_1047=1234 DATE_1047=2004-01-27 ns2:properties type=document/ VEHICLE_1047 VIN_1047=38 OWNER_1047 LNAME_1047=Dover FNAME_1047=Ben/ OWNER_1047 LNAME_1047=Dover FNAME_1047=Eileen/ /VEHICLE_1047 VEHICLE_1047 VIN_1047=34 OWNER_1047 LNAME_1047=Freely FNAME_1047=I.P./ /VEHICLE_1047 ICMBASE ns2:resourceObject MIMEType=image/tiff ns2:label name=base 1/ /ns2:resourceObject /ICMBASE /CLAIM_1047 /ItemXML /Item /CreateItemRequest The namespace http://www.ibm.com/xmlns/db2/cm/api/1.0/schema was put in the root element. Is there anyone who knows how to configure CXF to generate the XML message in accordance with the first style? Or is there possible to manually modify the generated message using out Interceptor? Actually, I have tried to use interceptor the modify the output stream: public StreamInterceptor() { super(Phase.PRE_STREAM); addBefore(SoapPreProtocolOutInterceptor.class.getName()); } public void handleMessage(Message message) { OutputStream os = message.getContent(OutputStream.class); CachedStream cs = new CachedStream(); message.setContent(OutputStream.class, cs); message.getInterceptorChain().doIntercept(message); try { cs.flush();
RE: When client gets fault response, it throws java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder
Well, that almost worked. Now that I put the CXF jars in, my client throws exceptions when calling certain WS methods (it seems to be limited to those that take a few parameters). With the CXF jars I get the following stack when making the call: addAll():472, ArrayList.java createWrapperObject():-1 handleMessage():102, WrapperClassOutInterceptor.java doIntercept():208, PhaseInterceptorChain.java invoke():276, ClientImpl.java invoke():222, ClientImpl.java invokeSync():73, ClientProxy.java invoke():135, JaxWsClientProxy.java getNumbers():-1 doLine():95, CmdLineApp.java main():45, CmdLineApp.java and then in addAll() it throws a NullPointerException. WITHOUT the CXF jars this is the stack I get: addAll():472, ArrayList.java copySatelliteInto():86, DistributedPropertySet.java init():168, Packet.java createClientResponse():607, Packet.java process():148, HttpTransportPipe.java processRequest():74, HttpTransportPipe.java __doRun():581, Fiber.java _doRun():540, Fiber.java doRun():525, Fiber.java runSync():422, Fiber.java process():235, Stub.java doProcess():120, SEIStub.java invoke():230, SyncMethodHandler.java invoke():210, SyncMethodHandler.java invoke():103, SEIStub.java getNumbers():-1 doLine():95, CmdLineApp.java main():45, CmdLineApp.java and everything works fine (unless of course the server sends back a fault message, in which case -- as we know -- the client throws an exception). I will freely admit that I haven't delved into JAX, SOAP or CXF -- I just want an easy way to export some methods as Web Services and use them transparently in a client application -- so please factor that in when explaining your theories of what's gone so terribly, terribly wrong. Thanks in advance. Michael -Original Message- From: Michael Berkowitz [mailto:[EMAIL PROTECTED] Sent: Thursday, March 20, 2008 2:48 PM To: Daniel Kulp; cxf-user@incubator.apache.org Subject: RE: When client gets fault response, it throws java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder Actually, I'm embarrassed to say this, but I just realized that I didn't have the CXF jars in my client's classpath, just the JAX jars, so it worked okay with proper messages but didn't know what to do with faults. Putting the CXF jars (I didn't know exactly which were needed, so I took the whole distribution) in place worked. -Original Message- From: Daniel Kulp [mailto:[EMAIL PROTECTED] Sent: Thursday, March 20, 2008 2:18 PM To: cxf-user@incubator.apache.org Cc: Michael Berkowitz Subject: Re: When client gets fault response, it throws java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder On Wednesday 19 March 2008, Michael Berkowitz wrote: Thanks, Daniel. I am, in fact, using build 1.6.0_04-b12. Thanks for the advice, I'll look into it. What's the ETA on 2.1? I started a discussion about that: http://www.nabble.com/Options-for-CXF-2.1.-to16158740.html Users inputs would be welcome as well. :-) Dan -Original Message- From: Daniel Kulp [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 19, 2008 4:05 PM To: cxf-user@incubator.apache.org Cc: Michael Berkowitz Subject: Re: When client gets fault response, it throws java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder Looking at the error, I guess it's Java 6? That's probably the issue. My gut feeling says it would work ok if you used a Java5 vm. Getting 2.0.x to completely work on Java 6 (up to update 3, but not update 4) can be done, but you probably need to copy a couple jars from the lib dir to the jre/lib/endorsed dir. Specifically, the saaj* jars and the jaxb* jars.I don't think 2.0.x will work at all with Java 6 update 4. Maybe if you also endorse the jaxws-api jar. CXF 2.1 will support Java 6 update 4 (but not updates 1-3). Dan On Wednesday 19 March 2008, Michael Berkowitz wrote: I've put this into Jira; I apologize if that wasn't the proper procedure. I did search quite a bit for any references to such a problem beforehand - no luck. Anyway, what I would expect is to get an exception from the invoke() that contains whatever information is in the fault message. This is killing my tester, who can never tell what's gone wrong without searching the Tomcat log for the corresponding server error. Sometimes even that doesn't show up, but that's for another email... If anyone can suggest what may be going wrong, I'm all ears. TIA. Michael -- J. Daniel Kulp Principal
Re: How to change the namespace position in the generate xml message (SOAP message)?
Hi Dan, Thanks a lot for your quick and detailed response! I will try the options provided by you. Hope everything goes well~~ :) Yuval 2008/3/20, Daniel Kulp [EMAIL PROTECTED]: This is definitely a bug for whomever is consuming that message. According to the XML rules, both messages are equivilent. Couple options: 1) Best performing option: write an interceptor that would be immediately AFTER the StaxOutInterceptor that would take the XMLStreamWriter and replace it with a new XMLStreamWriter that wrappers the original, but overwrides the start element and namespace map stuff so that it generates empty prefixes at all times. That StreamWriter might be a bit tricky to write if you aren't familliar with StAX, but it would definitely be the best performing as you wouln't break the streaming, you wouldn't need to scan the byte[], etc FYI: your interceptor will also need to set: msg.put( AbstractOutDatabindingInterceptor.DISABLE_OUTPUTSTREAM_OPTIMIZATION, Boolean.TRUE); to make sure it actually uses the new StreamWriter in all cases. 2) Next option: your CachedOutputStream stuff. This actually will work, but you need to modify things a bit. First off, it needs to be split into two interceptors: (usually, it's one interceptor.java that then has an inner class for the other. See the AttachmentOutInterceptor for example) a) First/Outer one will replace the OutputStream with the cached output stream and record the original stream. It will also then add the second one to the chain. Make sure it's stuck before the attachement stuff: super(Phase.PRE_STREAM); addBefore(AttachmentOutInterceptor.class.getName()); b) The second/inner interceptor would grab the Cached stream, do the transformation, and flush back to original stream. It would be: super(Phase.PRE_STREAM_ENDING); addAfter(AttachmentOutInterceptor.AttachmentOutEndingInterceptor .class.getName()); Dan On Thursday 20 March 2008, Yuval Zou wrote: Hi, Recently, I'm working on a web services client using CXF. But some request messages can't be parsed by the web services server. I found the problem is related to the namespace and prefix. The correct message: ?xml version=1.0 encoding=UTF-8? CreateItemRequest xmlns=http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema; AuthenticationData ServerDef ServerNameicmnlsdb/ServerName /ServerDef LoginData UserIDicmadmin/UserID Password/Password /LoginData /AuthenticationData Item ItemXML CLAIM_1047 DATE_1047=2004-01-27 CLAIMNO_1047=1234 DESC_1047=This is a claim regarding the accident.3 properties xmlns=http://www.ibm.com/xmlns/db2/cm/api/1.0/schema; type=document/ VEHICLE_1047 VIN_1047=38 OWNER_1047 FNAME_1047=Ben LNAME_1047=Dover/ OWNER_1047 FNAME_1047=Eileen LNAME_1047=Dover/ /VEHICLE_1047 VEHICLE_1047 VIN_1047=34 OWNER_1047 FNAME_1047=I.P. LNAME_1047=Freely/ /VEHICLE_1047 ICMBASE resourceObject xmlns=http://www.ibm.com/xmlns/db2/cm/api/1.0/schema; MIMEType=image/tiff label name=base 1/ /resourceObject /ICMBASE /CLAIM_1047 /ItemXML /Item /CreateItemRequest The namespace http://www.ibm.com/xmlns/db2/cm/api/1.0/schema was put in the element that needs it in this correct message. The mesage can't be parsed by server (sent by CXF): ?xml version=1.0 encoding=UTF-8? CreateItemRequest xmlns:ns2=http://www.ibm.com/xmlns/db2/cm/api/1.0/schema; xmlns=http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema; AuthenticationData ServerDef ServerNameicmnlsdb/ServerName /ServerDef LoginData UserIDicmadmin/UserID Password/Password /LoginData /AuthenticationData Item ItemXML CLAIM_1047 DESC_1047=This is a claim regarding the accident.3 CLAIMNO_1047=1234 DATE_1047=2004-01-27 ns2:properties type=document/ VEHICLE_1047 VIN_1047=38 OWNER_1047 LNAME_1047=Dover FNAME_1047=Ben/ OWNER_1047 LNAME_1047=Dover FNAME_1047=Eileen/ /VEHICLE_1047 VEHICLE_1047 VIN_1047=34 OWNER_1047 LNAME_1047=Freely FNAME_1047=I.P./ /VEHICLE_1047 ICMBASE ns2:resourceObject MIMEType=image/tiff ns2:label name=base 1/ /ns2:resourceObject /ICMBASE /CLAIM_1047 /ItemXML /Item /CreateItemRequest The namespace http://www.ibm.com/xmlns/db2/cm/api/1.0/schema was put in the root element. Is there anyone who knows how to configure CXF to generate the XML message in accordance with the first style? Or is there possible to manually modify the generated message using out Interceptor? Actually, I have tried to use interceptor the modify the output stream: public StreamInterceptor() { super(Phase.PRE_STREAM); addBefore(SoapPreProtocolOutInterceptor.class.getName()); } public void
REST-JS
Hi, Currently CXF supports Java2JS for simple or JAX-WS front ends. Does CXF support JAX-RS front end (REST-JavaScript) too? Thanks! Arul
Re: REST-JS
Arul, CXF has a 'front end' that allows you to run Javascript on the server in Rhino. I believe that this should work fine for REST, but I'm not the REST expert. Java2js generates Client javascript. It does not generate REST clients, only SOAP clients. Does that clarify? -benson On Thu, Mar 20, 2008 at 1:29 PM, Arul Dhesiaseelan [EMAIL PROTECTED] wrote: Hi, Currently CXF supports Java2JS for simple or JAX-WS front ends. Does CXF support JAX-RS front end (REST-JavaScript) too? Thanks! Arul
Re: REST-JS
There is no existing code to do this, if I follow your definition of a 'resource object'. It would be only a few days of work to add to the existing Javascript generator to add this, I bet. If you post an example of what you'd like to see generated that might clarify. I for one wouldn't be in a position to tackle the job if I've understood it correctly. Here is my scenario. I have a JAX-RS CXF service. I have a web application which consumes this service. Is it possible to generate the REST resources as JavaScript so that the web app can use it directly when doing a POST (ex: construct the resource object)?
ListDouble with aegis mapping issue
All, I've recently run into an issue with the Mar 14 snapshot build and was wondering if anyone has experienced something similar. If I have a service with a method that takes a parameter of type ListDouble and use aegis mapping files to map the argument's componentType to java.lang.Double, the produced wsdl adds the following block: ... xsd:import namespace=http://lang.java/ ... xsd:complexType name=ArrayOfDouble xsd:sequence xsd:element maxOccurs=unbounded minOccurs=0 name=Double nillable=true type=tns:Double/ /xsd:sequence /xsd:complexType .. In previous builds, a paratmer of type ListDouble added the following block: xsd:complexType name=ArrayOfDouble xsd:sequence xsd:element maxOccurs=unbounded minOccurs=0 name=double nillable=true type=xsd:double/ /xsd:sequence /xsd:complexType The difference being that the Object java.lang.Double is no longer being mapped to xsd:double. Is this intended? I tried using the snapshot build from Mar 19, but that won't even start up. Seems there was a change or regression with the parsing of the Spring 2.0 simple:server parsing since with that build I get the following error at start-up: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.apache.cxf.service.model.ServiceInfo.getSchemas()Ljava/util/Collecti on; Has anyone else come across this issue. Javier Delgadillo ESRI / ArcWeb Services http://www.esri.com/ (909) 793-2853 x1068
Re: ListDouble with aegis mapping issue
2.1 snapshot? Looks like a goof to me. Please make a JIRA. On Thu, Mar 20, 2008 at 5:03 PM, Javier Delgadillo [EMAIL PROTECTED] wrote: All, I've recently run into an issue with the Mar 14 snapshot build and was wondering if anyone has experienced something similar. If I have a service with a method that takes a parameter of type ListDouble and use aegis mapping files to map the argument's componentType to java.lang.Double, the produced wsdl adds the following block: ... xsd:import namespace=http://lang.java/ ... xsd:complexType name=ArrayOfDouble xsd:sequence xsd:element maxOccurs=unbounded minOccurs=0 name=Double nillable=true type=tns:Double/ /xsd:sequence /xsd:complexType .. In previous builds, a paratmer of type ListDouble added the following block: xsd:complexType name=ArrayOfDouble xsd:sequence xsd:element maxOccurs=unbounded minOccurs=0 name=double nillable=true type=xsd:double/ /xsd:sequence /xsd:complexType The difference being that the Object java.lang.Double is no longer being mapped to xsd:double. Is this intended? I tried using the snapshot build from Mar 19, but that won't even start up. Seems there was a change or regression with the parsing of the Spring 2.0 simple:server parsing since with that build I get the following error at start-up: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.apache.cxf.service.model.ServiceInfo.getSchemas()Ljava/util/Collecti on; Has anyone else come across this issue. Javier Delgadillo ESRI / ArcWeb Services http://www.esri.com/ (909) 793-2853 x1068
RE: ListDouble with aegis mapping issue
Created 2. The wsdl issue: http://issues.apache.org/jira/browse/CXF-1482 Startup exception: https://issues.apache.org/jira/browse/CXF-1483 -Original Message- From: Benson Margulies [mailto:[EMAIL PROTECTED] Sent: Thursday, March 20, 2008 2:59 PM To: cxf-user@incubator.apache.org Subject: Re: ListDouble with aegis mapping issue 2.1 snapshot? Looks like a goof to me. Please make a JIRA. On Thu, Mar 20, 2008 at 5:03 PM, Javier Delgadillo [EMAIL PROTECTED] wrote: All, I've recently run into an issue with the Mar 14 snapshot build and was wondering if anyone has experienced something similar. If I have a service with a method that takes a parameter of type ListDouble and use aegis mapping files to map the argument's componentType to java.lang.Double, the produced wsdl adds the following block: ... xsd:import namespace=http://lang.java/ ... xsd:complexType name=ArrayOfDouble xsd:sequence xsd:element maxOccurs=unbounded minOccurs=0 name=Double nillable=true type=tns:Double/ /xsd:sequence /xsd:complexType .. In previous builds, a paratmer of type ListDouble added the following block: xsd:complexType name=ArrayOfDouble xsd:sequence xsd:element maxOccurs=unbounded minOccurs=0 name=double nillable=true type=xsd:double/ /xsd:sequence /xsd:complexType The difference being that the Object java.lang.Double is no longer being mapped to xsd:double. Is this intended? I tried using the snapshot build from Mar 19, but that won't even start up. Seems there was a change or regression with the parsing of the Spring 2.0 simple:server parsing since with that build I get the following error at start-up: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.apache.cxf.service.model.ServiceInfo.getSchemas()Ljava/util/Collecti on; Has anyone else come across this issue. Javier Delgadillo ESRI / ArcWeb Services http://www.esri.com/ (909) 793-2853 x1068
Error in AbstractHTTPDestination.setHeaders, AbstractHTTPDestination.setHeaders
If I run my service inside a Tomcat-5.5 runtime configured in Eclipse-3.2, all works fine. I run the very same code, deployed on Tomcat-5.5 on Linux, I get this error. If anyone can suggest something short of debuggin the CXF source, that would be great. I am using 2.0.4. I searched and found some references about SOAP headers, by my service is not using those, in fact the message looks like: ?xml version=1.0 encoding=utf-8? SOAP-ENV:Envelope xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; SOAP-ENV:Body loginUser xmlns=http://services.secadmin.cis.ms.com/types; ns0:servername xmlns:ns0=http://services.secadmin.cis.ms.com/types;MYSERVER/ns0:serv ername ns0:database xmlns:ns0=http://services.secadmin.cis.ms.com/types;my_db/ns0:databas e ns0:username xmlns:ns0=http://services.secadmin.cis.ms.com/types;user56/ns0:userna me ns0:password xmlns:ns0=http://services.secadmin.cis.ms.com/types;user56pw/ns0:pass word /loginUser /SOAP-ENV:Body /SOAP-ENV:Envelope ava.lang.ArrayIndexOutOfBoundsException: 1 org.apache.cxf.transport.http.AbstractHTTPDestination.setHeaders(Abstrac tHTTPDestination.java:137) org.apache.cxf.transport.http.AbstractHTTPDestination.setupMessage(Abstr actHTTPDestination.java:286) org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestin ation.java:82) org.apache.cxf.transport.servlet.ServletController.invokeDestination(Ser vletController.java:213) org.apache.cxf.transport.servlet.ServletController.invoke(ServletControl ler.java:150) org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFSe rvlet.java:170) org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFSe rvlet.java:148) javax.servlet.http.HttpServlet.service(HttpServlet.java:709) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.