天道酬勤,学无止境

cxfrs

Camel cxfrs RESTful client / ProducerTemplate ConnectionTimeout

I am trying to set the 'connectionTimeout' for a Camel CXF-RS component here which produces a RESTful requests on a 3rd party service. The default 30000 miliseconds is to long. Exchange exchange = template.send("cxfrs://" + url, new Processor() { public void process(Exchange exchange) throws Exception { exchange.setPattern(ExchangePattern.InOut); Message inMessage = exchange.getIn(); setupDestinationURL(inMessage); // using the http central client API inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE); // set the Http method inMessage.setHeader(Exchange.HTTP_METHOD,

2021-11-24 03:03:58    分类:问答    rest   apache-camel   cxf   cxfrs

如何在 XML 中使用 CXF JAX-RS 和 Jackson 2 配置服务器返回的日期格式?(How do I configure the date format the server returns using CXF JAX-RS and Jackson 2 in XML?)

问题 这花了我很多努力才弄明白,所以我将回答下面的问题。 这个答案不使用注释,也不需要创建额外的类。 回答1 你把它放在你的 spring xml 上下文配置中: <?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" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" 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 http://www.springframework

2021-11-09 04:08:20    分类:技术分享    java   json   spring   jackson   cxfrs

How do I configure the date format the server returns using CXF JAX-RS and Jackson 2 in XML?

This took me a lot of effort to figure out so I'm going to answer the question below. This answer doesn't use annotations and does not require creating additional classes.

2021-11-07 01:46:34    分类:问答    java   json   spring   jackson   cxfrs

JMS 传输上的 REST 而不是 HTTP(REST on JMS Transport instead of HTTP)

问题 我正在尝试为 REST 创建多个通道,以便可以使用 http 协议从浏览器调用我的端点,或者其他应用程序可以通过将消息放在队列中来异步调用。 虽然我能够配置两种传输类型。 我能够访问 REST 服务,但在发送 JMS 消息时失败。 这是我用于重现问题的完整代码设置。 pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.kp.swasthik</groupId> <artifactId>kp-rest-jms-artemis</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>kp-rest-jms-artemis</name>

2021-10-15 10:46:52    分类:技术分享    rest   jms   cxf   spring-jms   cxfrs

在 CXF 中禁用 wadl Web 服务定义(Disable wadl Web Service Definition In CXF)

问题 我正在使用 CXF 网络服务,一切正常。 但是当我要向公众公开我们的网络服务时,wadl url 正在从公众那里工作。 任何人都可以看到我们的网络服务的 wadl 定义。 我们如何禁用此定义。 例如 wadl 的 url 是 - http://localhost:8080/webservice/rest?_wadl 回答1 由于以下依赖项,生成了 wadl。 cxf-rt-rs-service-description 如果您从应用程序/依赖项管理中删除该 jar,则不会生成 wadl。 附加信息: http://cxf.apache.org/docs/jaxrs-services-description.html#JAXRSServicesDescription-WADLAutoGenerationatRuntime 回答2 尝试将其添加到jaxrs:server ,这将隐藏由jaxrs:server地址公开的端点 <jaxrs:properties> <entry key="org.apache.cxf.endpoint.private" value="true"/> </jaxrs:properties>

2021-10-14 17:53:54    分类:技术分享    cxf   cxfrs

REST on JMS Transport instead of HTTP

I'm trying to create multiple channels for REST such that my endpoints can be invoked from Browser using http protcol or other applications can asynchronously invoke by placing message on queue. Though I'm able to configure both transport types. I'm able to access the REST service and but fails when sending JMS message. Here is the complete code setup I'm using for reproducing the issue. pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0

2021-10-14 14:53:51    分类:问答    rest   jms   cxf   spring-jms   cxfrs

Disable wadl Web Service Definition In CXF

I am using CXF webservice and everything is working perfectly. But as I am going to expose our webservice to public the wadl url is working from public. Anyone can see the wadl definition of our webservice. How can we disable this definition. e.g. the url for wadl is - http://localhost:8080/webservice/rest?_wadl

2021-10-11 13:58:36    分类:问答    cxf   cxfrs

JAX-RS CXF 异常包装(JAX-RS CXF Exception wrapping)

问题 我想向 CXF (2.6.1) 添加一个 ExceptionMapper,它不仅传达响应代码,而且还以有效负载格式发送异常(我现在使用 JSON)。 @Provider public class CustomExceptionMapper implements ExceptionMapper<MyException> { ... @Override public Response toResponse(MyException mex) { //I need something here which can convert mex object to JSON and ship it in response // I want this to be de-serialized on client //the following returns the status code return Response.status(Response.Status.BAD_REQUEST).build(); } ... } 有没有办法做到这一点 ? 回答1 您可能需要使用 @Produces 将您的对象序列化为 JSON,例如: @Produces(MediaType.APPLICATION_JSON) 然后return Response.ok().entity(OBJECT).build(

2021-09-30 03:48:58    分类:技术分享    java   cxf   jax-rs   cxfrs

JAX-RS CXF Exception wrapping

I would like to add an ExceptionMapper to CXF (2.6.1) which not only communicates the Response code, but also ships the exception in the payload format (I'm using JSON for now). @Provider public class CustomExceptionMapper implements ExceptionMapper<MyException> { ... @Override public Response toResponse(MyException mex) { //I need something here which can convert mex object to JSON and ship it in response // I want this to be de-serialized on client //the following returns the status code return Response.status(Response.Status.BAD_REQUEST).build(); } ... } Is there a way to do this ?

2021-09-29 16:32:22    分类:问答    java   cxf   jax-rs   cxfrs

如何从 CXF/JAX-RS 的 JSON 响应中删除命名空间前缀?(How to remove namespace prefixes from JSON response in CXF/JAX-RS?)

问题 我有 CXF 使用 JAX-RS 创建的以下响应: {"ns1.CustomerInformationResponse":{ "@xsi.type":"ns1:CustomerInformationResponse", "ns2.code":"SUCCESS", "ns1.customer":{ "@xsi.type":"ns2:CustomerBaseDTO", "ns2.login":"login1" } }} 这是我当前上下文配置的相关部分: <jaxrs:server address="http://${host}:${port}/rest/customer"> <jaxrs:serviceBeans> <ref bean="customerManagementServiceImpl" /> </jaxrs:serviceBeans> <jaxrs:providers> <bean class="org.apache.cxf.jaxrs.provider.AegisJSONProvider" /> </jaxrs:providers> </jaxrs:server> 我想接收像上面那样的响应,没有命名空间前缀(即 ns1、ns2 等...)。 我试图将org.apache.cxf.interceptor.transform

2021-08-11 02:05:11    分类:技术分享    java   cxf   jax-rs   cxfrs