简体   繁体   English

通过java程序从WSDL生成java类

[英]Generate java classes from WSDL through java program

I used wsimport command line tool for creating classses but I want to do it from the java code. 我使用wsimport命令行工具来创建类,但我想从java代码中创建它。 Any idea? 任何想法?

It is possible to call the WsImport main() method: 可以调用WsImport main()方法:

import com.sun.tools.ws.WsImport;

...

String[] args = {"put", "your", "arguments", "here"};
WsImport.main(args);

I think that this is what the Ant task does. 我认为这就是Ant任务的作用。


Update: I'm not sure to understand what you're trying to do (and I don't think that you want to generate source code and compile it during runtime). 更新:我不确定你想要做什么(我不认为你想生成源代码并在运行时编译它)。

If the question is actually about doing dynamic invocation, JAX-WS's dynamic invocation interface (DII) is the javax.xml.ws.Dispatch object. 如果问题实际上是关于进行动态调用,则JAX-WS的动态调用接口(DII)是javax.xml.ws.Dispatch对象。 Check JAX-WS's dynamic Dispatch interface . 检查JAX-WS的动态Dispatch接口

You can use the wsimport ant task programatically. 您可以以编程方式使用wsimport ant任务

You can do this by using the task class - com.sun.tools.ws.ant.WsImport . 您可以使用任务类 - com.sun.tools.ws.ant.WsImport来完成此操作。 Instantiate it, set its properties (as defined on the task documentation), and call the execute() method. 实例化它,设置其属性(在任务文档中定义),并调用execute()方法。

What you are trying to achieve is not typical Java Web Services flow. 您要实现的不是典型的Java Web服务流程。 But you can achieve this with dynamic JVM based Groovy language using GroovyWS module. 但是您可以使用GroovyWS模块通过基于动态JVM的Groovy语言实现此目的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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