关于从WSDL生成客户端代码 [英] Regarding client side code generation from WSDL

查看:80
本文介绍了关于从WSDL生成客户端代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Web服务领域的新手,我必须开发客户端代码(即Java代码),并提供了一个wsdl,可以通过在浏览器中打开该wsdl来看到它,因为我可以访问对于wsdl,请让我知道如何通过Axis 2从该wsdl本身生成客户端代码,将不胜感激,在此先感谢

I am a new bie to the world of webservices , I have to develop the client side code that is the java code,I have been provided a wsdl which I can see by opening that wsdl in the browser , As i have access to wsdl please let me know how can I generate the client side code from that wsdl itself through Axis 2, any help will be appreciated, Thanks in advance

推荐答案

有许多生成客户端和服务器存根的方法. 您可以使用WSDL2Code插件方法 该插件将WSDL作为输入,并生成用于调用或实现与WSDL相匹配的Web服务的客户端和服务器存根. 将以下部分添加到您的POM

There are many ways to generate client and server stubs. you can use WSDL2Code Plug-in approach This plugin takes as input a WSDL and generates client and server stubs for calling or implementing a Web service matching the WSDL. add the following section to your POM

      <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
            <version>1.6.0</version>
            <executions>
                <execution>
                    <id>ws1</id>
                    <goals>
                        <goal>wsdl2code</goal>
                    </goals>
                    <configuration>
                       <unpackClasses>true</unpackClasses>
                       <databindingName>adb</databindingName>
                       <packageName>ma.glasnost.sample.axis2-maven</packageName>
                       <wsdlFile>src/main/resources/ws.wsdl</wsdlFile>
                       <outputDirectory>target/generated-sources</outputDirectory>
                       <syncMode>sync</syncMode>
                    </configuration>
                </execution>
           ..... if you have many web services                
            </executions>
        </plugin>

还添加axis2 jar作为依赖项

Also add axis2 jars as a dependency

 <dependency>
          <groupId>org.apache.axis2</groupId>
          <artifactId>axis2</artifactId>
          <version>1.4</version>
 </dependency>

这篇关于关于从WSDL生成客户端代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆