如何在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>


我真的很想在REST服务中充实发布的EndpointUrl。 JAXRSServerFactoryBean的API表示可以通过继承的字段来完成。应该如何实现上下文配置?

最佳答案

您可以将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>

08-03 17:07