As requested by Sergey (this works fine when run through the standalone 
server - see main method - but fails when configured through Spring):

import javax.jws.WebService;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;

@WebService(endpointInterface = "ApplicationConfigurationService")
public class ApplicationConfigurationServiceImpl 
   implements ApplicationConfigurationService
{
   protected final Log logger = 
LogFactory.getLog(this.getClass().getName());
 
   @POST
   @Path("/push/")
   public Response addApplicationConfiguration(ApplicationConfiguration 
ac)
   {
      logger.info("ApplicationConfiguration: "+ac);

      return Response.ok(ac).build();
   }
 
   @POST
   @Path("/push/")
   public Response updateApplicationConfiguration(ApplicationConfiguration 
ac)
   {
      logger.info("ApplicationConfiguration: "+ac);

      return Response.ok(ac).build();
   }
 
   @GET
   @Path("/get/{id}/")
   public Response getApplicationConfiguration(@PathParam("id") String id)
   {
      logger.info("id: "+id);

      ApplicationConfiguration ac = new ApplicationConfiguration();
      ac.setId(id);
      ac.setName("test");

      return Response.ok(ac).build();
   } 
 
   /**
    * Set up the server to allow testing.
    */
   public static final void main(String[] argv)
   {
      JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
      sf.setResourceClasses(ApplicationConfigurationService.class);
      sf.setResourceProvider(ApplicationConfigurationService.class, 
          new SingletonResourceProvider(new 
ApplicationConfigurationServiceImpl()));
      sf.setAddress("http://localhost:9000/";);

      Server svr = sf.create(); 
      System.out.println("Server started");
   }
}

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
import javax.jws.WebService;

@Path("/applicationConfiguration/")
@WebService
public interface ApplicationConfigurationService 
{
   /**
    * Add an application configuration.
    */
   @POST
   @Path("/push/")
   Response addApplicationConfiguration(ApplicationConfiguration ac);

   /**
    * Update an application configuration.
    */
   @PUT
   @Path("/push/{id}/")
   Response updateApplicationConfiguration(ApplicationConfiguration ac);

   /**
    * Retrieve an application configuration by id.
    */
   @GET
   @Path("/get/{id}/")
   Response getApplicationConfiguration(@PathParam("id") String id);
}

John Baker
-- 
Web SSO 
IT Infrastructure 
Deutsche Bank London

URL:  http://websso.cto.gt.intranet.db.com




John-M Baker <[EMAIL PROTECTED]> 
30/04/2008 08:27
Please respond to
[email protected]


To
[email protected]
cc
[email protected]
Subject
Re: CXF 2.1, Rest and Spring configuration






Sergey,

Yep, we figured this out yesterday. wget was not passing application/xml 
in the Accept header, and hence json was used in the output. However 
Firefox does and XML is returned as expected. I then found myself puzzling 

to why this:

<ns1:XMLFault><ns1:faultstring>
.No operation matching request path /configuration/get/moo/ is found, 
ContentType : */*, Accept : 
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5.
</ns1:faultstring></ns1:XMLFault>

is returned when I try and setup the service through Spring (see post at 
15:18 GMT yesterday). Could you have a look at this particular problem?

Thanks,


John Baker
-- 
Web SSO 
IT Infrastructure 
Deutsche Bank London

URL:  http://websso.cto.gt.intranet.db.com




"Sergey Beryozkin" <[EMAIL PROTECTED]> 
29/04/2008 17:24
Please respond to
[email protected]


To
<[email protected]>
cc
<[email protected]>
Subject
Re: CXF 2.1, Rest and Spring configuration






Hi

In JAX-RS it's media/mime types which dictate what provider is selected on 

input/output. 
In CXF there're 2 default providers which can deal with JAXB - 
JAXBElementProvider and JSONProvider, they're chosen based on the value of 

HTTP Accept header and the value of the ProduceMime annotation on a 
particular method (on output in this case).

Most likely you haven't specified the value of HTTP Accept header or 
ProduceMime (application/xml in this case) and as such the first provider 
capable of dealing with JAXB (JSON one happens to be the first in the 
list) has been selected. 

That said, I think this needs to be fixed so that a JAXB provider is 
checked first by default...If you nedd it fixed then you might want to 
consider applyinga apcth, it should a one line fixer to the provider 
factory (where the relevant code currently lives)

Thanks, Sergey


----- Original Message ----- 
From: "John-M Baker" <[EMAIL PROTECTED]>
To: <[email protected]>
Cc: <[email protected]>
Sent: Tuesday, April 29, 2008 3:19 PM
Subject: Re: CXF 2.1, Rest and Spring configuration


> Sergey,
> 
> So I've now got a system running fine with jaxrs and the standalone 
server 
> option works as expected. However I've used the example at the bottom of 


> this page:
> 
> http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html
> 
> and produced this Spring context:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans";
>  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.xsd
> http://cxf.apache.org/jaxrs
> http://cxf.apache.org/schemas/jaxrs.xsd";>
> 
>  <import resource="classpath:META-INF/cxf/cxf.xml"/>
>  <import 
> resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml"/>
>  <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
> 
>  <jaxrs:server id="cxf.server.ApplicationConfigurationService" 
> address="/">
>    <jaxrs:serviceBeans>
>      <bean 
> class="com.db.websso.rest.server.ApplicationConfigurationServiceImpl" />
>    </jaxrs:serviceBeans>
>  </jaxrs:server> 
> 
> </beans>
> 
> which results in this exception:
> 
> org.apache.cxf.BusException: No binding factory for namespace 
> http://apache.org/cxf/binding/jaxrs registered.
>        at 
> org.apache.cxf.binding.BindingFactoryManagerImpl.getBindingFactory(
> BindingFactoryManagerImpl.java:91)
>        at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.createBindingInfo(
> JAXRSServerFactoryBean.java:208)
> 
> Is the webpage out of date?
> 
> 
> John Baker
> -- 
> Web SSO 
> IT Infrastructure 
> Deutsche Bank London
> 
> URL:  http://websso.cto.gt.intranet.db.com
> 
> 
> 
> 
> "Sergey Beryozkin" <[EMAIL PROTECTED]> 
> 29/04/2008 11:50
> Please respond to
> [email protected]
> 
> 
> To
> <[email protected]>
> cc
> 
> Subject
> Re: CXF 2.1, Rest and Spring configuration
> 
> 
> 
> 
> 
> 
> Hi John,
> 
> In your bean.xml you can do something like :
> 
> <beans>
> <!-- your service class -->
> <bean name="ServiceClass" class="com.Service">
> 
> <!-- JAXWS SOAP-->
> <jaxws:endpoint implementor="#ServiceClass" address="/Greeter"/>
> 
> <!-- JAXRS -->
> <jaxrs:server address="/jaxrsgreeter">
> <jaxrs:serviceBeans>
>      <bean ref="#ServiceClass" />
> </jaxrs:serviceBeans>
> </jaxrs:server>
> 
> <!-- JAXWS HTTP Binding -->
> <jaxws:endpoint implementor="#ServiceClass" 
> address="/GreeterHttpBinding"/>
> 
> </beans>
> 
> and then have both JAX-WS and JAX-RS annotations applied to the 
> com.Service class at will...
> 
> By the way, as far as writing RESTful services is concerned, I do 
> encourage you to migrate your HTTP Binding service to JAX-RS. 
> JAX-RS is a standard and in the end of the day you should be able to run 


> the same code with different JAX-RS implementations
> 
> Cheers, Sergey 
> 
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, 
Ireland
> 
> 
> 
> ---
> 
> This e-mail may contain confidential and/or privileged information. If 
you are not the intended recipient (or have received this e-mail in error) 

please notify the sender immediately and delete this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
> 
> Please refer to http://www.db.com/en/content/eu_disclosures.htm for 
additional EU corporate and regulatory disclosures.

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



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and delete this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for 
additional EU corporate and regulatory disclosures.


---

This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this e-mail in error) please 
notify the sender immediately and delete this e-mail. Any unauthorized copying, 
disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional 
EU corporate and regulatory disclosures.

Reply via email to