java 如何转换为 SOAP 1.1 制作的 WSDL 文件以支持 SOAP 1.2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6467234/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 15:59:32  来源:igfitidea点击:

How to convert a WSDL file made for SOAP 1.1 to support SOAP 1.2

javasoapaxis2wsdl2java

提问by Olivier Grégtheitroade

Years ago, I built a SOAP 1.1 service based upon a WSDL I was given. This was rather basic: I executed Axis' WSDL2Java and used the generated classes as base.

多年前,我基于收到的 WSDL 构建了一个 SOAP 1.1 服务。这是相当基本的:我执行了 Axis 的 WSDL2Java 并使用生成的类作为基础。

Now I'm told to migrate this service so people can reach it using SOAP 1.2.

现在我被告知要迁移此服务,以便人们可以使用 SOAP 1.2 访问它。

What should I change in my WSDL file so my new generated service (still using Axis' WSDL2Java) supports SOAP 1.2?

我应该在我的 WSDL 文件中更改什么,以便我新生成的服务(仍然使用 Axis 的 WSDL2Java)支持 SOAP 1.2?

It's important to understand that I'm service provider: I don't want solutions that only work for clients.

了解我是服务提供商这一点很重要:我不想要仅适用于客户的解决方案。

Many thanks!

非常感谢!

回答by maasg

Structurally, you will need to add support of SOAP 1.2 in your WSDL document. Your 'abstract' WSDL part defines the types, messages and portTypes. (I'm assuming here that you want to update your WSDL1.1 doc to add SOAP1.2 support for your existing service)

在结构上,您需要在 WSDL 文档中添加对 SOAP 1.2 的支持。您的“抽象”WSDL 部分定义了类型、消息和端口类型。(我在这里假设您想要更新您的 WSDL1.1 文档,以便为您现有的服务添加 SOAP1.2 支持)

To support SOAP1.2 you will need to add SOAP1.2-compliant bindings and service definitions. As an example, we have this port definition:

要支持 SOAP1.2,您需要添加符合 SOAP1.2 的绑定和服务定义。例如,我们有这个端口定义:

<wsdl:portType name="ServerSoap">
    <wsdl:operation name="SomeOperation"> ...

You will need to add a SOAP1.2 binding section for your operation:

您需要为您的操作添加一个 SOAP1.2 绑定部分:

<wsdl:binding name="ServerSoap12" type="tns:ServerSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="SomeOperation">
        <soap12:operation soapAction="..." style="document" /> ...

And a service:

还有一项服务:

<wsdl:service name="Server">
        <!-- SOAP1.1 Service -->
        <wsdl:port name="ServerSoap" binding="tns:ServerSoap">
        <soap:address location="http://localhost:8080/Server" />
    </wsdl:port>

        <!-- SOAP1.2 Service -->
    <wsdl:port name="ServerSoap12" binding="tns:ServerSoap12">
        <soap12:address location="http://localhost:8080/Server" />
    </wsdl:port>
</wsdl:service>

Note that the two definitions can co-exist and your service can remain backwards compatible with SOAP1.1. The clients will have to make the choice to use SOAP1.1 or SOAP1.2.

请注意,这两个定义可以共存,并且您的服务可以保持与 SOAP1.1 的向后兼容。客户端必须选择使用 SOAP1.1 还是 SOAP1.2。

In practical terms, you could try generating the WSDL from the code you have, indicating Axis to generate bindings for SOAP1.2. I'm not an AXIS user, so RTM java2wsdl for a way to do that.

实际上,您可以尝试从您拥有的代码生成 WSDL,指示 Axis 为 SOAP1.2 生成绑定。我不是 AXIS 用户,所以 RTM java2wsdl 是一种方法。