Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generating API dynamically from WSDL

 
Yann Emeraud
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Yann Emeraud
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
    Posts: 11962
    5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    Lasse Koskela
    author
    Sheriff
    Posts: 11962
    5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 15
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    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
    Posts: 11962
    5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 15
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    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 ]
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic