繁体   English   中英

如何在Spring Mvc 4中同时运行Soap和Json这两个Web服务?

[英]How to have two web services that is both Soap and Json run together in Spring Mvc 4?

我的Web应用程序基于Spring Mvc 4启动,而不是使用Restful服务完全基于注释的配置。现在我需要将Soap集成到我现有的Spring Mvc应用程序中。 如何使用基于注释的配置配置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>

对于使用cfl.xml配置绑定的SOAP服务,没有特定于此的注释。 显然你需要@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) {

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM