编程语言
首页 > 编程语言> > java – SOAP和Spring

java – SOAP和Spring

作者:互联网

我刚刚在Manning Publications Co.的Craig Walls的第二版“Spring in Action”中阅读了关于SOAP的文章.他们写了一篇关于契约优先的文章,就像Spring文档一样,编写了一个消息和方法XML和然后将其转换为XSD,然后再转换为WSDL,同时在Spring中连接编组和服务路径.

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

另外:我想复制已经存在的Web服务.我有它的WSDL,我可以放置我的服务而不是它.这是推荐的吗?如果是这样,推荐的方法是什么?

干杯

Nik

解决方法:

我想你必须穿过你的电线.

合同首先意味着定义WSDL,然后创建Java代码以支持此WSDL.

契约最后意味着创建Java代码,并在以后生成WSDL.

最后合同的危险在于,如果您的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.

标签:spring-ws,java,spring,soap,wsdl
来源: https://codeday.me/bug/20190724/1519622.html