1

CXF レスト サービスのエラーを処理しようとしています。私が得たいのは、ユーザーがリクエストを送信しようとしていて、間違ったパスを選択している状況です。この状況を何とかしたい。デフォルトの応答は次のとおりです。

2014-05-15 14:07:14 INFO  [qtp811959489-40] LoggingOutInterceptor:234 - Outbound Message
---------------------------
ID: 1
Response-Code: 405
Content-Type: 
Headers: {Allow=[POST, GET, OPTIONS, HEAD], Date=[Thu, 15 May 2014 12:07:14 GMT], Content-Length=[0]}

私のリソースクラス:

@Path("payment/v1/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public class OneApiResource {

    @GET
    @Path("/{endUserId}/transactions")
    public PaymentTransactionListWrapper listTransactions(@PathParam("endUserId") String endUserId) {
        return null;
    }
}

終点:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:cxf="http://camel.apache.org/schema/cxf"
       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://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
       http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
    ">

    <bean id="jsonProviderFactory" class="model.oneApi.JsonProviderFactory"/>
    <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
    <cxf:rsServer id="bieService"
                  address="http://{{endpoint.jetty.app.oneApi.host}}:{{endpoint.jetty.app.oneApi.service.port}}/{{endpoint.jetty.app.oneApi.service.ctx}}/"
                  loggingFeatureEnabled="true"
                  serviceClass="model.oneApi.OneApiResource"
                  loggingSizeLimit="-1"
                  skipFaultLogging="false">
        <cxf:providers>
            <bean factory-bean="jsonProviderFactory" factory-method="create"/>
        </cxf:providers>
        <cxf:inFaultInterceptors>
            <ref bean="logOutbound"/>
        </cxf:inFaultInterceptors>
        <cxf:outFaultInterceptors>
            <ref bean="logOutbound"/>
        </cxf:outFaultInterceptors>
    </cxf:rsServer>

</beans>

それを処理する方法はありますか?

4

0 に答える 0