我的Web应用程序是基于Spring Mvc 4引导较少的,使用Restful服务基于完全注释的配置构建的。现在根据需要,我需要将Soap集成到现有的Spring Mvc Application中。如何使用基于注释的配置将Soap和Restful Spring Mvc Application一起配置?

最佳答案

我们正在我当前的项目中执行此操作。只需在cxf.xml中配置适当的端点即可。

像这样:

<jaxrs:server id="restEndpoint" address="/whatever">
    <jaxrs:serviceBeans>
        <ref bean="restEndpointBean" />
    </jaxrs:serviceBeans>
</jaxrs:server>


....

<jaxws:endpoint xmlns:tns="http://my.url/soapserv/connect"
    id="ConnectSoap" address="/connect" serviceName="tns:connect"
    endpointName="tns:connect" implementor="#connectSoapImpl">
    <jaxws:binding>
        <soap:soapBinding version="1.2" mtomEnabled="true" />
    </jaxws:binding>
</jaxws:endpoint>


对于SOAP服务,它们使用cfl.xml配置进行绑定,没有特定于此的注释。显然,您将需要@Component

对于REST服务,他们利用标准的REST注释:

@GET
@Path("foo/{id}")
public Response getFooId(@PathParam("id") String id)


要么

@RequestMapping(value = "/foo", method = RequestMethod.PuT)
public @ResponseBody PaymentModel updateFoo(
                                       @RequestBody PaymentModel request) {

10-06 06:59
查看更多