WSDL2Java won't create all the stubs

2019-07-25 17:46发布

I'm using Apache axis2 and more specifically, the wsdl2java tool to generate the stubs for a web service and create a client, given the wsdl file.

When I try to generate stub classes for a paypal web service (its wsdl file is here) axis won't generate stubs for both the bindings included to the wsdl but just for the second one (PayPalAPIAASoapBinding)

Has anybody worked on this wsdl with apache's wsdl2java tool before?

2条回答
SAY GOODBYE
2楼-- · 2019-07-25 18:10

I've been struggling with this, too.

Short answer:
Append -pn PayPalAPI to your Axis2 command.

Long answer:
Take a look at following lines of the 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>

Obviously, the WSDL specifies 1 service with 2 ports. Our problem is that Axis2 only creates the stub for the second port, "PayPalAPIAA" but not for the port "PayPalAPI".

Now, take a look at the Axis 2 command line option reference (http://ws.apache.org/axis2/tools/1_2/CodegenToolReference.html#cmdref), specifically, at the description of the option -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."

Thus, specifying -pn PayPalAPI does the trick.

查看更多
我想做一个坏孩纸
3楼-- · 2019-07-25 18:23

apon,
I used Eclipse and created a new Web Service Client project and pointed to the URL you mentioned. I think i was able to create both the stubs. Can you please try creating stubs from Eclipse IDE once?

查看更多
登录 后发表回答