axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nelson Minar <nel...@monkey.org>
Subject WSDL generation - redone every time? Also a generateWSDL() example
Date Sun, 18 Apr 2004 23:49:56 GMT
I've been experimenting with overriding the WSDL that Axis provides in
a dynamic fashion. Doing more than just substituting a static file.
Following a tip from Tom J I've been doing this via Hander.generateWSDL().
I've learned that WSDL generation happens in
  org.apache.axis.providers.BasicProvider.generateWSDL()

What surprises me is that the work this method does doesn't seem to be
cached at all. I'd naively assumed the bytes for the WSDL would be
generated once, but instead it looks like a new DOM tree is built
everytime the WSDL is created. Is that on purpose, or is this just an
optimization that's not yet done?


I thought I'd also share my code for intercepting the WSDL. The
approach here is to get Axis to generate the WSDL, then capture it and
modify the DOM once you have it. Warning: I haven't actually modified
anything here, but I think it will work :-)

This code belongs in a Handler in the requestFlow.

  /** Handler to override Axis' default WSDL generation, intercepting
   ** the DOM and modifying it how we want.
   **/
  public void generateWSDL(MessageContext ctx) throws AxisFault {
    log.info("Generate WSDL called");
    
    if (ctx.getProperty("WSDL") == null) {
      log.info("No WSDL was set up yet, hacking it in");
      // This method invocation induces Axis to create a WSDL DOM and
      // put it into the message context
      new RPCProvider().generateWSDL(ctx);
    }
    Document wsdl = (Document)ctx.getProperty("WSDL");
    log.info("Found some WSDL, here's a dump of it:");
    log.info(XMLUtils.PrettyDocumentToString((Document)wsdl));
    // We could modify the wsdl DOM now.
  }

Mime
View raw message