Regarding client side code generation from WSDL

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 03:43:22

问题


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


回答1:


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>

Also add axis2 jars as a dependency

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



回答2:


Here a brief overview what you will have to do to generate the client-side java code:

  1. Open the URL pointing to wsdl document in the webbrowser.
  2. Save that webpage as a xml document.
  3. Rename the file to have a .wsdl extension (optional)
  4. Then you need to run the WSDLToJava java file through the java command this class will be contained in the axis.jar
  5. Provide the wsdl filename as an argument to this java file.
  6. Provide all the jar files needed as a classpath argument to this java command

So your command will look something like below:

java -classpath axis.jar;%CATALINA_HOME%/shared/lib/commons-httpclient.jar;%CATALINA_HOME%/shared/lib/log4j.jar;%CATALINA_HOME%/shared/lib/commons-logging.jar;wsdl4j.jar;commons-net.jar;commons-discovery.jar;jaxrpc.jar;soap.jar;saaj.jar org.apache.axis.wsdl.WSDL2Java your_wsdl_fileName.wsdl




回答3:


If you are using Eclipse then use Java code generation as mentioned in this link.http://axis.apache.org/axis2/java/core/tools/eclipse/wsdl2java-plugin.html#WSDL2Java



来源:https://stackoverflow.com/questions/16057417/regarding-client-side-code-generation-from-wsdl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!