Saral Saxena
Saral Saxena

Reputation: 121

Regarding client side code generation from 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

Upvotes: 2

Views: 1350

Answers (3)

Khalil
Khalil

Reputation: 259

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>

Upvotes: 1

Alpesh Gediya
Alpesh Gediya

Reputation: 3794

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

Upvotes: 0

user_CC
user_CC

Reputation: 4776

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

Upvotes: 0

Related Questions