1

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

这是我对 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> 

我真的很想看到publishedEndpointUrl 在REST 服务中得到充实。JAXRSServerFactoryBean的 API暗示它可以通过继承的字段来完成。上下文配置应该如何实现?

4

1 回答 1

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> 

于 2018-01-29T08:43:25.333 回答