JAXRS / Spring / CXF端点配置中的合同细节 - 命名空间,PublishedUrl等

时间:2012-04-04 01:01:16

标签: java spring jax-rs cxf

如何使用JAXRS中的Endpoint详细信息充实我的上下文配置?

以下是我对JAXWS的看法:

<jaxws:endpoint id="s-myService" implementor="#myService" 
    serviceName="s2:MyService" 
    endpointName="e2:MyServiceEndpoint"
    address="/my-service/soap/base" 
    publishedEndpointUrl="http://localhost:8080/my-service/soap/base" 
    xmlns:s2="http://localhost:8080/example-service/ns" 
    xmlns:e2="http://localhost:8080/example-service/ns"
/>

如何使以下JAXRS端点实现相同的细节?

<jaxrs:server id="r-myService" 
    address="/my-service/rest/base"> 
    <jaxrs:serviceBeans> 
        <ref bean="myRestService" /> 
    </jaxrs:serviceBeans> 
    <jaxrs:providers> 
        <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" /> 
        <ref bean="SomethingGives"/> 
    </jaxrs:providers> 
    <jaxrs:extensionMappings> 
        <entry key="json" value="application/json" /> 
        <entry key="xml" value="application/xml" /> 
    </jaxrs:extensionMappings> 
</jaxrs:server> 

我真的很想看看在Exchange服务中充实的publishedEndpointUrl。 JAXRSServerFactoryBean的API意味着可以通过继承字段完成。应该如何实现上下文配置?

1 个答案:

答案 0 :(得分:1)

您可以将publishedEndpointUrl用作jaxrs属性的一部分。

<jaxrs:server id="r-myService" 
address="/my-service/rest/base" publishedEndpointUrl="http://localhost"> 
<jaxrs:serviceBeans> 
    <ref bean="myRestService" /> 
</jaxrs:serviceBeans> 
<jaxrs:providers> 
    <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" /> 
    <ref bean="SomethingGives"/> 
</jaxrs:providers> 
<jaxrs:extensionMappings> 
    <entry key="json" value="application/json" /> 
    <entry key="xml" value="application/xml" /> 
</jaxrs:extensionMappings>