gpt4 book ai didi

java - WSDL2Java 不会创建所有 stub

转载 作者:行者123 更新时间:2023-11-30 05:10:42 26 4
gpt4 key购买 nike

我正在使用 Apache axis2,更具体地说,使用 wsdl2java 工具来生成 Web 服务的 stub 并在给定 wsdl 文件的情况下创建客户端。

当我尝试为 paypal Web 服务生成 stub 类(其 wsdl 文件为 here )时,轴不会为 wsdl 中包含的两个绑定(bind)生成 stub ,而只会为第二个绑定(bind)生成 stub (PayPalAPIAASoapBinding)

以前有人用 apache 的 wsdl2java 工具处理过这个 wsdl 吗?

最佳答案

我也曾为此苦苦挣扎。

简短回答:
-pn PayPalAPI 附加到您的 Axis2 命令。

长答案:
看一下 PayPal WSDL 的以下几行:

<wsdl:service name="PayPalAPIInterfaceService">
<wsdl:port name="PayPalAPI" binding="ns:PayPalAPISoapBinding">
<wsdlsoap:address location="https://api.sandbox.paypal.com/2.0/"/>
</wsdl:port>
<wsdl:port name="PayPalAPIAA" binding="ns:PayPalAPIAASoapBinding">
<wsdlsoap:address location="https://api-aa.sandbox.paypal.com/2.0/"/>
</wsdl:port>
</wsdl:service>

显然,WSDL 指定了 1 个服务和 2 个端口。我们的问题是 Axis2 只为第二个端口“PayPalAPIAA”创建 stub ,但不为端口“PayPalAPI”创建 stub 。

现在,看一下 Axis 2 命令行选项引用 ( http://ws.apache.org/axis2/tools/1_2/CodegenToolReference.html#cmdref ),特别是选项 -pn 的说明:

"Specifies the port name to be code generated. If the port name is not specified, then the first port (of the selected service) will be picked."

因此,指定 -pn PayPalAPI 就可以了。

关于java - WSDL2Java 不会创建所有 stub ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3457672/

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