Using cxf with external web-services
Hello everyone, suppose I want to write a client application to use the meteo webservice at this address: http://www.webservicex.net/globalweather.asmx?WSDL What are the steps to do so using CXF ? I've been using wsdl2java to geneate java classes and interfaces, but it's not quite clear how to combine such classes with cxf. In particular, up to now I've been using cxf to generate clients using the ClientProxyFactoryBean...or the DynamicClientfactory to generate the client. So, help is very appreciated. Cheers, Valerio -- http://www.linkedin.com/in/vschiavoni http://jroller.com/vschiavoni
[HelloWorld JavaScript client] problem on IE.
Hi all, I just join cxf users mailingL, i'm a new cxf user and try to use the JavaScript CXF Client (good capability !) I got no problem since i try the sample (described into documentation) on Firefox (2.0.0.13) but i got a JavaScript error with Internet Explorer 7 (7.05730.13) (idem on version 6) : Microsoft Jscript runtime error: 'spring_demo__HelloWorld' is undefined Here is an extract of the client src : --- (...) head !-- Generate and retrieve a JavaScript client for the server. -- script type=text/javascript src=/api/HW?js/script script type=text/javascript // ![CDATA[ var responseSpan; !-- This is the function called upon success. -- function sayHiResponse(response) { responseSpan.firstChild.nodeValue = response.getReturn(); } !-- This is the function called for an error. -- function sayHiError(error) { alert('error ' + error); } !-- This function is invoked from the button press to run the service. -- function invokeSayHi() { var HW = new spring_demo__HelloWorld (); HW.url = /api/HW; responseSpan = document.getElementById('sayHiResponse'); responseSpan.firstChild.nodeValue = - pending - ; HW.sayHi(sayHiResponse, sayHiError, document.forms[0].text.value); } function init() { invokeSayHi(); } // ]] /script /head (...) --- Here is the cxf doc. : http://cwiki.apache.org/CXF20DOC/javascript-clients.html CXF version used (SNAPSHOT) : apache-cxf-2.1-incubator-20080314.200134-39 Could you help me to solve this problem ? Here is another test i do : When i make a direct access to the generated JS (/api/HW?js) with IE, i got a popup titled : File download security warning : Do you want to save this file, of find a program online to open it ? - Name : HW - Type : Unknown File Type - From : myhost [find] [save] [cancel] Maybe the mime-type isn't correct or null ? If i choose save the file, i got the correct javascript client code. Thanks Regards Brice Vandeputte
Re: Using cxf with external web-services
Have you already had a look at http://cwiki.apache.org/CXF20DOC/a-simple-jax-ws-service.html ? -- View this message in context: http://www.nabble.com/Using-cxf-with-external-web-services-tp16627061p16627305.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: Thrown by JAXB : undefined element declaration 's:schema'
Hey Guys, Thanks for the various replies on this - If i wanted to add s:import - what would I need to add to the WSDL file? Cheers Tim On 8 Apr 2008, at 21:31, Daniel Kulp wrote: Thus, to get it working for CXF, you would need to modify the schema to put the proper s:import in place to import the schema schema, then include the binding file to deal with the duplicate classes.
NPE org.apache.cxf.attachment.AttachmentSerializer.writeAttachments
Hi List, I'm relatively new to Apache CXF and managed to implement a Webservice using JAX-WS which returns MTOM attachments. My service connects to a Webserver and gets the content of the MTOM attachment by reading a Java HTTPConnection. Sometimes there seems to be no content in the HTTPConnection inputStream, so I implemented a check for this case which throws an exception. At a first glance everything is ok but when I do some load test with SoapUI I get this exception in the tomcat log: java.lang.NullPointerException at javax.activation.DataHandler.writeTo(DataHandler.java:90) at org.apache.cxf.attachment.AttachmentSerializer.writeAttachments(AttachmentSerializer.java:129) at org.apache.cxf.interceptor.AttachmentOutInterceptor$AttachmentOutEndingInterceptor.handleMessage(AttachmentOutInterceptor.java:77) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220) at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:74) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:77) at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:150) 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:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Thread.java:595) 11.04.2008 16:18:33 org.apache.cxf.phase.PhaseInterceptorChain doIntercept INFO: Interceptor has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Error writing to XMLStreamWriter. at org.apache.cxf.binding.soap.interceptor.Soap11FaultOutInterceptor.handleMessage(Soap11FaultOutInterceptor.java:140) at org.apache.cxf.binding.soap.interceptor.Soap11FaultOutInterceptor.handleMessage(Soap11FaultOutInterceptor.java:43) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220) at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:96) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:254) at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:74) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:77) at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:150) at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:170) at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:148) at
[CXF] deployment problems
Hi all, I have a provider implementation for a service, then i want deploy with a specified wsdl and every msg should call the invoke() method I deploy it and my specified wsdl if correctly displayed, but every msg sent to the service is threat as OneWay (an empty 200ok is sent every time... ) Here is the config: web.xml ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd; web-app context-param param-namecontextConfigLocation/param-name param-valueWEB-INF/beans.xml/param-value /context-param listener listener-class org.springframework.web.context.ContextLoaderListener /listener-class /listener servlet servlet-nameCXFServlet/servlet-name display-nameCXF Servlet/display-name servlet-class org.apache.cxf.transport.servlet.CXFServlet /servlet-class load-on-startup1/load-on-startup /servlet servlet-mapping servlet-nameCXFServlet/servlet-name url-pattern/*/url-pattern /servlet-mapping /web-app beans.xml beans xmlns=http://www.springframework.org/schema/beans; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:jaxws=http://cxf.apache.org/jaxws; xsi:schemaLocation= http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd; import resource=classpath:META-INF/cxf/cxf.xml / import resource=classpath:META-INF/cxf/cxf-extension-soap.xml / import resource=classpath:META-INF/cxf/cxf-servlet.xml / bean id=logInbound class=org.apache.cxf.interceptor.LoggingInInterceptor/ bean id=logOutbound class=org.apache.cxf.interceptor.LoggingOutInterceptor/ bean id=cxf class=org.apache.cxf.bus.CXFBusImpl property name=inInterceptors list ref bean=logInbound/ /list /property property name=outInterceptors list ref bean=logOutbound/ /list /property property name=outFaultInterceptors list ref bean=logOutbound/ /list /property /bean jaxws:endpoint id=ese6ordine serviceName=s:OrdineService implementor=isi.esercitazione.java2wsdl.Server address=/ordine xmlns:s=http://www.rivenditore.org/Ordine/ /beans isi.esercitazione.java2wsdl.Server package isi.esercitazione.java2wsdl; import javax.xml.soap.MessageFactory; @ServiceMode(value=Mode.MESSAGE) @WebServiceProvider(serviceName = OrdineService, portName = OrdineInterfaceEndpoint, targetNamespace = http://www.rivenditore.org/Ordine;, wsdlLocation = webapps/ese6/WEB-INF/ordini.wsdl) public class Server implements ProviderSOAPMessage{ public SOAPMessage invoke(SOAPMessage req){ SOAPMessage res = null; try{ MessageFactory msgFac = MessageFactory.newInstance(); res = msgFac.createMessage(); SOAPFactory soapFac = SOAPFactory.newInstance(); SOAPBodyElement esito = res.getSOAPBody().addBodyElement(soapFac.createName(esito, ele, http://www.rivenditore.org/ordiniElements;)); SOAPElement ok = esito.addChildElement(ok); SOAPElement id = ok.addChildElement(idOrdine); id.setTextContent(123456); SOAPElement totale = ok.addChildElement(totale); totale.setTextContent(123.45); totale.addAttribute(soapFac.createName(valuta), USD); } catch(SOAPException soapex){ System.out.println(Errore SOAP: + soapex); soapex.printStackTrace(); } catch(Exception ex){ System.out.println(Errore SOAP: + ex); ex.printStackTrace(); } return res; } } Any tip? Thx all, Lorenzo -- View this message in context: http://www.nabble.com/-CXF--deployment-problems-tp16627862p16627862.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: Using cxf with external web-services
For the most part, you can just do: wsdl2java http://www.webservicex.net/globalweather.asmx?WSDL Then in your code, just do: GlobalWeather weather = new GlobalWeather(); GlobalWeatherSoap port = weather.getGlobalWeatherSoap(); String result = port.getWeather(city, country); Dan On Friday 11 April 2008, Valerio Schiavoni wrote: Hello everyone, suppose I want to write a client application to use the meteo webservice at this address: http://www.webservicex.net/globalweather.asmx?WSDL What are the steps to do so using CXF ? I've been using wsdl2java to geneate java classes and interfaces, but it's not quite clear how to combine such classes with cxf. In particular, up to now I've been using cxf to generate clients using the ClientProxyFactoryBean...or the DynamicClientfactory to generate the client. So, help is very appreciated. Cheers, Valerio -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Adding headers to soap request?
Hey chaps, Is there a way to add headers to the soap request inside the CXF service class? (or any other way) Cheers, Tim
Re: Adding headers to soap request?
OK. I'm sick of answering this. :-) Added to the FAQ: http://cwiki.apache.org/confluence/display/CXF/FAQ#FAQ-HowcanIaddsoapheaderstotherequest%2Fresponse%3F Dan On Friday 11 April 2008, Tim Perrett wrote: Hey chaps, Is there a way to add headers to the soap request inside the CXF service class? (or any other way) Cheers, Tim -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: wsdl2Java compiler error w/customer binding
It is generated by the wsdl2java tool. I managed to get the source to compile by manually building it but I thought that the wsdl2java tool should have been able to do that as well. Chris Mathrusse [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 jim ma [EMAIL PROTECTED] 04/09/2008 06:41 PM Please respond to cxf-user@incubator.apache.org To cxf-user@incubator.apache.org cc Subject Re: wsdl2Java compiler error w/customer binding org.w3._2001.xmlschema.Adapter1 is generated by wsdl2java tool or wrote by yourself ? Jim On Thu, Apr 10, 2008 at 6:24 AM, [EMAIL PROTECTED] wrote: I've followed the documentation pertaining to a customer binding for wsdl2java. Specifically, replacing the XMLGregorianCalendar with java.util.Date. The command I'm using is as follows: ./wsdl2java.bat -d s:\\cxf-client\\src -compile -client -b quoteBrokerBinding.ml http://cmathrusxp:8080/QuoteService_r1.6/services/QuoteBroker?wsdl My binding file is as follows: jaxws:bindings wsdlLocation= http://cmathrusxp:8080/QuoteService_r1.6/services/QuoteBroker?wsdl; xmlns:jaxws=http://java.sun.com/xml/ns/jaxws; xmlns:xs=http://www.w3.org/2001/XMLSchema; xmlns:jxb=http://java.sun.com/xml/ns/jaxb; xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/; jaxws:bindings node=wsdl:definitions/wsdl:types/xs:[EMAIL PROTECTED]'http://quoting.it.sybase.com' ] jxb:globalBindings xmlns:jxb=http://java.sun.com/xml/ns/jaxb; xmlns:xs=http://www.w3.org/2001/XMLSchema; jxb:javaType name=java.util.Date xmlType=xs:dateTime parseMethod=org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime printMethod=org.apache.cxf.tools.common.DataTypeAdapter.printDateTime/ /jxb:globalBindings /jaxws:bindings /jaxws:bindings And when I run the wsdl2java command I get the following error: s:\cxf-client\src\com\sybase\it\quoting\QuoteLineitemDTO.java:10: package org.w3._2001.xmlschema does not exist import org.w3._2001.xmlschema.Adapter1; I've looked at the generated source and there is an Adapter1.java file located in S:\cxf-client\src\org\w3\_2001\xmlschema So things appear to be genereating but the error seems to be coming from the -compile option. Is there something I need to do to get past this or should I simply manually build? Thanks... Chris Mathrusse [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553
Re: Adding headers to soap request?
Cheers Dan - your a star :-) On 11 Apr 2008, at 17:12, Daniel Kulp wrote: OK. I'm sick of answering this. :-) Added to the FAQ: http://cwiki.apache.org/confluence/display/CXF/FAQ#FAQ-HowcanIaddsoapheaderstotherequest%2Fresponse%3F Dan
Re: Problems resolving schemas using http, when wsdl is in a jar
It probably is a bug in CXF. Feel free to log it. (and a patch would be nice :-) However, there is another issue that you need to think about: If the xsd's are to be hosted from the same localhost container as the service, the service may not start. For example, in tomcat, it loads and initializes all wars before starting the port listener. Thus, if we try to go back to http://localhost; to get the xsd, there won't be anything listening on the port and we won't be able to get the wsdl. The service won't start. Dan On Thursday 10 April 2008, [EMAIL PROTECTED] wrote: Hi, I'm writing some code that will allow me to deploy webservices that has been setup as ServicePoints in Hivemind. This way I can build components (JARs) with the webservice that I want to deploy and just add them to the classpath of my WAR project and they will deployed. No need to configure everything in one xml file, distributed configuration (maybe something to commit back to CXF when I'm done?). It works just fine until I realize that I want to import XSD schemas in my WSDLs to allow validation of the SOAP requests. Now, I have several webservices sharing XSDs (one entity model for several services and so on) so I don't want to package the XSDs in the JAR that contains the implementation code and the WSDL for the actual service. I add an import for a external resource in my test.wsdl: xsd:import . schemaLocation=http://localhost/entities/user.xsd; / Generating Java code with WSDL2JAVA works fine, and I set the @Webservice annotation accordingly (wsdlLocation=schemas/service/test.wsdl), the WSDL will reside in the JAR file that is built with the service code, the XSDs are NOT, they reside on a server (in this case localhost). Now, when I deploy my WAR file containing the JAR I get an error (removing the wsdlLocation from the Webservice annotation - thus building service from SEI instead of WSDL - will work just fine, but then I lose the validation!) like this: ...XMLSchemaException: Unable to locate imported document at 'http://localhost/entities/user.xsd', relative to 'jar:file://.../warfile.war/WEB-INF/lib/test.jar!/schemas/services /test. wsdl'. at org.apache.cxf.catalog.CatalogXMLSchemaURIResolver.resolveEntity(Catal ogXMLS chemaURIResolver.java:71). Digging down in the code we end up in the ExtendedURIResolver.resolve (line 42) that makes a call to resolve in org.apache.cxf.resource.URIResolver.resolve. This method totally ignores that my URI starts with 'http' it just assumes a JAR, CLASSPATH or FILESYSTEM path. This seems kind of silly? Any URL should be possible to resolve? If I change the baseUriStr (jar:file://) - removing the 'jar:' when debugging I can get it to work since then I end up in the tryFileSystem method which actually can resolve a HTTP URL, I'm thinking that this should be tried if JAR resolving fails? Or maybe even before JAR resolving? What do you think? Should I file this as an JIRA issues? I feel it's a bug, easy to fix as well, and would to get it fixed in the next release of CXF. Regards, Peter Peter Liljenberg TeliaSonera AB Software Architect, TSS-IT Channel Technologies Cell: +46 (0)703 790 793 e-mail: [EMAIL PROTECTED] - -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: Thrown by JAXB : undefined element declaration 's:schema'
It goes inside the schema element. Any schema that references another schema needs an import. On Fri, Apr 11, 2008 at 7:18 AM, Tim Perrett [EMAIL PROTECTED] wrote: Hey Guys, Thanks for the various replies on this - If i wanted to add s:import - what would I need to add to the WSDL file? Cheers Tim On 8 Apr 2008, at 21:31, Daniel Kulp wrote: Thus, to get it working for CXF, you would need to modify the schema to put the proper s:import in place to import the schema schema, then include the binding file to deal with the duplicate classes.
Re: Using cxf with external web-services
This interested me, as Im trying to get to grips with CXF. I just tried to put together a basic client (and even tried the WSDL below) but im getting odd problems when trying to run it. Even in its most simple form (very similar to the hello world on the wiki - http://cwiki.apache.org/CXF20DOC/developing-a-consumer.html ) I get this error: timperrett$ java com.timperrett.soap.temperature.App Starting... Exception in thread main java.lang.NoClassDefFoundError: javax/xml/ ws/Service at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:675) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:316) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java: 280) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java: 374) at com.timperrett.soap.temperature.App.main(App.java:31) Line 31 in my (extremely basic) application reads: 31: GlobalWeather weather = new GlobalWeather(); I have all the relevant imports etc but still no joy - any ideas? Cheers Tim On 11 Apr 2008, at 16:37, Daniel Kulp wrote: For the most part, you can just do: wsdl2java http://www.webservicex.net/globalweather.asmx?WSDL Then in your code, just do: GlobalWeather weather = new GlobalWeather(); GlobalWeatherSoap port = weather.getGlobalWeatherSoap(); String result = port.getWeather(city, country);
Re: [HelloWorld JavaScript client] problem on IE.
I fixed it. you'll need a new snapshot.
Re: [HelloWorld JavaScript client] problem on IE.
There's a new snapshot.
Re: Using cxf with external web-services
The jaxws-api jar is missing of the classpath somehow. That class comes from that jar. Dan On Friday 11 April 2008, Tim Perrett wrote: This interested me, as Im trying to get to grips with CXF. I just tried to put together a basic client (and even tried the WSDL below) but im getting odd problems when trying to run it. Even in its most simple form (very similar to the hello world on the wiki - http://cwiki.apache.org/CXF20DOC/developing-a-consumer.html ) I get this error: timperrett$ java com.timperrett.soap.temperature.App Starting... Exception in thread main java.lang.NoClassDefFoundError: javax/xml/ ws/Service at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:675) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124 ) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:316) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java: 280) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java: 374) at com.timperrett.soap.temperature.App.main(App.java:31) Line 31 in my (extremely basic) application reads: 31: GlobalWeather weather = new GlobalWeather(); I have all the relevant imports etc but still no joy - any ideas? Cheers Tim On 11 Apr 2008, at 16:37, Daniel Kulp wrote: For the most part, you can just do: wsdl2java http://www.webservicex.net/globalweather.asmx?WSDL Then in your code, just do: GlobalWeather weather = new GlobalWeather(); GlobalWeatherSoap port = weather.getGlobalWeatherSoap(); String result = port.getWeather(city, country); -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Unexpected EOF in prolog
I have an echo web service working when deployed to tomcat 5.5 and sending requests through soapUI. It seems to work great. But now I am trying to create a client via spring 2.5, and test this through testNG. *I keep getting this error when I create this client:* *!-- Web service dynamic proxy -- bean id=echoClient class=com.baselogic.service.EchoImpl factory-bean=echoClientFactory factory-method=create/ !-- Factory to create the dynamic proxy -- bean id=echoClientFactory class=org.apache.cxf.jaxws.JaxWsProxyFactoryBean property name=serviceClass value=com.baselogic.service.EchoService/ property name=address value= http://localhost:8080//cxf/EchoService/ property name=serviceFactory ref=jaxwsAndAegisServiceFactory/ /bean * *And here is my testNG test:* *@Test(groups = {functional}) public void testEcho() throws Exception { log.debug(testGetUser); try { Object echo1 = applicationContext.getBean(echoClient); log.debug(==); log.debug(StringUtil.toString(echo1.getClass())); log.debug(==); EchoService echo = (EchoService) applicationContext.getBean(echoClient); log.debug(==); log.debug(echo.echoString(this is a test)); //-- This lines throws the error log.debug(==); AssertJUnit.assertNotNull(echo.echoString(this is a test)); //AssertJUnit.assertEquals(mknutson, user.getUsername()); } catch (Exception e) { e.printStackTrace(); throw e; } } * *Here is my error:* * exception class=javax.xml.ws.soap.SOAPFaultException message ![CDATA[Error reading XMLStreamReader.]] /message full-stacktrace ![CDATA[javax.xml.ws.soap.SOAPFaultException: Error reading XMLStreamReader. at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:211) at $Proxy39.echoString(Unknown Source) at com.baselogic.service.UserServiceTest.testEcho(UserServiceTest.java:79) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580) at org.testng.internal.Invoker.invokeMethod(Invoker.java:478) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:607) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:874) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) at org.testng.TestRunner.runWorkers(TestRunner.java:689) at org.testng.TestRunner.privateRun(TestRunner.java:566) at org.testng.TestRunner.run(TestRunner.java:466) at org.testng.SuiteRunner.runTest(SuiteRunner.java:301) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:296) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:276) at org.testng.SuiteRunner.run(SuiteRunner.java:191) at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:808) at org.testng.TestNG.runSuitesLocally(TestNG.java:776) at org.testng.TestNG.run(TestNG.java:701) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:74) at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92) at org.apache.maven.surefire.Surefire.run(Surefire.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997) Caused by: 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:220) at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:429) at
Re: [CXF] deployment problems
Couple questions: 1) What version of CXF? 2) What deployment environment? Tomcat? 3) What's logged to the servers logs? Looking at the code, if res = msgFac.createMessage(); throws an exception, the return is null and nothing would get written out. It might be best to wrapper the exceptions with a WebServiceException or SOAPFaultException and throw that so the proper exception handling could occur. Another note: Instead of creating all the logger beans and the Bus bean and configuring all the interceptors and such, it's probably easier to just do: cxf:bus cxf:features cxf:logging/ /cxf:features /cxf:bus ns: xmlns:cxf=http://cxf.apache.org/core; spring validation info: http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd Certainly less verbose. :-) Dan On Friday 11 April 2008, Cencio wrote: Hi all, I have a provider implementation for a service, then i want deploy with a specified wsdl and every msg should call the invoke() method I deploy it and my specified wsdl if correctly displayed, but every msg sent to the service is threat as OneWay (an empty 200ok is sent every time... ) Here is the config: web.xml ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd; web-app context-param param-namecontextConfigLocation/param-name param-valueWEB-INF/beans.xml/param-value /context-param listener listener-class org.springframework.web.context.ContextLoaderListener /listener-class /listener servlet servlet-nameCXFServlet/servlet-name display-nameCXF Servlet/display-name servlet-class org.apache.cxf.transport.servlet.CXFServlet /servlet-class load-on-startup1/load-on-startup /servlet servlet-mapping servlet-nameCXFServlet/servlet-name url-pattern/*/url-pattern /servlet-mapping /web-app beans.xml beans xmlns=http://www.springframework.org/schema/beans; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:jaxws=http://cxf.apache.org/jaxws; xsi:schemaLocation= http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd; import resource=classpath:META-INF/cxf/cxf.xml / import resource=classpath:META-INF/cxf/cxf-extension-soap.xml / import resource=classpath:META-INF/cxf/cxf-servlet.xml / bean id=logInbound class=org.apache.cxf.interceptor.LoggingInInterceptor/ bean id=logOutbound class=org.apache.cxf.interceptor.LoggingOutInterceptor/ bean id=cxf class=org.apache.cxf.bus.CXFBusImpl property name=inInterceptors list ref bean=logInbound/ /list /property property name=outInterceptors list ref bean=logOutbound/ /list /property property name=outFaultInterceptors list ref bean=logOutbound/ /list /property /bean jaxws:endpoint id=ese6ordine serviceName=s:OrdineService implementor=isi.esercitazione.java2wsdl.Server address=/ordine xmlns:s=http://www.rivenditore.org/Ordine/ /beans isi.esercitazione.java2wsdl.Server package isi.esercitazione.java2wsdl; import javax.xml.soap.MessageFactory; @ServiceMode(value=Mode.MESSAGE) @WebServiceProvider(serviceName = OrdineService, portName = OrdineInterfaceEndpoint, targetNamespace = http://www.rivenditore.org/Ordine;, wsdlLocation = webapps/ese6/WEB-INF/ordini.wsdl) public class Server implements ProviderSOAPMessage{ public SOAPMessage invoke(SOAPMessage req){ SOAPMessage res = null; try{ MessageFactory msgFac = MessageFactory.newInstance(); res = msgFac.createMessage(); SOAPFactory soapFac = SOAPFactory.newInstance(); SOAPBodyElement esito = res.getSOAPBody().addBodyElement(soapFac.createName(esito, ele, http://www.rivenditore.org/ordiniElements;)); SOAPElement ok = esito.addChildElement(ok); SOAPElement id = ok.addChildElement(idOrdine); id.setTextContent(123456); SOAPElement totale = ok.addChildElement(totale); totale.setTextContent(123.45); totale.addAttribute(soapFac.createName(valuta), USD); } catch(SOAPException soapex){
Re: bi-directional relationships
Wow. This is neet. I didn't know about this one at all. I honestly though JAXB wouldn't do it. I learned something today. :-) Thanks Glen! Dan On Thursday 10 April 2008, Glen Mazza wrote: Here you go: https://jaxb.dev.java.net/guide/Mapping_cyclic_references_to_XML.html Glen Am Donnerstag, den 10.04.2008, 16:12 -0700 schrieb [EMAIL PROTECTED]: I'm using CXF 2.0.5. My Web Service is as follows: @WebService(endpointInterface = com.sybase.it.quoting.QuoteBroker, portName = QuoteBroker, targetNamespace = http://quoting.it.sybase.com;, name = QuoteBroker) @SOAPBinding(parameterStyle = ParameterStyle.WRAPPED, style = Style.DOCUMENT, use = Use.LITERAL) @Service(quoteBroker) public abstract class QuoteBrokerImpl implements QuoteBroker ... I am returning DTO's from my web service that are populated with data from my Hibernate objects. The problem that I am running into now is the following exception: INFO: Interceptor has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Marshalling Error: A cycle is detected in the object graph. This will cause infinitely deep XML: [EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED] This is due to the relationship that is defined. Quote - QuoteLineItem - Quote Because the relationship is bi-directional I am seeing this exception occurring. The Web Service is a replacement of an old Axis 1.0 RPC/Encoded web service. Now that I have it running with CXF using Document/Literal/Wrapped I am seeing this issue. How have others resolved/worked around this issue? Thanks... Chris Mathrusse [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: bi-directional relationships
I've started playing with this and it seems to work correctly. (More testing needed) But one issue I came across was in the generated Client objects. My server side object looks as follows: public class QuoteDTO { @XmlAttribute @XmlIDREF protected CustomerDTO customer; But my generated Client object looks as follows: public class QuoteDTO { @XmlAttribute @XmlIDREF protected Object customer; So now when my client attempts to access the customer the specific data type is lost. Is there any work around for this? Thanks... Chris Mathrusse [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 Daniel Kulp [EMAIL PROTECTED] 04/11/2008 12:44 PM Please respond to cxf-user@incubator.apache.org To cxf-user@incubator.apache.org cc Subject Re: bi-directional relationships Wow. This is neet. I didn't know about this one at all. I honestly though JAXB wouldn't do it. I learned something today. :-) Thanks Glen! Dan On Thursday 10 April 2008, Glen Mazza wrote: Here you go: https://jaxb.dev.java.net/guide/Mapping_cyclic_references_to_XML.html Glen Am Donnerstag, den 10.04.2008, 16:12 -0700 schrieb [EMAIL PROTECTED]: I'm using CXF 2.0.5. My Web Service is as follows: @WebService(endpointInterface = com.sybase.it.quoting.QuoteBroker, portName = QuoteBroker, targetNamespace = http://quoting.it.sybase.com;, name = QuoteBroker) @SOAPBinding(parameterStyle = ParameterStyle.WRAPPED, style = Style.DOCUMENT, use = Use.LITERAL) @Service(quoteBroker) public abstract class QuoteBrokerImpl implements QuoteBroker ... I am returning DTO's from my web service that are populated with data from my Hibernate objects. The problem that I am running into now is the following exception: INFO: Interceptor has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Marshalling Error: A cycle is detected in the object graph. This will cause infinitely deep XML: [EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED] This is due to the relationship that is defined. Quote - QuoteLineItem - Quote Because the relationship is bi-directional I am seeing this exception occurring. The Web Service is a replacement of an old Axis 1.0 RPC/Encoded web service. Now that I have it running with CXF using Document/Literal/Wrapped I am seeing this issue. How have others resolved/worked around this issue? Thanks... Chris Mathrusse [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: NPE org.apache.cxf.attachment.AttachmentSerializer.writeAttachments
Christoph, How is the attachment constructed? Is this something that is a byte[] in the jaxb beans or is it an Image or a DataHandler or what? That may help narrow down that cause a bit. All we do is iterator over the attachments, write out the mime headers, then call: att.getDataHandler().writeTo(out); Also, what version of activation are you using? Assuming the latest geronimo-specs activation jar, from that stack trace, line 90 is: is.close() Thus, an NPE would occur there if getInputStream() returns null which would occur if: ds.getInputStream(); returns null. Thus, I guess I'd need to know what the DataSource is. Dan On Friday 11 April 2008, [EMAIL PROTECTED] wrote: Hi List, I'm relatively new to Apache CXF and managed to implement a Webservice using JAX-WS which returns MTOM attachments. My service connects to a Webserver and gets the content of the MTOM attachment by reading a Java HTTPConnection. Sometimes there seems to be no content in the HTTPConnection inputStream, so I implemented a check for this case which throws an exception. At a first glance everything is ok but when I do some load test with SoapUI I get this exception in the tomcat log: java.lang.NullPointerException at javax.activation.DataHandler.writeTo(DataHandler.java:90) at org.apache.cxf.attachment.AttachmentSerializer.writeAttachments(Attach mentSerializer.java:129) at org.apache.cxf.interceptor.AttachmentOutInterceptor$AttachmentOutEndin gInterceptor.handleMessage(AttachmentOutInterceptor.java:77) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto rChain.java:220) at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(Outg oingChainInterceptor.java:74) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto rChain.java:220) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitia tionObserver.java:77) at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDest ination.java:92) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(S ervletController.java:213) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletContr oller.java:150) at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXF Servlet.java:170) at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXF Servlet.java:148) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli cationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi lterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVa lve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextVa lve.java:174) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticat orBase.java:525) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.ja va:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.ja va:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValv e.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java :174) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java: 874) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.pr ocessConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoi nt.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFoll owerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPo ol.java:689) at java.lang.Thread.run(Thread.java:595) 11.04.2008 16:18:33 org.apache.cxf.phase.PhaseInterceptorChain doIntercept INFO: Interceptor has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Error writing to XMLStreamWriter. at org.apache.cxf.binding.soap.interceptor.Soap11FaultOutInterceptor.hand leMessage(Soap11FaultOutInterceptor.java:140) at org.apache.cxf.binding.soap.interceptor.Soap11FaultOutInterceptor.hand leMessage(Soap11FaultOutInterceptor.java:43) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto rChain.java:220) at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessa ge(AbstractFaultChainInitiatorObserver.java:96) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto rChain.java:254) at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(Outg oingChainInterceptor.java:74) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto rChain.java:220) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitia tionObserver.java:77) at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDest
Re: JiBX and CXF
No one really ended up with having the time to implement it. :-( Unfortunately, it hasn't really been a priority for me as none of IONA's paying customers have even asked for it at all. (plus, the fact many of us have never even used JiBX at all doesn't help)Even the xmlbeans support is limitted right now. I started working on it when there was some interest, but the interested party changed to JAXB and I never really had time to go back and do the tooling side of things as other priorities kept popping up. That said, if you are interested in working on it, I'd be more than happy to help be a mentor. Getting basic runtime support working is probably not very hard since JiBX has stax API's already. (if I remember correctly) Tooling might be trickier as the only data model we have in the tooling right now is jaxb so I'm not sure how abstracted out it is yet. (From experience, if code supposedly supports N plugins, if N==1, there is usually something that was forgotten or not properly abstracted to fully support the N1 case.) Dan On Thursday 10 April 2008, ron_honeyman wrote: I noticed on the CXF Roadmap (http://cwiki.apache.org/confluence/display/CXF/Roadmap) page it references JiBX and the possiblility that it may be in version 2.1 or may slip to version 2.2. I was curious if anyone could tell me if it has been included with 2.1 or not? If it has is there any documentation I could look at for integrating with it. Thanks Ron Honeyman -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: Problem with CXF WAS Deployment
Just fyi, I finally managed to get tomcat running from a dir with spaces in it (had to hack the catalina.sh script a bit) and it seems to work fine with the latest CXF code. I deployed a bunch of wars with wsdl's and imports and such and they all seemed to work. Dan On Wednesday 09 April 2008, Daniel Kulp wrote: Any chance you can try with CXF 2.0.5? I know I fixed a BUNCH of issues with URL's with spaces in them a little while ago. It MAY have been for 2.0.4, but definitely 2.0.5. Meanwhile, I'll try testing some stuff here. I cannot even get tomcat to start from a dir with a space in it to test this. :-( Dan On Wednesday 09 April 2008, Bharath Thippireddy wrote: Hi Dan, We could see the root cause for this issue.It happens only when the App Server is installed in a folder path which has a space(in any of the folder names).We tried it on JBoss which resulted in the same exception. 1) What version of CXF? We are using CXF 2.0.3 wsdl location is WEB-INF/wsdl/Auth.wsdl 2) What are you using for the wsdlLocation? (WEB-INF/foo.wsdl, or just foo.wsdl, or) We use the cxf-servlet.xml file for the configuration. 3)How are you configuring the wsdl location? (@WebService annotation, in a xml config file, etc..) Can you please let me know how this can be resolved while having spaces in the foder names. thanks and regards, Bharath Daniel Kulp [EMAIL PROTECTED] wrote on 04/09/2008 04:08:34 PM: Couple questions: 1) What version of CXF? 2) What are you using for the wsdlLocation? (WEB-INF/foo.wsdl, or just foo.wsdl, or) 3) How are you configuring the wsdl location? (@WebService annotation, in a xml config file, etc..) Dan On Tuesday 08 April 2008, bharath_t19 wrote: We are trying to deploy our CXF application on WebSphere 6.1 and we see the following problem ServletWrappe E SRVE0100E: Did not realize init() exception thrown by servlet cxf: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AuthenticationService': Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError Caused by: java.lang.IncompatibleClassChangeError at org.apache.cxf.wsdl11.WSDLServiceBuilder.copyExtensionAttributes (W SDLS erviceBuilder.java:117) at org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServi ce Buil der.java:218) at org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServi ce Buil der.java:150) at org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFacto ry .jav a:117) This was fixed by following the instruction in the CXF App Server Guide. But now we see the following exception.Looks like its seaching the XSDs in the server root folder instead of searching for them relative to the wsdl files.All the wsdl files are under the web-inf folder of the webapplication and the XSDs imported in the WSDLs go in to the same directory.We see the same exception when we try both the options in the App Server Guide. 1)put jar in the endorsed folder 2)Add your own class loader 0018 ServletWrappe E SRVE0100E: Did not realize init() exception thrown by servlet cxf: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AuthenticationService': Invocation of init method failed; nested exception is org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service. Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service. at org.apache.cxf.wsdl11.WSDLServiceFactory.init(WSDLServiceFacto ry .jav a:83) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buil dS ervi ceFromWSDL(ReflectionServiceFactoryBean.java:256) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.init ia lize ServiceModel(ReflectionServiceFactoryBean.java:331) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.crea te (Ref lectionServiceFactoryBean.java:151) at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxW sS ervi ceFactoryBean.java:93) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createE nd poin t(AbstractWSDLBasedEndpointFactory.java:74) at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBe an .jav a:108) at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFa ct oryB ean.java:147) at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:28 8) at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:22 8) at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:179) at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:341) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Re: bi-directional relationships
I've begun to play with this type of implementation, using the @XmlIDREF and @XmlAttribute annotations and I've found a few issues. 1) As stated below, your client generated classes have the references to parent objects defined as data type Object. (an annoyance but workable) 2) As stated in the documentation: You'd also need to ensure that the referenced objects are contained somewhere else (like in the Root class in this case), or else Bar objects will never be marshalled. This one is difficult. I have a parent class that I return from my Services methods that contain all the information associated to the user and the request: UserAcct - Quote - SalesResp When this gets returned to the client the objects are just as the server sent them back. But when I send a child object back over to the server all the references to the parents are lost. Example: addSalesRep(SalesRepDTO salesRep) { ... The SalesRep object no longer has the parent Quote. That is because the original container no longer exists. I would need to define a new contain to be used to hold the object structure. I've tried several things to get around this, like placing a @XmlRootElement on my SalesRepDTO class on both the server and client classes but to no avail. There just doesn't seem to be a way to make this work how I would expect it to. The references to the parents are always lost when sending the objects from the client to the server. Any suggestions? Chris Mathrusse [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 [EMAIL PROTECTED] 04/11/2008 12:50 PM Please respond to cxf-user@incubator.apache.org To cxf-user@incubator.apache.org cc Subject Re: bi-directional relationships I've started playing with this and it seems to work correctly. (More testing needed) But one issue I came across was in the generated Client objects. My server side object looks as follows: public class QuoteDTO { @XmlAttribute @XmlIDREF protected CustomerDTO customer; But my generated Client object looks as follows: public class QuoteDTO { @XmlAttribute @XmlIDREF protected Object customer; So now when my client attempts to access the customer the specific data type is lost. Is there any work around for this? Thanks... Chris Mathrusse [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 Daniel Kulp [EMAIL PROTECTED] 04/11/2008 12:44 PM Please respond to cxf-user@incubator.apache.org To cxf-user@incubator.apache.org cc Subject Re: bi-directional relationships Wow. This is neet. I didn't know about this one at all. I honestly though JAXB wouldn't do it. I learned something today. :-) Thanks Glen! Dan On Thursday 10 April 2008, Glen Mazza wrote: Here you go: https://jaxb.dev.java.net/guide/Mapping_cyclic_references_to_XML.html Glen Am Donnerstag, den 10.04.2008, 16:12 -0700 schrieb [EMAIL PROTECTED]: I'm using CXF 2.0.5. My Web Service is as follows: @WebService(endpointInterface = com.sybase.it.quoting.QuoteBroker, portName = QuoteBroker, targetNamespace = http://quoting.it.sybase.com;, name = QuoteBroker) @SOAPBinding(parameterStyle = ParameterStyle.WRAPPED, style = Style.DOCUMENT, use = Use.LITERAL) @Service(quoteBroker) public abstract class QuoteBrokerImpl implements QuoteBroker ... I am returning DTO's from my web service that are populated with data from my Hibernate objects. The problem that I am running into now is the following exception: INFO: Interceptor has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Marshalling Error: A cycle is detected in the object graph. This will cause infinitely deep XML: [EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED] This is due to the relationship that is defined. Quote - QuoteLineItem - Quote Because the relationship is bi-directional I am seeing this exception occurring. The Web Service is a replacement of an old Axis 1.0 RPC/Encoded web service. Now that I have it running with CXF using Document/Literal/Wrapped I am seeing this issue. How have others resolved/worked around this issue? Thanks... Chris Mathrusse [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: bi-directional relationships
Chris, for advanced JAXB questions, you might just want to go ahead and ask on the Sun forum[1]. We use their JAXB, and the JAXB specialists tend to congregate on that site. Regards, Glen [1] http://forums.java.net/jive/forum.jspa?forumID=46 Am Freitag, den 11.04.2008, 14:33 -0700 schrieb [EMAIL PROTECTED]: I've begun to play with this type of implementation, using the @XmlIDREF and @XmlAttribute annotations and I've found a few issues. 1) As stated below, your client generated classes have the references to parent objects defined as data type Object. (an annoyance but workable) 2) As stated in the documentation: You'd also need to ensure that the referenced objects are contained somewhere else (like in the Root class in this case), or else Bar objects will never be marshalled. This one is difficult. I have a parent class that I return from my Services methods that contain all the information associated to the user and the request: UserAcct - Quote - SalesResp When this gets returned to the client the objects are just as the server sent them back. But when I send a child object back over to the server all the references to the parents are lost. Example: addSalesRep(SalesRepDTO salesRep) { ... The SalesRep object no longer has the parent Quote. That is because the original container no longer exists. I would need to define a new contain to be used to hold the object structure. I've tried several things to get around this, like placing a @XmlRootElement on my SalesRepDTO class on both the server and client classes but to no avail. There just doesn't seem to be a way to make this work how I would expect it to. The references to the parents are always lost when sending the objects from the client to the server. Any suggestions? Chris Mathrusse [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 [EMAIL PROTECTED] 04/11/2008 12:50 PM Please respond to cxf-user@incubator.apache.org To cxf-user@incubator.apache.org cc Subject Re: bi-directional relationships I've started playing with this and it seems to work correctly. (More testing needed) But one issue I came across was in the generated Client objects. My server side object looks as follows: public class QuoteDTO { @XmlAttribute @XmlIDREF protected CustomerDTO customer; But my generated Client object looks as follows: public class QuoteDTO { @XmlAttribute @XmlIDREF protected Object customer; So now when my client attempts to access the customer the specific data type is lost. Is there any work around for this? Thanks... Chris Mathrusse [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553 Daniel Kulp [EMAIL PROTECTED] 04/11/2008 12:44 PM Please respond to cxf-user@incubator.apache.org To cxf-user@incubator.apache.org cc Subject Re: bi-directional relationships Wow. This is neet. I didn't know about this one at all. I honestly though JAXB wouldn't do it. I learned something today. :-) Thanks Glen! Dan On Thursday 10 April 2008, Glen Mazza wrote: Here you go: https://jaxb.dev.java.net/guide/Mapping_cyclic_references_to_XML.html Glen Am Donnerstag, den 10.04.2008, 16:12 -0700 schrieb [EMAIL PROTECTED]: I'm using CXF 2.0.5. My Web Service is as follows: @WebService(endpointInterface = com.sybase.it.quoting.QuoteBroker, portName = QuoteBroker, targetNamespace = http://quoting.it.sybase.com;, name = QuoteBroker) @SOAPBinding(parameterStyle = ParameterStyle.WRAPPED, style = Style.DOCUMENT, use = Use.LITERAL) @Service(quoteBroker) public abstract class QuoteBrokerImpl implements QuoteBroker ... I am returning DTO's from my web service that are populated with data from my Hibernate objects. The problem that I am running into now is the following exception: INFO: Interceptor has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Marshalling Error: A cycle is detected in the object graph. This will cause infinitely deep XML: [EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED] This is due to the relationship that is defined. Quote - QuoteLineItem - Quote Because the relationship is bi-directional I am seeing this exception occurring. The Web Service is a replacement of an old Axis 1.0 RPC/Encoded web service. Now that I have it running with CXF using Document/Literal/Wrapped I am seeing this issue. How have others resolved/worked around this issue? Thanks... Chris Mathrusse [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA 94568 (925) 236-5553
Re: Using cxf with external web-services
Perhaps my client example may help you: http://www.jroller.com/gmazza/date/20070929 Glen Am Freitag, den 11.04.2008, 18:21 +0100 schrieb Tim Perrett: This interested me, as Im trying to get to grips with CXF. I just tried to put together a basic client (and even tried the WSDL below) but im getting odd problems when trying to run it. Even in its most simple form (very similar to the hello world on the wiki - http://cwiki.apache.org/CXF20DOC/developing-a-consumer.html ) I get this error: timperrett$ java com.timperrett.soap.temperature.App Starting... Exception in thread main java.lang.NoClassDefFoundError: javax/xml/ ws/Service at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:675) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:316) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java: 280) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java: 374) at com.timperrett.soap.temperature.App.main(App.java:31) Line 31 in my (extremely basic) application reads: 31: GlobalWeather weather = new GlobalWeather(); I have all the relevant imports etc but still no joy - any ideas? Cheers Tim On 11 Apr 2008, at 16:37, Daniel Kulp wrote: For the most part, you can just do: wsdl2java http://www.webservicex.net/globalweather.asmx?WSDL Then in your code, just do: GlobalWeather weather = new GlobalWeather(); GlobalWeatherSoap port = weather.getGlobalWeatherSoap(); String result = port.getWeather(city, country);
Re: Unexpected EOF in prolog
I don't know what version of CXF you're using but 2.0.5 has some changes that *might* reduce the number of com.ctc.wstx.exc.WstxEOFExceptions you will be getting, and hopefully provide you a more useful error message: http://www.jroller.com/gmazza/date/20080327 HTH, Glen Am Freitag, den 11.04.2008, 10:26 -0800 schrieb Mick Knutson: I have an echo web service working when deployed to tomcat 5.5 and sending requests through soapUI. It seems to work great. But now I am trying to create a client via spring 2.5, and test this through testNG. *I keep getting this error when I create this client:* *!-- Web service dynamic proxy -- bean id=echoClient class=com.baselogic.service.EchoImpl factory-bean=echoClientFactory factory-method=create/ !-- Factory to create the dynamic proxy -- bean id=echoClientFactory class=org.apache.cxf.jaxws.JaxWsProxyFactoryBean property name=serviceClass value=com.baselogic.service.EchoService/ property name=address value= http://localhost:8080//cxf/EchoService/ property name=serviceFactory ref=jaxwsAndAegisServiceFactory/ /bean * *And here is my testNG test:* *@Test(groups = {functional}) public void testEcho() throws Exception { log.debug(testGetUser); try { Object echo1 = applicationContext.getBean(echoClient); log.debug(==); log.debug(StringUtil.toString(echo1.getClass())); log.debug(==); EchoService echo = (EchoService) applicationContext.getBean(echoClient); log.debug(==); log.debug(echo.echoString(this is a test)); //-- This lines throws the error log.debug(==); AssertJUnit.assertNotNull(echo.echoString(this is a test)); //AssertJUnit.assertEquals(mknutson, user.getUsername()); } catch (Exception e) { e.printStackTrace(); throw e; } } * *Here is my error:* * exception class=javax.xml.ws.soap.SOAPFaultException message ![CDATA[Error reading XMLStreamReader.]] /message full-stacktrace ![CDATA[javax.xml.ws.soap.SOAPFaultException: Error reading XMLStreamReader. at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:211) at $Proxy39.echoString(Unknown Source) at com.baselogic.service.UserServiceTest.testEcho(UserServiceTest.java:79) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580) at org.testng.internal.Invoker.invokeMethod(Invoker.java:478) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:607) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:874) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) at org.testng.TestRunner.runWorkers(TestRunner.java:689) at org.testng.TestRunner.privateRun(TestRunner.java:566) at org.testng.TestRunner.run(TestRunner.java:466) at org.testng.SuiteRunner.runTest(SuiteRunner.java:301) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:296) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:276) at org.testng.SuiteRunner.run(SuiteRunner.java:191) at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:808) at org.testng.TestNG.runSuitesLocally(TestNG.java:776) at org.testng.TestNG.run(TestNG.java:701) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:74) at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92) at org.apache.maven.surefire.Surefire.run(Surefire.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997) Caused by: org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader. at
Re: Transfer-encoding chunked
If you have followed the instructions in the paragraph starting with The first thing to notice is... on [1] closely in order to come up with the exact name, and it still doesn't work, then possibly we have a CXF bug. It can be tricky to get right. Glen [1] http://cwiki.apache.org/CXF20DOC/client-http-transport-including-ssl-support.html Am Donnerstag, den 10.04.2008, 05:32 -0700 schrieb gbuys: OK, using wildcard *.http-conduit as the conduit name did the trick. I still don't see why the specified name doesn't work though... gbuys wrote: Hi All, I'm having an issue calling a webservice on MS IIS from JBoss 4.2.2 with Apache CXF 2.0.4 client deployed in a Spring application. The deployed service doesn't seem to support client calls from JBoss with Transfer-encoding chunked in the request header. Sometimes the service system gives a response but most of the time it hangs or returns an error message. I've deployed exactly the same client code (generated with soapUI using CXF 2.0.4.-incubator) in a stand alone program in Eclipse. This program sends requests to the service with a content-length specified in the request header. This works perfectly well, the IIS server quickly responds and remains stable. So it appears to me that JBoss is actually responsible for putting the 'Transfer-encoding chunked' in the header. How can I reconfigure my JBoss to send requests with fixed content length. As a matter of fact, I think I should configure that only the web service requests have content-length specified. All other requests/responses should remain chunked. Or do I have to configure CXF or change my service client code to force the requests having a content-length header? I did some experiments with a cxf.xml in my classpath without succes (ip address replaced with x's): beans xmlns=http://www.springframework.org/schema/beans; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:http-conf=http://cxf.apache.org/transports/http/configuration; xsi:schemaLocation=http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd; http-conf:conduit name={http://xx.xx.xx.xx/Webservice_Server/}Webservice_Server.http-conduit; http-conf:client AllowChunking=false/ /http-conf:conduit http-conf:conduit name={http://localhost:8080/axis2/services/}Version.http-conduit; http-conf:client AllowChunking=false/ /http-conf:conduit /beans Any help is greatly appreciated! (Of course, the guys on the web service side should find out why their IIS becomes unstable, but i'd like to find out what i can change on the client side as well...)