简体   繁体   中英

Cannot generate webservice client with WSDL2Java with WSSE

I'm having trouble generating the client classes using WSDL2Java from Axis1.4. The WSDL contains the header

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"

The error shown is

java.io.IOException: Element {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security is referenced but not defined.
    at org.apache.axis.wsdl.symbolTable.SymbolTable.checkForUndefined(SymbolTable.java:670)
    at org.apache.axis.wsdl.symbolTable.SymbolTable.add(SymbolTable.java:545)
    at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:518)
    at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:495)
    at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
    at java.lang.Thread.run(Thread.java:680)

Params to WSDL2Java are: -o ./src --package ws.generated -v https://myurl/?WSDL

Am I missing a parameter or some special configuration?

I would have to see the entire WSDL to be certain, but it looks like while you have referenced the namespace in defining the wsse prefix, there is no indication to the (wsdl2java) engine where to find the element/type definitions in the namespace. Try adding the following to your WSDL and executing again:

       <wsdl:import namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
       location="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" />

This element should be a peer to <wsdl:types> and <wsdl:message> elements, among others.

This does assume that the wsdl prefix is identified with the namespace for wsdl definitions, a common convention.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM