eclipse 如何将 wsdl 转换为 java?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7020755/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to convert wsdl to java?
提问by nag
I've a WSDL file and i need to convert it into java, so for this i use step by step procedure from below link
我有一个 WSDL 文件,我需要将它转换成 java,所以为此我使用下面链接中的分步程序
http://axis.apache.org/axis2/java/core/tools/eclipse/wsdl2java-plugin.html
http://axis.apache.org/axis2/java/core/tools/eclipse/wsdl2java-plugin.html
like adding axis2 codegen jar file into dropins folder in eclipse folder and restarted eclipse but i didn't get "Axis2 Wizard" in my eclipse IDE, so any one plz help me to get out of this.
就像将axis2 codegen jar文件添加到eclipse文件夹中的dropins文件夹并重新启动eclipse一样,但我在eclipse IDE中没有得到“Axis2向导”,所以请任何人帮助我摆脱这种情况。
Thanks, @nagaraju.
谢谢,@nagaraju。
回答by User
Recently I have to convert a WSDL file to Java code. I tried Axis2 Plugins with my Eclipse-Indigo and failed. I tried it in many ways but failed. Wasted my precious time and energy. I would like to suggest you one easy way i succeeded.
最近我必须将 WSDL 文件转换为 Java 代码。我用我的 Eclipse-Indigo 尝试了 Axis2 插件,但失败了。我尝试了很多方法,但都失败了。浪费了我宝贵的时间和精力。我想向你推荐一种我成功的简单方法。
- Create a Java Project:File->New->Other->Java Project. (Suppose I named it TestWSDL)
- Create a WSDL File:File->New->Other->Web Services->WSDL File-> Name the file->Next->finish. (Suppose I named it NewWSDLFile.wsdl)
- Modify the WSDL File:Open NewWSDLFile.wsdl and replace all its content by your desired WSDL file.Save it. (Suppose I have saved my desired wsdl file at D:\sampleWSDL.xml, which i want to convert. Open this xml file using Notepad++,copy all its content and paste it to NewWSDLFile.wsdl)
- Create Web Service Client:File->New->Other->Web Services->Web Service Client->Next->Browse Service definition and show the path of the NewWSDLFile.wsdl file we created at step 2 ->OK-> Click Client Project(blue colored link at right) and set it to the project we created at step 1.
- Press Next -> Set Output Folder->Finish.
- You will have all the converted Java files at the folder you set at step 5.
- 创建 Java 项目:文件->新建->其他->Java 项目。(假设我将其命名为 TestWSDL)
- 创建 WSDL 文件:File->New->Other->Web Services->WSDL File-> Name the file->Next->finish。(假设我将其命名为 NewWSDLFile.wsdl)
- 修改 WSDL 文件:打开 NewWSDLFile.wsdl 并用所需的 WSDL 文件替换其所有内容。保存它。(假设我已将所需的 wsdl 文件保存在 D:\sampleWSDL.xml 中,我想对其进行转换。使用 Notepad++ 打开此 xml 文件,复制其所有内容并将其粘贴到 NewWSDLFile.wsdl)
- 创建 Web Service Client:File->New->Other->Web Services->Web Service Client->Next->Browse Service definition 并显示我们在步骤 2 中创建的 NewWSDLFile.wsdl 文件的路径 ->OK-> 单击客户端项目(右侧的蓝色链接)并将其设置为我们在步骤 1 中创建的项目。
- 按下一步-> 设置输出文件夹-> 完成。
- 您将在步骤 5 中设置的文件夹中拥有所有转换后的 Java 文件。
回答by Anuj Balan
There are two things you can do here. You can use that plugin or use web service wizard(which is available in Eclipse 3.3 also).
您可以在这里做两件事。您可以使用该插件或使用 Web 服务向导(也可以在 Eclipse 3.3 中使用)。
(i) Using the plugin::You can download the latest Eclipse WSDL2JAVA Codegen plugin, paste it in the plugins folder of eclipse folder. Start the eclipse and you can find the Axis Codegen plugin on pressing ('Ctrl+N') or under 'File/New/Other/Axis'
(i)使用插件::您可以下载最新的Eclipse WSDL2JAVA Codegen 插件,将其粘贴到eclipse 文件夹的plugins 文件夹中。启动 Eclipse,您可以在按 ('Ctrl+N') 或在'File/New/Other/Axis'下找到 Axis Codegen 插件
(ii) Using the Web Service plugin:Press 'Ctrl+N ', and go to Web Service/Web Service Client. Paste the url(WSDL), select the client project you are working on, press next, specify the output folder and press finish.
(ii)使用 Web Service 插件:按“Ctrl+N”,然后转到 Web Service/Web Service Client。粘贴 url(WSDL),选择您正在处理的客户端项目,按下一步,指定输出文件夹并按完成。
Any of these two steps will generate the client stub(java code) for the wsdl you have given.
这两个步骤中的任何一个都会为您提供的 wsdl 生成客户端存根(java 代码)。
回答by Bennya
i founded this tool to auto generate wsdl to android code,
我创建了这个工具来自动生成 wsdl 到 android 代码,
http://www.wsdl2code.com/example.aspx
http://www.wsdl2code.com/example.aspx
SampleService srv1 = new SampleService();
req = new Request();
req.companyId = "1";
req.userName = "userName";
req.password = "pas";
Response response = srv1.ServiceSample(req);