gpt4 book ai didi

java - SOAP 和 Spring

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:04:16 27 4
gpt4 key购买 nike

我刚刚读完“Spring in Action”中关于 SOAP via Spring-WS 的文章,第 2 版,来自 Manning Publications Co. 的 Craig Walls。方法 XML,然后将其转换为 XSD,然后再转换为 WSDL,同时在 Spring 中连接编码和服务路径。

我必须承认,我不相信。为什么这是比创建服务接口(interface)并基于该接口(interface)生成我的服务更好的路径?这与在 Spring3 中定义我的 REST @Controllers 非常接近。我是否可以选择像这样使用 Spring 制作 SOAP web 服务?

另外:我想复制一个已经存在的网络服务。我有它的 WSDL,我可以用我的服务代替它。这是推荐的吗?如果是这样,推荐的方法是什么?

干杯

Nik

最佳答案

我想你一定是搞错了。

契约首先意味着定义一个 WSDL,然后创建 Java 代码来支持这个 WSDL。

Contract last 意味着创建您的 Java 代码,然后生成 WSDL。

contract last 的危险在于,如果您的 WSDL 是从您的 Java 代码自动生成的,并且您重构了您的 Java 代码,这会导致您的 WSDL 发生变化。

Spring-WS only supports contract first

2.3.1. Fragility

As mentioned earlier, the contract-last development style results in your web service contract (WSDL and your XSD) being generated from your Java contract (usually an interface). If you are using this approach, you will have no guarantee that the contract stays constant over time. Each time you change your Java contract and redeploy it, there might be subsequent changes to the web service contract.

Aditionally, not all SOAP stacks generate the same web service contract from a Java contract. This means changing your current SOAP stack for a different one (for whatever reason), might also change your web service contract.

When a web service contract changes, users of the contract will have to be instructed to obtain the new contract and potentially change their code to accommodate for any changes in the contract.

In order for a contract to be useful, it must remain constant for as long as possible. If a contract changes, you will have to contact all of the users of your service, and instruct them to get the new version of the contract.

关于java - SOAP 和 Spring ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1575268/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com