Re: How to develop a WebServiceClient correctly?
There was just one missing line that separated me from enlightenment. ;) requestContext.put(MessageContext.HTTP_REQUEST_HEADERS, requestHeaders); I forgot to put the requestHeaders back into the requestContext... Maybe I need a little break. Thank you for help! -- View this message in context: http://www.nabble.com/How-to-develop-a-WebServiceClient-correctly--tp16741038p16804879.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: Does JavaToWSDL support generics ?
Dan, The original post was the output of CXF v2.0.5. When trying with CXF v2.1-incubator-snapshot of 2008-04-15, the getAllCarsResponse remains a sequence without any reference to the Car element: xsd:element name=getAllCarsResponse type=tns:getAllCarsResponse/xsd:complexType name=getAllCarsResponsexsd:sequencexsd:element maxOccurs=unbounded minOccurs=0 name=return//xsd:sequence/xsd:complexType I've tried with 2 other methods that do not use generics, but in both cases the generated WSDL does not contain a reference to the Car element. Java method: public Car[] getAllCarsAsArray(); Generated WSDL: xsd:element name=getAllCarsAsArrayResponse type=tns:getAllCarsAsArrayResponse/xsd:complexType name=getAllCarsAsArrayResponsexsd:sequencexsd:element maxOccurs=unbounded minOccurs=0 name=return//xsd:sequence/xsd:complexType Java method: public Car getOneCar(); Generated WSDL: xsd:element name=getOneCar type=tns:getOneCar/xsd:complexType name=getOneCarxsd:sequence//xsd:complexType Regards, Stefan Lecho. dkulp wrote: What version of CXF? That should definitely be working. Dan On Thursday 17 April 2008, stlecho wrote: Hi, I would like to generate a WSDL for the following method: public ListCar getAllCars();. In the generated WSDL I expect to have something similar to 'xs:element name=getAllCarsResponsexs:complexTypexs:sequencexs:element minOccurs=0 name=return nillable=true type=xxx:Car//xs:sequence/xs:complexType/xs:element'. When using JavaToWSDL, the generated WSDL contains 'xsd:element name=getAllCars type=tns:getAllCars /xsd:complexType name=getAllCarsxsd:sequence //xsd:complexTypexsd:element name=getAllCarsResponse type=tns:getAllCarsResponse /xsd:complexType name=getAllCarsResponsexsd:sequencexsd:element maxOccurs=unbounded minOccurs=0 name=return //xsd:sequence/xsd:complexType'. There is no reference to the 'Car' element :o(. Based on this experience I was wondering if JavaToWSDL supports generics or should I specify an additional parameter to generate a reference to the 'Car' element in the 'getAllCarsResponse' element ? Regards, Stefan Lecho. -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog -- View this message in context: http://www.nabble.com/Does-JavaToWSDL-support-generics---tp16743152p16804887.html Sent from the cxf-user mailing list archive at Nabble.com.
unsubscribe
Re: How to use wsdl2js output?
One of the IONA folks did a video podcast thing that shows how to use the js stuff to access services from an iPhone: http://open.iona.com/wiki/display/ProdInfo/FMCS+No.+3+-+Accelerate+Web+Development+on+the+iPhone+-+Roland+Tritsch That might provide another useful starting point. Dan On Sunday 20 April 2008, Tim Perrett wrote: Hey chaps, Just having a play around with the wsdl2js stuff in 2.1 snapshot. I've generated a tester service based on http://webservices.daelab.net/temperatureconversions/TemperatureConver sions.wso?WSDL but Im not sure how to use that outputed JS file? All the prototype classes are in there, but I cant see which one I would need to call? Has anyone got any advice? Cheers Tim -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: problem serializing class hierarchy
As Ian mentioned, this is quite a bit easier with JAXWS/JAXB 2.1. With the 2.1 snapshots, you can add @XmlSeeAlso(FooBar.class) to the IFake interface or to the Foo object to allow the runtime to know that the FooBar class should also be added to the JAXBContext. Alternatively, for CXF 2.0.5 and 2.1, if Foo.java and FooBar.java are in the same package, you can add a file called jaxb.index to the package that just contains a single line: FooBar (don't put a package qualifier there as the jaxb.index only loades classes from the same package) The JAXB databinding will pick that up and load those classes as well. Dan On Sunday 20 April 2008, Rafael Ribeiro wrote: Hi all, I have an webmethod that returns an arbitrary class. The problem is, on some of its executions it might return some subclass of the class that is expressed on the method signature. Instead of getting the actual class that was serialized from the webservice the client is getting the class that is expressed on the method. Do I have to specify anything on the classes that I need to serialize or on the method in order for it to correct serialize the expected class? I am sending a sample I did to reproduce the problem described above (it is deployed on tomcat using CXFNonSpringServlet and service is registered using an startupservlet): IFake.java - package fake; import javax.jws.WebService; @WebService public interface IFake { public Foo fooOp(); } FakeImpl.java - package fake; public class FakeImpl implements IFake { public Foo fooOp() { return new FooBar(); } } FakeCli.java - import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import fake.IFake; public class FakeCli { private static IFake fakeClient; public static void main(String[] args) { System.out.println(getFakeClient().fooOp()); } public static IFake getFakeClient() { if (fakeClient == null) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(IFake.class); factory .setAddress( http://localhost:8080/mywebapp/services/fake;); fakeClient = (IFake) factory.create(); } return fakeClient; } } Foo.java - package fake; public class Foo { private String foo; public String getFoo() { return foo; } public void setFoo(String foo) { this.foo = foo; } } FooBar.java - package fake; public class FooBar extends Foo { private String fooBar; public String getFooBar() { return fooBar; } public void setFooBar(String fooBar) { this.fooBar = fooBar; } } -- -- This webservice is registered by this call on the startupservlet: Endpoint.publish(/fake, new FakeImpl()); and the result of the execution of FakeCli is something like: [EMAIL PROTECTED] If I try to cast it to FooBar I get a ClassCastException, as expected since this class was really instantiated as Foo instead of FooBar -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: Does JavaToWSDL support generics ?
Ian, Unfortunately, Car is an interface and not a concrete class. Regards, Stefan Lecho. ianroberts wrote: stlecho wrote: Hi, I would like to generate a WSDL for the following method: public ListCar getAllCars();. This should work as you expect, so long as Car is a concrete class and not an interface. If it's an interface things get more difficult, but if you search for interface in the list archives you should find several threads to help. Ian -- Ian Roberts | Department of Computer Science [EMAIL PROTECTED] | University of Sheffield, UK -- View this message in context: http://www.nabble.com/Does-JavaToWSDL-support-generics---tp16743152p16807958.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: Does JavaToWSDL support generics ?
On Monday 21 April 2008, stlecho wrote: Ian, Unfortunately, Car is an interface and not a concrete class. Yea, that would be the issue. JAXB doesn't support interfaces directly, just concrete beans. To get this to work, you would need to write an XmlJavaTypeAdapter to convert the Car objects to a concrete CarImpl or something that JAXB can deal with. That said, I think that will only work with 2.1. We actually have a sample that shows the TypeAdapters in the 2.1 kits in the sample/java_first_jaxws directory. Dan Regards, Stefan Lecho. ianroberts wrote: stlecho wrote: Hi, I would like to generate a WSDL for the following method: public ListCar getAllCars();. This should work as you expect, so long as Car is a concrete class and not an interface. If it's an interface things get more difficult, but if you search for interface in the list archives you should find several threads to help. Ian -- Ian Roberts | Department of Computer Science [EMAIL PROTECTED] | University of Sheffield, UK -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: Using HTTPClient as a transport
Hello, I am a trying to use HTTPClient to send request i CXF HTTP transport. I have implemented the Conduit API with HTTPClient but i don't understand how do i configure CXF to use my implementation. Can anyone help me? Thanks, Paulo Ramos -- View this message in context: http://www.nabble.com/Using-HTTPClient-as-a-transport-tp14715325p16807978.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: REST-JS
Hi Jervis I'm sorry for replying so late... The idea behind ?_js or ?_lang=js is not to indicate to the runtime that the invocation is coming from a JS client stack but to provide on the fly generation of the client execution code (JS in this case), similar to what Benson did for JAX-WS services. Such execution fragment can then be embedded into XHTML pages, etc. Perhaps a better option would be to support .js extensions, something like GET /customer.js Either way, CXF JAX-RS impl supports handlers which can be invoked before the invocation is made on the actual resource class. These handlers need some minor cleanup, but as far as the generation of such JS client code is concerned, it would be a matter implementing a handler capable of looking at a ClassResourceInfo (the model class you created originally) and returning a JAX-RS Response with its entity being the generated (JS) code... Cheers, Sergey - Original Message - From: Jervis Liu [EMAIL PROTECTED] To: cxf-user@incubator.apache.org Sent: Monday, March 24, 2008 3:14 AM Subject: Re: REST-JS Hi Sergey, could you elaborate a bit more on the ?_js or ?_lang=js stuff please. I thought what Benson and Arul were talking about is a pure client stack that is implemented in Java script that can connect to JAX-RS compatible RESTful services. As far as the JAX-RS server side is concerned, it does not matter the request is coming from a java script client or anything else, does it? IONA Technologies PLC (registered in Ireland) Registered Number: 171387 Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
Re: Problem when trying to test JAX-RS service
Arul, thanks for the pointer. I have upgraded to the latest snapshot of 2.1 but still get the same issue. Brad. On Mon, Apr 21, 2008 at 4:12 PM, Arul Dhesiaseelan [EMAIL PROTECTED] wrote: I think JAX-RS (JSR 311) support is available only in 2.1. Brad wrote: Hi, I'm trying to test out the JAX-RS support in cxf-2.0.5 by adapting the Spring based example at http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html. My beans.xml file is shown here: ?xml version=1.0 encoding=UTF-8? beans xmlns=http://www.springframework.org/schema/beans; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:jaxrs=http://cxf.apache.org/jaxrs; xsi:schemaLocation=http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/jaxrs C:\workspace\eclipse33\cxf_REST_Web\WebContent\WEB-INF\schema\jaxrs.xsd import resource=cxf.xml / import resource=cxf-extension-jaxrs-binding.xml / import resource=cxf-servlet.xml / jaxrs:server id=audit address=/audit jaxrs:serviceBeans bean class=test.rest.TestImpl/ /jaxrs:serviceBeans /jaxrs:server /beans This gives me the following error: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://cxf.apache.org/jaxrs] I tried googling this and got one result for something similar which seemed to be suggesting that I'm missing a JAR file (possibly comtaining a missing handler class for the given namespace?) Am I on the right track there? All help gratefully received. Thanks, Brad. _ Scanned by MessageLabs for the Super Flux Friends _
Re: Problem when trying to test JAX-RS service
This entry might be a problem : http://cxf.apache.org/jaxrs C:\workspace\eclipse33\cxf_REST_Web\WebContent\WEB-INF\schema\jaxrs.xsd There's a spring.schemas file wich matches the http://cxf.apache.org/schemas/jaxrs.xsd location to the local class resource schemas/jaxrs.xsd, so please try http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd; Cheers, Sergey IONA Technologies PLC (registered in Ireland) Registered Number: 171387 Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
Re: Using HTTPClient as a transport
On Monday 21 April 2008, Paulo Ramos wrote: I am a trying to use HTTPClient to send request i CXF HTTP transport. I have implemented the Conduit API with HTTPClient but i don't understand how do i configure CXF to use my implementation. Can anyone help me? You'll want to create two files: 1) META-INF/cxf/cxf.extension This file would just contain the line: META-INF/cxf/cxf-extension-http-commons.xml which points to file #2: 2) META-INF/cxf/cxf-extension-http-commons.xml Is a spring module that would look something like: beans xmlns=http://www.springframework.org/schema/beans; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:foo=http://cxf.apache.org/configuration/foo; xsi:schemaLocation= http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd; import resource=classpath:META-INF/cxf/cxf-extension-http.xml / bean class=org.apache.cxf.transport.http_commons.CommonsHTTPTransportFactory id=org.apache.cxf.transport.http_commons.CommonsHTTPTransportFactory lazy-init=false depends-on=org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory property name=bus ref=cxf/ property name=transportIds list valuehttp://schemas.xmlsoap.org/soap/http/value valuehttp://schemas.xmlsoap.org/wsdl/http//value valuehttp://schemas.xmlsoap.org/wsdl/soap/http/value valuehttp://www.w3.org/2003/05/soap/bindings/HTTP//value valuehttp://cxf.apache.org/transports/http/configuration/value valuehttp://cxf.apache.org/bindings/xformat/value /list /property /bean /beans What that file does it forces your bean to be created/registered after the standard one we have in CXF. Your TransportFactory would then have a @PostConstruct method that would register your factory with the bus's ConduitInitiatorManager. Since you would be called after the standard ClientOnlyHTTPTransport, you would overwrite what it registers and your Conduit stuff would be called. -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
CXF WS-Addressing
Hi all, I am converting the ws-addressing sample in cxf 2.0.5 to a servlet version. When I deploy and run, I am getting the following error. I checked CXF users guide on how to configure WS-Addressing but it doesn't help. I included the build.xml and cxf-servlet.xml that I used to create the war file. Am I misising some configuration on the server side? SteveWu client-servlet: [java] URL===http://localhost:8080/helloworldaddr/services/hello_world_addr?wsdl [java] Invoking sayHi... [java] Apr 21, 2008 1:14:13 PM org.apache.cxf.ws.addressing.soap.MAPCodec encode [java] INFO: Outbound WS-Addressing headers [java] Apr 21, 2008 1:14:13 PM org.apache.cxf.ws.addressing.soap.MAPCodec encodeAsExposed [java] INFO: MessageID : urn:uuid:ddd32553-8aa0-4ed9-88f3-0b809bd0d4eb [java] Apr 21, 2008 1:14:13 PM org.apache.cxf.ws.addressing.soap.MAPCodec encodeAsExposed [java] INFO: To : http://localhost:9050/SoapContext/SoapPort [java] Apr 21, 2008 1:14:13 PM org.apache.cxf.ws.addressing.soap.MAPCodec encodeAsExposed [java] INFO: ReplyTo : http://localhost:9990/decoupled_endpoint [java] Apr 21, 2008 1:14:13 PM org.apache.cxf.ws.addressing.soap.MAPCodec encodeAsExposed [java] INFO: FaultTo : http://localhost:9990/decoupled_endpoint [java] javax.xml.ws.soap.SOAPFaultException: Connection refused: connect [java] at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:175) [java] at $Proxy33.sayHi(Unknown Source) [java] at demo.ws_addressing.client.Client.main(Client.java:76) [java] Caused by: org.apache.cxf.interceptor.Fault: Connection refused: connect [java] at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:75) [java] at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68) [java] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207) [java] at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254) [java] at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205) [java] at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) [java] at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135) [java] ... 2 more [java] Caused by: com.ctc.wstx.exc.WstxIOException: Connection refused: connect [java] at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:313) [java] at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:73) [java] ... 8 more [java] Caused by: java.net.ConnectException: Connection refused: connect [java] at java.net.PlainSocketImpl.socketConnect(Native Method) [java] at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) [java] at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) [java] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) [java] at java.net.Socket.connect(Socket.java:519) [java] at sun.net.NetworkClient.doConnect(NetworkClient.java:152) [java] at sun.net.www.http.HttpClient.openServer(HttpClient.java:382) [java] at sun.net.www.http.HttpClient.openServer(HttpClient.java:509) [java] at sun.net.www.http.HttpClient.init(HttpClient.java:231) [java] at sun.net.www.http.HttpClient.New(HttpClient.java:304) [java] at sun.net.www.http.HttpClient.New(HttpClient.java:316) [java] at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:813) [java] at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:765) [java] at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:690) [java] at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:857) [java] at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1766) [java] at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1734) [java] at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42) [java] at com.ctc.wstx.io.UTF8Writer.flush(UTF8Writer.java:96) [java] at com.ctc.wstx.sw.BufferingXmlWriter.flush(BufferingXmlWriter.java:214) [java] at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:311) [java] ... 9 more http://www.nabble.com/file/p16808296/cxf-servlet.xml cxf-servlet.xml http://www.nabble.com/file/p16808296/build.xml build.xml -- View this message in context: http://www.nabble.com/CXF-WS-Addressing-tp16808296p16808296.html Sent from the cxf-user mailing list archive at Nabble.com.
JAX-RS and Exception / Fault Handling
I'm looking for an example or documentation referencing the appropriate way to handle exceptions in a custom manner on a JAX-RS server. I have a REST service resembling the following: @Path(/exception) @GET public String getException() throws ABCException{ throw new ABCException(Test exception message); } When I invoke this service, I receive the following response: ns1:XMLFault xmlns:ns1=http://cxf.apache.org/bindings/xformat; ns1:faultstring xmlns:ns1=http://cxf.apache.org/bindings/xformat;test.rest.ABCException: Test exception message/ns1:faultstring /ns1:XMLFault I'd like to be able to catch this exception (probably via an interceptor so that I can handle all exception for a jaxrs server in a general fashion) and return a response resembling the following: error messageTest exception message/message /error What I have done to date is written an ExceptionInterceptor and registered it as an outFaultHandler. I've tried removing the exception from the MessageContentsList and adding my custom Error object as an elementData object, but it appears I'm to late in the process (phase) to affect the output. When I do this, the default CXF error message no longer displays, but my Error object is not marshalled. I'm not even convinced that the outFaultHandler is correct, as the phase INVOKE (as part of inHandler) seems more appropriate. I'll admit, I've just been trying various combinations to make it work. Can anyone point me in the right direction? Thanks - Steve Ardis -- View this message in context: http://www.nabble.com/JAX-RS-and-Exception---Fault-Handling-tp16810827p16810827.html Sent from the cxf-user mailing list archive at Nabble.com.
IndexOutOfBoundsException in MessageContentsList
I have a WSDL with multiple operations defined and one of them works properly. However, my login operation throws an IndexOutOfBoundsException when the SOAP response is processed. I have FINE logging enabled and I can see the request and response SOAP messages being processed. I'm using version 2.0.5 and the Maven WSDLtoJava plugin. Here is the debug output starting at the output of the request message: INFO: Outbound Message --- Encoding: UTF-8 Headers: {SOAPAction=[], Accept=[*]} Messages: Payload: soap:Envelope xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/;soap:Bodyns2:L ogin xmlns:ns2=http://www.informatica.com/wsh;RepositoryDomainNameDEV_DOM AIN/RepositoryDomainNameRepositoryNameMY_DEVELOPMENT/RepositoryName UserNameaamick/UserNamePasswordmypassword/Password/ns2:Login /soap:Body/soap:Envelope -- Apr 21, 2008 1:56:11 PM org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream handleResponse FINE: Response Code: 200 Conduit: {http://www.informatica.com/wsh}Metadata.http-conduit Apr 21, 2008 1:56:11 PM org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream handleResponse FINE: Content length: -1 Apr 21, 2008 1:56:11 PM org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream handleResponse FINE: Header fields: Date: [Mon, 21 Apr 2008 19:56:10 GMT] null: [HTTP/1.1 200 OK] Content-Type: [text/xml;charset=utf-8] Server: [Apache-Coyote/1.1] Transfer-Encoding: [chunked] Apr 21, 2008 1:56:11 PM org.apache.cxf.endpoint.ClientImpl onMessage FINE: Interceptors contributed by bus: [] Apr 21, 2008 1:56:11 PM org.apache.cxf.endpoint.ClientImpl onMessage FINE: Interceptors contributed by endpoint: [EMAIL PROTECTED] 0, [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] Apr 21, 2008 1:56:11 PM org.apache.cxf.endpoint.ClientImpl onMessage FINE: Interceptors contributed by client: [EMAIL PROTECTED] Apr 21, 2008 1:56:11 PM org.apache.cxf.endpoint.ClientImpl onMessage FINE: Interceptors contributed by binding: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] , [EMAIL PROTECTED] Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain add FINE: Adding interceptor [EMAIL PROTECTED] to phase pre-protocol Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain add FINE: Adding interceptor [EMAIL PROTECTED] to phase post-logical Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain add FINE: Adding interceptor [EMAIL PROTECTED] to phase pre-invoke Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain add FINE: Adding interceptor [EMAIL PROTECTED] to phase pre-protocol Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain add FINE: Adding interceptor [EMAIL PROTECTED] to phase pre-invoke Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain add FINE: Adding interceptor [EMAIL PROTECTED] to phase receive Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain add FINE: Adding interceptor [EMAIL PROTECTED] to phase receive Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain add FINE: Adding interceptor [EMAIL PROTECTED] to phase post-stream Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain add FINE: Adding interceptor [EMAIL PROTECTED] to phase read Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain add FINE: Adding interceptor [EMAIL PROTECTED] to phase unmarshal Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain add FINE: Adding interceptor [EMAIL PROTECTED] to phase unmarshal Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain add FINE: Adding interceptor [EMAIL PROTECTED] to phase read Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain add FINE: Adding interceptor [EMAIL PROTECTED] to phase pre-protocol Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain add FINE: Adding interceptor [EMAIL PROTECTED] to phase unmarshal Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain outputChainToLog FINE: Chain [EMAIL PROTECTED] was created. Current flow: receive [LoggingInInterceptor, AttachmentInInterceptor] post-stream [StaxInInterceptor] read [ReadHeadersInterceptor, SoapActionInInterceptor] pre-protocol [MustUnderstandInterceptor, SOAPHandlerInterceptor, LogicalHandlerInInterceptor] unmarshal [URIMappingInterceptor, DocLiteralInInterceptor, SoapHeaderInterceptor] post-logical [WrapperClassInInterceptor] pre-invoke [SwAInInterceptor, HolderInInterceptor] Apr 21, 2008 1:56:11 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept FINE: Invoking handleMessage on interceptor [EMAIL PROTECTED] Apr 21, 2008 1:56:11 PM org.apache.cxf.interceptor.LoggingInInterceptor logging INFO: Inbound Message
RE: JAX-RS and Exception / Fault Handling
Hi I think the JAX-RS spec is going to talk more about handling custom exceptions in the 0.8 or later versions but as far as I'm aware the most portable way at the moment is to throw a (runtime) WebApplicationException. Provided your resource class is a thin wrapper around a more involved application class, you might want to catch all the application exception and wrap them into a WebApplicationException like this : try { doIt(); } catch (ABCException ex) { throw new WebApplicationException(Response.status(appropriateErrorStatus).entity(t oXML(ex.getMesssage())).build()); } This way you'll get the XML message as expected and it will work across multiple JAX-RS implementations JAX-RS dictates that other exceptions like ABCException (provided they're runtime ones ?) should be propagated to the container such that one can write say a servlet filter and handle them, but at the moment they're caught at the binding level...There's likely to be more clarification in this regard in the future versions of the spec Cheers, Sergey -Original Message- From: yarddog [mailto:[EMAIL PROTECTED] Sent: 21 April 2008 20:48 To: cxf-user@incubator.apache.org Subject: JAX-RS and Exception / Fault Handling I'm looking for an example or documentation referencing the appropriate way to handle exceptions in a custom manner on a JAX-RS server. I have a REST service resembling the following: @Path(/exception) @GET public String getException() throws ABCException{ throw new ABCException(Test exception message); } When I invoke this service, I receive the following response: ns1:XMLFault xmlns:ns1=http://cxf.apache.org/bindings/xformat; ns1:faultstring xmlns:ns1=http://cxf.apache.org/bindings/xformat;test.rest.ABCExceptio n: Test exception message/ns1:faultstring /ns1:XMLFault I'd like to be able to catch this exception (probably via an interceptor so that I can handle all exception for a jaxrs server in a general fashion) and return a response resembling the following: error messageTest exception message/message /error What I have done to date is written an ExceptionInterceptor and registered it as an outFaultHandler. I've tried removing the exception from the MessageContentsList and adding my custom Error object as an elementData object, but it appears I'm to late in the process (phase) to affect the output. When I do this, the default CXF error message no longer displays, but my Error object is not marshalled. I'm not even convinced that the outFaultHandler is correct, as the phase INVOKE (as part of inHandler) seems more appropriate. I'll admit, I've just been trying various combinations to make it work. Can anyone point me in the right direction? Thanks - Steve Ardis -- View this message in context: http://www.nabble.com/JAX-RS-and-Exception---Fault-Handling-tp16810827p1 6810827.html Sent from the cxf-user mailing list archive at Nabble.com. IONA Technologies PLC (registered in Ireland) Registered Number: 171387 Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
Basic authentication as a client
Hi, I'm facing a problem with basic authentication when consuming a service with CXF. Currently the cxf-configuration XML contains these lines for each service my client is invoking: http-conf:authorization UserName xmlns=http://cxf.apache.org/configuration/security;@@username@@/UserN ame Password xmlns=http://cxf.apache.org/configuration/security;@@password@@/Passw ord /http-conf:authorization The tokens @@username@@ and @@password@@ are replaced by the classoader (loading the resource) to allow dynamic configuration. This is required because the consumed services can be deployed on different servers having different security settings (user credentials). I have not yet found a way to accomplish this with CXF which is not requiring the classloader workaround. This is how I instantiate the service-consumer: new MyService(ReplacingClassloader.getInstance().getResource(wsdl/myservice /main.wsdl), new QName(urn:MyServiceWsd, MyService);); Any ideas how this can be done programmatically ? Regards, Frederic _ SEEBURGER AGVorstand/Seeburger Executive Board: Sitz der Gesellschaft/ Bernd Seeburger, Axel Haas, Michael Kleeberg Registered Office: Edisonstrasse 1 Vorsitzender des Aufsichtsrats/Chairperson of D-75015 Bretten the Seeburger Supervisory Board: Tel.: 07252 / 96-0 Dr. Franz Scherer Fax: 07252 / 96- Internet: http://www.seeburger.de Registergericht/Commercial Register: e-mail: [EMAIL PROTECTED] HRB 240708 Mannheim _ Dieses E-Mail ist nur fur den Empfanger bestimmt, an den es gerichtet ist und kann vertrauliches bzw. unter das Berufsgeheimnis fallendes Material enthalten. Jegliche darin enthaltene Ansicht oder Meinungs- au?erung ist die des Autors und stellt nicht notwendigerweise die Ansicht oder Meinung der SEEBURGER AG dar. Sind Sie nicht der Empfanger, so haben Sie diese E-Mail irrtumlich erhalten und jegliche Verwendung, Veroffentlichung, Weiterleitung, Abschrift oder jeglicher Druck dieser E-Mail ist strengstens untersagt. Weder die SEEBURGER AG noch der Absender (Frederic Bitsch) ubernehmen die Haftung fur Viren; es obliegt Ihrer Verantwortung, die E-Mail und deren Anhange (0) auf Viren zu prufen. The present email addresses only the addressee which it targets and may contain confidential material that may be protected by the professional secret. The opinions reflected herein are not necessarily the one of the SEEBURGER AG. If you are not the addressee, you have accidentally got this email and are not enabled to use, publish, forward, copy or print it in any way. Neither the SEEBURGER AG, nor the sender (Frederic Bitsch) are liable for viruses, being your own responsibility to check this email and its attachments (0) for this purpose. _
JAX-RS sample broken in trunk?
Hi, I was using a recent snapshot of 2.1. When I tried to compile the JAX_RS sample, it failed. After looking at the source code, I see SingletonResourceProvider no longer has a default constructor. I fixed the Server.java in the sample as shown below. JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(CustomerService.class); sf.setResourceProvider(CustomerService.class, new SingletonResourceProvider(new CustomerService())); sf.setAddress(http://localhost:9000/;); sf.create(); After this, when I run the client it fails with the following HTTP-500 internal error. client: [java] Sent HTTP GET request to query customer info [java] Exception in thread main java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:9000/customerservice/customers/123 [java] at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Ht tpURLConnection.java:1241) [java] at java.net.URL.openStream(URL.java:1009) [java] at demo.jaxrs.client.Client.main(Client.java:52) [java] Java Result: 1 This used to work earlier. Can someone help understand this error? Thank you Arul
Re: Basic authentication as a client
You may want to use JAX-WS code to accomplish this. QName SERVICE_NAME = new QName(http://yournamespace.com;, MyWebServiceService); QName PORT_NAME = new QName( http://yournamespace.com;, MyService); Service service = Service.create(SERVICE_NAME); service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, myConfig .getUrl());MyWebService port = service.getPort(PORT_NAME, MyService.class);BindingProvider provider = (BindingProvider) port; MapString, Object requestContext = provider.getRequestContext(); requestContext.put(BindingProvider.PASSWORD_PROPERTY, myConfig.getPassword()); requestContext.put(BindingProvider.USERNAME_PROPERTY, myConfig.getUserID()); MyConfig is an environment aware config class which dynamically loads my configurations uid,pwd , service endpoint url etc from propertyfile. --Vijay On 4/21/08 4:57 PM, Bitsch. Frederic [EMAIL PROTECTED] wrote: Hi, I'm facing a problem with basic authentication when consuming a service with CXF. Currently the cxf-configuration XML contains these lines for each service my client is invoking: http-conf:authorization UserName xmlns=http://cxf.apache.org/configuration/security;@@username@@/UserN ame Password xmlns=http://cxf.apache.org/configuration/security;@@password@@/Passw ord /http-conf:authorization The tokens @@username@@ and @@password@@ are replaced by the classoader (loading the resource) to allow dynamic configuration. This is required because the consumed services can be deployed on different servers having different security settings (user credentials). I have not yet found a way to accomplish this with CXF which is not requiring the classloader workaround. This is how I instantiate the service-consumer: new MyService(ReplacingClassloader.getInstance().getResource(wsdl/myservice /main.wsdl), new QName(urn:MyServiceWsd, MyService);); Any ideas how this can be done programmatically ? Regards, Frederic _ SEEBURGER AGVorstand/Seeburger Executive Board: Sitz der Gesellschaft/ Bernd Seeburger, Axel Haas, Michael Kleeberg Registered Office: Edisonstrasse 1Vorsitzender des Aufsichtsrats/Chairperson of D-75015 Brettenthe Seeburger Supervisory Board: Tel.: 07252 / 96-0 Dr. Franz Scherer Fax: 07252 / 96- Internet: http://www.seeburger.de Registergericht/Commercial Register: e-mail: [EMAIL PROTECTED] HRB 240708 Mannheim _ Dieses E-Mail ist nur fur den Empfanger bestimmt, an den es gerichtet ist und kann vertrauliches bzw. unter das Berufsgeheimnis fallendes Material enthalten. Jegliche darin enthaltene Ansicht oder Meinungs- au?erung ist die des Autors und stellt nicht notwendigerweise die Ansicht oder Meinung der SEEBURGER AG dar. Sind Sie nicht der Empfanger, so haben Sie diese E-Mail irrtumlich erhalten und jegliche Verwendung, Veroffentlichung, Weiterleitung, Abschrift oder jeglicher Druck dieser E-Mail ist strengstens untersagt. Weder die SEEBURGER AG noch der Absender (Frederic Bitsch) ubernehmen die Haftung fur Viren; es obliegt Ihrer Verantwortung, die E-Mail und deren Anhange (0) auf Viren zu prufen. The present email addresses only the addressee which it targets and may contain confidential material that may be protected by the professional secret. The opinions reflected herein are not necessarily the one of the SEEBURGER AG. If you are not the addressee, you have accidentally got this email and are not enabled to use, publish, forward, copy or print it in any way. Neither the SEEBURGER AG, nor the sender (Frederic Bitsch) are liable for viruses, being your own responsibility to check this email and its attachments (0) for this purpose. _
Exception logging on server:
I have recently upgraded from XFire 1.2.6 to CXF 2.0.5, (within JBoss 4.2.0.GA/Java1.6.0_06). When using JAXWS, when my services throws an exception from the business code, the exception stack is not logged. For example, when my application throws a NullPointerException, only the following is mentioned in the log (instead of printing that stack trace or the exception class at the very least): 15:36:41,796 ERROR [STDERR] Apr 21, 2008 3:36:41 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept INFO: Application has thrown exception, unwinding now: null I am using the following cxf configuration: --- beans xmlns=http://www.springframework.org/schema/beans; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:cxf=http://cxf.apache.org/core; xmlns:jaxws=http://cxf.apache.org/jaxws; xsi:schemaLocation= http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.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/ cxf:bus cxf:features cxf:logging/ /cxf:features cxf:inInterceptors ref bean=logInbound/ /cxf:inInterceptors cxf:outInterceptors ref bean=logOutbound/ /cxf:outInterceptors cxf:inFaultInterceptors ref bean=logOutbound/ /cxf:inFaultInterceptors /cxf:bus jaxws:endpoint id=ExampleService implementor=com.example.ExampleWs endpointName=e:Example serviceName=s:ExampleService address=/ImportDistSnapService xmlns:e=http://service.jaxws.cxf.apache.org/endpoint; xmlns:s=http://service.jaxws.cxf.apache.org/service; jaxws:inFaultInterceptors ref bean=logOutbound/ /jaxws:inFaultInterceptors /jaxws:endpoint /beans --- And the following web.xml: web-app 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/services/*/url-pattern /servlet-mapping context-param param-namecontextConfigLocation/param-name param-value classpath:WEB-INF/cxf/services.xml /param-value /context-param listener listener-class org.springframework.web.context.ContextLoaderListener /listener-class /listener /web-app -- View this message in context: http://www.nabble.com/Exception-logging-on-server%3A-tp16816689p16816689.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: Exception logging on server:
It appears to print Exception.getMessage(). NullPointerException has no message, which explains why it prints null in this case. How can I configure CXF to print the exception class and optionally the stack trace (on the server)? greenstar wrote: I have recently upgraded from XFire 1.2.6 to CXF 2.0.5, (within JBoss 4.2.0.GA/Java1.6.0_06). When using JAXWS, when my services throws an exception from the business code, the exception stack is not logged. For example, when my application throws a NullPointerException, only the following is mentioned in the log (instead of printing that stack trace or the exception class at the very least): 15:36:41,796 ERROR [STDERR] Apr 21, 2008 3:36:41 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept INFO: Application has thrown exception, unwinding now: null ... -- View this message in context: http://www.nabble.com/Exception-logging-on-server%3A-tp16816689p16817103.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: CXF WS-Addressing
I don't know, but perhaps Steps 7 and 8 of my example (http://www.jroller.com/gmazza/date/20080417) might give you a hint. Glen 2008-04-21 stevewu wrote: Hi all, I am converting the ws-addressing sample in cxf 2.0.5 to a servlet version. When I deploy and run, I am getting the following error. I checked CXF users guide on how to configure WS-Addressing but it doesn't help. I included the build.xml and cxf-servlet.xml that I used to create the war file. Am I misising some configuration on the server side? SteveWu client-servlet: [java] URL===http://localhost:8080/helloworldaddr/services/hello_world_addr?wsdl [java] Invoking sayHi... [java] Apr 21, 2008 1:14:13 PM org.apache.cxf.ws.addressing.soap.MAPCodec encode [java] INFO: Outbound WS-Addressing headers [java] Apr 21, 2008 1:14:13 PM org.apache.cxf.ws.addressing.soap.MAPCodec encodeAsExposed [java] INFO: MessageID : urn:uuid:ddd32553-8aa0-4ed9-88f3-0b809bd0d4eb [java] Apr 21, 2008 1:14:13 PM org.apache.cxf.ws.addressing.soap.MAPCodec encodeAsExposed [java] INFO: To : http://localhost:9050/SoapContext/SoapPort [java] Apr 21, 2008 1:14:13 PM org.apache.cxf.ws.addressing.soap.MAPCodec encodeAsExposed [java] INFO: ReplyTo : http://localhost:9990/decoupled_endpoint [java] Apr 21, 2008 1:14:13 PM org.apache.cxf.ws.addressing.soap.MAPCodec encodeAsExposed [java] INFO: FaultTo : http://localhost:9990/decoupled_endpoint [java] javax.xml.ws.soap.SOAPFaultException: Connection refused: connect [java] at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:175) [java] at $Proxy33.sayHi(Unknown Source) [java] at demo.ws_addressing.client.Client.main(Client.java:76) [java] Caused by: org.apache.cxf.interceptor.Fault: Connection refused: connect [java] at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:75) [java] at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68) [java] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207) [java] at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254) [java] at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205) [java] at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) [java] at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135) [java] ... 2 more [java] Caused by: com.ctc.wstx.exc.WstxIOException: Connection refused: connect [java] at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:313) [java] at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:73) [java] ... 8 more [java] Caused by: java.net.ConnectException: Connection refused: connect [java] at java.net.PlainSocketImpl.socketConnect(Native Method) [java] at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) [java] at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) [java] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) [java] at java.net.Socket.connect(Socket.java:519) [java] at sun.net.NetworkClient.doConnect(NetworkClient.java:152) [java] at sun.net.www.http.HttpClient.openServer(HttpClient.java:382) [java] at sun.net.www.http.HttpClient.openServer(HttpClient.java:509) [java] at sun.net.www.http.HttpClient.init(HttpClient.java:231) [java] at sun.net.www.http.HttpClient.New(HttpClient.java:304) [java] at sun.net.www.http.HttpClient.New(HttpClient.java:316) [java] at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:813) [java] at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:765) [java] at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:690) [java] at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:857) [java] at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1766) [java] at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1734) [java] at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42) [java] at com.ctc.wstx.io.UTF8Writer.flush(UTF8Writer.java:96) [java] at com.ctc.wstx.sw.BufferingXmlWriter.flush(BufferingXmlWriter.java:214) [java] at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:311) [java] ... 9 more http://www.nabble.com/file/p16808296/cxf-servlet.xml cxf-servlet.xml
Re: Exception logging on server:
Here's information on our logging options: http://cwiki.apache.org/CXF20DOC/debugging.html 2008-04-21 (月) の 16:02 -0700 に greenstar さんは書きました: It appears to print Exception.getMessage(). NullPointerException has no message, which explains why it prints null in this case. How can I configure CXF to print the exception class and optionally the stack trace (on the server)? greenstar wrote: I have recently upgraded from XFire 1.2.6 to CXF 2.0.5, (within JBoss 4.2.0.GA/Java1.6.0_06). When using JAXWS, when my services throws an exception from the business code, the exception stack is not logged. For example, when my application throws a NullPointerException, only the following is mentioned in the log (instead of printing that stack trace or the exception class at the very least): 15:36:41,796 ERROR [STDERR] Apr 21, 2008 3:36:41 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept INFO: Application has thrown exception, unwinding now: null ...