簡體   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