File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Generating API dynamically from WSDL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Generating API dynamically from WSDL" Watch "Generating API dynamically from WSDL" New topic
Author

Generating API dynamically from WSDL

Yann Emeraud
Greenhorn

Joined: May 03, 2004
Posts: 15
Hi all,

If i am correct, Axis API let you map a XML class description (from the WSDL) to the corresponding java class. But this java class must be on client side first, therefore we lost the dynamic part of it.

Hence, i would like to know if generating a JAVA API from a WSDL and invoking the methods of the generated API is actually possible.
[ May 25, 2004: Message edited by: Yann Emeraud ]
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Originally posted by Yann Emeraud:
But this java class must be on client side first, therefore we lost the dynamic part of it.

Can you explain this sentence more further ?
Actually Axis with the tool called WSDL2Java can generate stubs(java client codes) for a given WSDL URL/file. Now you can use this generated client java code to call the webservices methods.
The generated client codes(stubs or proxy) will have necessary properties and methods which can be used from your servlet/jsp/java code.


Spritle Software Blogs
Yann Emeraud
Greenhorn

Joined: May 03, 2004
Posts: 15

Axis with the tool called WSDL2Java can generate stubs


I need a client capable
  • to show all the operations hold by a WSDL file given during execution time
  • to execute each of them.

  • Therefore a stub cannot help but the DII can do the job.


    Originally posted by Yann Emeraud:
    But this java class must be on client side first, therefore we lost the dynamic part of it.

    Can you explain this sentence more further ?

    If a new operation taking a custom Complex Type (let s say MyBook.java) is added to the server, i don t want to "manually" add the related class binarie (MyBook.class) to all the clients (i.e to patch them everytime i update the server).

    Client should be able to generate dynamically the needed binaries from WSDL.

    I hope this makes me more clear.
    [ May 25, 2004: Message edited by: Yann Emeraud ]
    Lasse Koskela
    author
    Sheriff

    Joined: Jan 23, 2002
    Posts: 11962
        
        5
    Originally posted by Yann Emeraud:
    Client should be able to generate dynamically the needed binaries from WSDL.
    Why isn't DII enough?

    If you really need to generate the "binaries" (.class files) dynamically when the WSDL changes, I guess you could parse the WSDL document with WSDL4J and use some bytecode manipulation API such as ASM, BCEL, Javassist, etc. to generate the .class files.


    Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
    Lasse Koskela
    author
    Sheriff

    Joined: Jan 23, 2002
    Posts: 11962
        
        5
    Originally posted by Yann Emeraud:
    If a new operation taking a custom Complex Type (let s say MyBook.java) is added to the server, i don t want to "manually" add the related class binarie (MyBook.class) to all the clients (i.e to patch them everytime i update the server).

    By the way, if you only add an operation, the clients don't need to change unless they suddenly need to use that new operation.
    Yann Emeraud
    Greenhorn

    Joined: May 03, 2004
    Posts: 15

    By the way, if you only add an operation, the clients don't need to change unless they suddenly need to use that new operation.


    In fact, the purpose of my client is to let the user execute any operation hold by the server at any moment.

    And several new operations are supposed to be added very often to the server.

    This is the problem
    [ May 26, 2004: Message edited by: Yann Emeraud ]
    Lasse Koskela
    author
    Sheriff

    Joined: Jan 23, 2002
    Posts: 11962
        
        5
    Originally posted by Yann Emeraud:
    In fact, the purpose of my client is to let the user execute any operation hold by the server at any moment.

    How would the client know how to use one of the new operations?
    If the operation's signature is, for example, doSomethingNew(String, String, int), what will the client code pass in as parameters?
    Yann Emeraud
    Greenhorn

    Joined: May 03, 2004
    Posts: 15

    If the operation's signature is, for example, doSomethingNew(String, String, int), what will the client code pass in as parameters


    The client parse the WSDL file, retrieve the number of parameters and show the same number of inputBoxes for a selected operation.
    It cast whenever it is needed.
    And show the answer with a String.

    Reading the doSomethingNew specification, it will show 3 boxes and cast the input to String String and int respectively.

    The client knows that some Complex types may be passed as parameters (e.g MyBook.java with 2 fields name and id).

    If the Complex Types are update by server, i would like to see the client generating the relative binaries only by reading the WSDL file.

    If that is possible.
    [ May 26, 2004: Message edited by: Yann Emeraud ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Generating API dynamically from WSDL
     
    Similar Threads
    Problem in returning an array in a container
    Equalivent command for WSDL2Java in Weblogic 10g
    Axis 1.3 - WSDL2JAVA issue
    java.lang.reflect.InvocationTargetException in generating WDSL from java usinng Axis2 and eclipse
    WSDL2JAVA generating some unnecessary holder classes