Skip to main content

Web Services with Apache Axis 1.4 Tutorial: server and client sides

Web services are a handy method of integrating independent systems. Apache Axis is one of the best free tools available for implementing and deploying web services, and also for implementing the web service clients. In this article we will create a simple, but complete web service and a client for this service step-by-step. Article will be explanatory as much as possible to succeed you in implementing it yourself alone after completing this tutorial.

Prerequisites

  • Must be familiar with Java
  • Familiar with basics on a web server like Tomcat
  • Some knowledge in configuring Axis will be an added advantage

System Configuration Requirements

We will be discussing the configuration in brief as our scope is mainly on web services. (If Axis already configured, jump to implementation). If you find any issues on the configuration part, you can refer to Apache Axis site for troubleshooting. (But if you can not solve it yourself do not worry, post the issue under the comments section in this article, and we’ll get back to you).

JDK installation
These examples have been tested on a machine with JDK 1.6 version.

Web Server
You must have a web server installed; and we will be using Tomcat (5.5 version) web server. If you are not having one, better download Tomcat here{link} and install it yourself (it is quite easy to install Tomcat). Now your CATALINA_HOME environment variable should point to the Tomcat installation directory.

Apache Axis 1.4
Download Apache Axis 1.4. Extract the downloaded file and you’ll find a folder named “axis” inside webapps folder.
%Axis_1.4_dir%\webapps\axis
Copy this “axis” folder into your web server’s webapps folder.
%CATALINA_HOME%\webapps

CLASS PATH
Now you must add following libraries into your CLASSPATH environment variable. All of these are available under %Axis_1.4_dir%\lib folder.
  • axis.jar
  • commons-discovery.jar
  • commons-logging.jar
  • jaxrpc.jar
  • log4j-1.2.8.jar
  • saaj.jar
  • wsdl4j.jar
That’s all for configuring Axis 1.4 on your system, quite easy isn’t it? Let’s move on to the implementation part.

Implementation - web service and client

The implementation will consist of two parts. First we will implement web service part; a Calculator will be exposed as a web service. Next a client to use this Calculator web service will be implemented. (Client part starts from here).

Calculator Web Service

Implementing the web service consists of 7 steps. We will be explaining each step in detail.
  1. Functionality provider
  2. Web service’s interface
  3. Java2WSDL - Generate WSDL file
  4. WSDL2Java - Generate server side and client side classes for web service
  5. Bind Web service with Functionality provider
  6. Bundle required classes
  7. Register web service with axis

Project structure

Before starting coding, we'll have a look at the project structure. We are using a separate folder for the project, called "WS-Sample". We will be creating source (.java) files under "WS-Sample\src" folder and storing generated class (.class) files under a "WS-Sample\classes" folder.

1. Functionality provider

First we need to write class with calculator functionality before exposing it as a web service. We have implemented it as a pretty complex high end calculator class, named SimpleCalculator and it's listed below. (It is just a pretty simple class with three methods). This class has no information related to a web service and has been written as a simple independent class. So in the time this class was written, no one has thought of any web service stuff. But we will expose this class as a web service. (Yes, what you guessed is correct. Later you can expose your existing Java classes as web services.)
package org.kamal.wssample;

public class SimpleCalculator {
    public int add(int a, int b) {
        return a + b;
    }
    public int subtract(int a, int b) {
        return a - b;
    }
    public int multiply(int a, int b) {
        return a * b;
    }
}
We'll compile above class using following command so that the generated .class file will reside in a folder named "classes" while preserving the package structure.
WS-Sample\src> javac -d ..\classes 
                    org\kamal\wssample\SimpleCalculator.java

2. Web service’s interface

Now we should write an interface that defines the services that will be provided by our web service. We will expose only two methods through our service; add() and subtract() methods (although we can expose any number of services within one web service). We did choose only two methods to emphasize the fact that we can control which methods we expose. And we will write this class in a separate package; org.kamal.wssample.ws.
package org.kamal.wssample.ws;

public interface Calculator {
    int add (int x, int y);
    int subtract(int x, int y);
}
And compile using following command.
WS-Sample\src> javac -d ..\classes 
                        org\kamal\wssample\ws\Calculator.java

3. Java2WSDL - Generate WSDL file

Axis has a tool called Java2WSDL, which generates a WSDL file for a web service using a Java class. We should use the Calculator interface and generate WSDL file as follows. Java2WSDL file requires the Calculator.class file (not Calculator.java) for the operation. Also we will provide the following information.
  • o – name for WSDL file -> calculator.wsdl
  • n – target namespace -> urn:org.kamal.calculator
  • l – url of web service -> http://localhost:8080/axis/services/calculator
WS-Sample\classes> java org.apache.axis.wsdl.Java2WSDL 
                         -o ..\calculator.wsdl
                         -n urn:org.kamal.calculator 
                         -l http://localhost:8080/axis/services/calculator
                         org.kamal.wssample.ws.Calculator
This command will generate a file named calculator.wsdl inside your project folder.

4. WSDL2Java - Generate server side and client side classes for web service

Axis has another tool named WSDL2Java, which can generate server side and client side Java classes using a WSDL file. These classes are needed for deploying the web service and for accessing the service by a Java client. This tool must be provided with WSDL file that we generated in the previous step. It needs the following information as well.
  • o – output folder -> src
  • p – package for generated classes -> org.kamal.wssample.ws.generated
  • s – generate server side classes as well
WS-Sample> java org.apache.axis.wsdl.WSDL2Java 
                 -o src 
                 -p org.kamal.wssample.ws.generated 
                 -s 
                 calculator.wsdl
Generated java classes will be saved in org.kamal.wssample.ws.generated package. This tool will generate five Java classes in this case with two .wsdd files as listed below.
  • Calculator.java
  • CalculatorService.java
  • CalculatorServiceLocator.java
  • CalculatorSoapBindingImpl.java
  • CalculatorSoapBindingStub.java
  • deploy.wsdd
  • undeploy.wsdd
Now we should compile those generated classes using the following command.
WS-Sample\src> javac –d ..\classes 
                   org\kamal\wssample\ws\generated\*.java

5. Bind Web service with Functionality provider

As you may have noted; even though we wrote org.kamal.wssample.SimpleCalculator class at the start, we have not used it so far. Now we are going to bind it to the web service.

There is a class named CalculatorSoapBindingImpl inside org.kamal.wssample.ws.generated package. This is the class used to bind our existing SimpleCalculator class to the web service calls. In CalculatorSoapBindingImpl class, there are two methods; add() and subtract(). In this class, we can use the SimpleCalculator to call the actual methods as follows.
package org.kamal.wssample.ws.generated;

import org.kamal.wssample.SimpleCalculator;

public class CalculatorSoapBindingImpl implements 
                org.kamal.wssample.ws.generated.Calculator {
    private SimpleCalculator calc = new SimpleCalculator();
    public int add(int a, int b) throws java.rmi.RemoteException {
        return calc.add(a, b);
    }
    public int subtract(int from, int x) throws java.rmi.RemoteException {
        return calc.subtract(from, x);
    }
}
Just analyze the above class, all method calls are delegated to the actual implementation class SimpleCalculator inside this binding class.

6. Bundle required classes

Now we will create a jar file with all these classes, so that we can use it for deploying our web service. Use the jar command as follows.
WS-Sample\classes> jar cvf ..\calculatorServerSide.jar
                           org\kamal\wssample\*.class
                           org\kamal\wssample\ws\*.class
                           org\kamal\wssample\ws\generated\*.class
Now copy this jar file into %CATALINA_HOME%\webapps\axis\WEB-INF\lib folder.
WS-Sample> copy calculatorServerSide.jar 
             "%CATALINA_HOME%\webapps\axis\WEB-INF\lib"

We will create another jar file to use in the client side. For the client side we only need the classes that were generated by the WSDL2java tool (which are located inside org\kamal\wssample\ws\generated package), except the CalculatorSoapBindingImpl class.
WS-Sample\classes> jar cvf ..\calculatorClientSide.jar
                              org\kamal\wssample\ws\generated\CalculatorSoapBindingStub.class
                              org\kamal\wssample\ws\generated\CalculatorServiceLocator.class
                              org\kamal\wssample\ws\generated\CalculatorService.class
                              org\kamal\wssample\ws\generated\Calculator.class

7. Register web service with axis

Axis comes with a tool for registering web services with Axis; it is called AdminClient. Look into org\kamal\wssample\ws\generated folder and you will find two WSDD (web service deployment descriptor) files; deploy.wsdd and undeploy.wsdd. These files were generated by WSDL2Java tool and as used in deploying/undeploying a web service.

Note: (Tomcat) Server must be started before executing the following command.
WS-Sample\src> java org.apache.axis.client.AdminClient 
                       org\kamal\wssample\ws\generated\deploy.wsdd
This command will deploy the web service into axis. Now restart (Tomcat) server.

To verify our web service is deployed correctly; try following url from your browser.
http://localhost:8080/axis/services/calculator?wsdl
(change the port 8080 in url to match the port on your machine)

This will show up a complete wsdl file, and it is the complete definition of the web service that we have deployed.

Now everything on web service (server side) is completed and our web service is successfully deployed.

Web Service client

Now it’s time for us to write a client to access this web service and use provided services. For this we need the calculatorClientSide.jar file that we created in an earlier step.

For the client side we will create a new project folder named “WS-Client” with sub folders named src, classes and lib. Copy the generated calculatorClientSide.jar file into the "WS-Client\lib" folder.


We will create the client as follows. Since our web service exposed two methods, add() and subtract(); client class will use the service and call those add() and subtract() methods.
package org.kamal.wsclient;

import org.kamal.wssample.ws.generated.Calculator;
import org.kamal.wssample.ws.generated.CalculatorService;
import org.kamal.wssample.ws.generated.CalculatorServiceLocator;

public class CalcClient {
    public static void main(String[] args) throws Exception {
        CalculatorService service =  new CalculatorServiceLocator();
 Calculator calc = service.getcalculator();
 System.out.println("15 + 6 = " + calc.add(15, 6));
 System.out.println("15 - 6 = " + calc.subtract(15, 6));
    }
}
The above class has not used even a single class that we wrote for Calculator implementation, only a few classes that WSDL2Java tool generated. We have not exposed the server side classes, but just provided a way to get the service from those classes.

Compile the class with following command.
WS-Sample-Client\src> javac -classpath %CLASSPATH%;..\lib\calculatorClientSide.jar 
                            -d ..\classes 
       org\kamal\wsclient\CalcClient.java
Now we can run our web service client using following command.
WS-Sample-Client\classes> java -cp %CLASSPATH%;.;..\lib\calculatorClientSide.jar 
                               org.kamal.wsclient.CalcClient
You would see the following as the result.
15 + 6 = 21
15 – 6 = 9
Our web service client, CalcClient has accessed the web service and received the results from the operations done by SimpleCalculator class (which is running on server side).

As you can see, generating the client side is much easier than the server side.

Related Articles

Comments

  1. I'm new to web services. Thanks this helped me a lot.

    ReplyDelete
  2. Nice work, thanks.

    ReplyDelete
  3. This is what i have been looking for simple easy to understand...my kind of tutorial


    thanks
    kris

    ReplyDelete
  4. while Generating WSDL file using java2wsdl this exception occur.I have added mentioned jar files in classpath.pls help me


    E:\WS-Sample\src>java org.apache.axis.wsdl.Java2WSDL -o ..\calculator.wsdl -n ur
    n:org.kamal.calculator -l http://localhost:8080/axis/services/calculator org.kam
    al.wssample.ws.Calculator
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl/
    Java2WSDL


    E:\WS-Sample\src>echo %CLASSPATH%
    E:\axis-1_4\lib

    ReplyDelete
  5. This error has caused because your CLASSPATH is incorrect.

    CLASSPATH=E:\axis-1_4\lib

    In setting the CLASSPATH, you should point to your jar files rather than the lib directory like;
    CLASSPATH=E:\axis-1_4\lib\axis.jar;E:\axis-1_4\lib\commons-discovery.jar;.. etc.

    Try that and let me know whether you could resolve the issue.

    ReplyDelete
  6. while compailing the generated class file the following is occur please help me,reply as soon as posible


    C:\Users\COMPAQ-GTI\Desktop\work\axis-ex\WS-Sample\src>javac -d C:\Users\COMPAQ-GTI\Desktop\work\axi
    s-ex\WS-Sample\classes.gen org\kamal\wssample\ws\generated\*.java
    org\kamal\wssample\ws\generated\CalculatorSoapBindingStub.java:32: as of release 1.5, 'enum' is a ke
    yword, and may not be used as an identifier
    (try -source 1.4 or lower to use 'enum' as an identifier)
    oper.setStyle(org.apache.axis.enum.Style.RPC);
    ^
    org\kamal\wssample\ws\generated\CalculatorSoapBindingStub.java:33: as of release 1.5, 'enum' is a ke
    yword, and may not be used as an identifier
    (try -source 1.4 or lower to use 'enum' as an identifier)
    oper.setUse(org.apache.axis.enum.Use.ENCODED);
    ^
    org\kamal\wssample\ws\generated\CalculatorSoapBindingStub.java:43: as of release 1.5, 'enum' is a ke
    yword, and may not be used as an identifier
    (try -source 1.4 or lower to use 'enum' as an identifier)
    oper.setStyle(org.apache.axis.enum.Style.RPC);
    ^
    org\kamal\wssample\ws\generated\CalculatorSoapBindingStub.java:44: as of release 1.5, 'enum' is a ke
    yword, and may not be used as an identifier
    (try -source 1.4 or lower to use 'enum' as an identifier)
    oper.setUse(org.apache.axis.enum.Use.ENCODED);
    ^
    4 errors

    ReplyDelete
  7. Hi,

    As the error message shows, it's due an invalid use of 'enum' keyword. What is the version that you are using, 1.4 or 1.5?

    Let me know the followings you used.
    1. JRE version
    2. JDK version

    Cheers.

    ReplyDelete
  8. Uday's question:
    while deploying the web services the following occurs

    > java org.apache.axis.client.AdminClient org\
    kamal\wssample\ws\generated\deploy.wsdd
    Processing file org\kamal\wssample\ws\generated\deploy.wsdd
    Exception: AxisFault
    faultCode: {http://xml.apache.org/axis/}HTTP
    faultSubcode:
    faultString: (404)Not found
    faultActor:
    faultNode:
    faultDetail:
    {}:return code: 404

    The requested URL /axis/services/AdminService was not found on this server

    {http://xml.apache.org/axis/}HttpErrorCode:404

    ReplyDelete
  9. Hi Uday,

    You must start Tomcat with Axis, before running this command. It seems your Tomcat server is not started yet. Try again after starting it.

    ReplyDelete
  10. thanks for reply
    i started tomcat(5.5),my os is vista, i set classpath pointing to alljar files in axis 1.4\lib

    ReplyDelete
  11. Hi Uday,

    Were you able to resolve the issue after starting Tomcat?

    ReplyDelete
  12. thanks for replay

    I followed all the above steps
    I)os vista
    i)installed j2sdk 1.5
    2)installed tomcat 5.5
    3)installed axis 1.4

    i successfully executed all 6 steps above .
    started tomcat(5.5) and validated
    http://localhost:8080/axis/happyaxis.jsp
    while executing the error is occurring.

    ReplyDelete
  13. Uday,

    In your error we see that the AdminService is not available.
    "The requested URL /axis/services/AdminService was not found on this server".

    So please verify your AdminService is up and running with following URL.

    http://localhost:8080/axis/services/AdminService?wsdl

    ReplyDelete
  14. thanks for reply
    how to enable AdminService

    ReplyDelete
  15. Uday, you don't have to enable it explicitly, it should be enabled by default. (Not sure whether there's any restrictions on Vista).

    ReplyDelete
  16. Kamal Mettananda

    An Excellent article for a newbie like me. Keep it up.

    Thanks a lot.

    ReplyDelete
  17. Hi Srinivas,

    Thanks for your appreciation. It really encourages me.

    Kamal

    ReplyDelete
  18. C:\WS-Sample\src>java org.apache.axis.client.AdminClient org\kamal\wssample\ws\generated\deploy.wsdd
    Processing file org\kamal\wssample\ws\generated\deploy.wsdd
    Exception: AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}
    Server.userException
    faultSubcode:
    faultString: org.xml.sax.SAXNotRecognizedException: Feature: http://xml.org/sax
    /properties/lexical-handler
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}
    stackTrace:org.xml.sax.SAXNotRecognizedExce
    ption: Feature: http://xml.org/sax/properties/lexical-handler
    at org.apache.xerces.jaxp.SAXParserImpl.
    setProperty(SAXParserImpl.java:1
    55)
    at org.apache.axis.encoding.
    DeserializationContext.parse(Deserialization
    Context.java:226) ....

    ReplyDelete
  19. Hi Uday,

    Seems you have been able to resolve the AdminService issue.

    To resolve this exception, try adding the latest xerces jar to your class path.

    ReplyDelete
  20. Excellent tutorial, You made me life simpler. You should start writing books.

    If you have similar tutorial on WS-Management and Wiseman implementation, please share with me. My email address vponnuru23@yahoo.com

    ReplyDelete
  21. Hi vponnuru,

    I'm really happy to hear your comments. At this moment, this is the only tutorial on web services (read other tutorials here).
    Please subscribe through email or RSS (shown at the top of the site) to receive the latest content.

    ReplyDelete
  22. Hi,

    When i am performing this step getting problem like
    D:\WS-Sample\src>java org.apache.axis.client.AdminClient org\kamal\wssample\ws\generated\deploy.wsdd
    Processing file org\kamal\wssample\ws\generated\deploy.wsdd
    Exception:: java.lang.NullPointerException

    Kindly help me for the same.

    Thanks,
    Manjesh Kumar

    ReplyDelete
  23. Hi Manjesh,

    Don't worry, we'll work together and get this resolved.

    Can you post the complete stack trace, so that we can pick the place where this exception is thrown?

    ReplyDelete
  24. I am trying to create WS according to your guidance steps. i have complete till 6th steps successfully but when i am trying to perform 7th step as following
    D:\WS-Sample\src>java org.apache.axis.client.AdminClient org\kamal\wssample\ws\generated\deploy.wsdd
    Processing file org\kamal\wssample\ws\generated\deploy.wsdd
    Exception:: java.lang.NullPointerException

    getting problem. Kindly help me.


    Regards,
    Manjesh Kumar

    ReplyDelete
  25. Manjesh,

    Is this all that you see in the error message? Isn't there any other information in the error message?

    I will need some more information as this does not tell anything that can be used in resolving the issue.

    ReplyDelete
  26. Hi,

    Can i get any link to create axis ws using SOAP Monitor.

    Thanks.

    Manjesh Kumar

    ReplyDelete
  27. Tomcat 5.5
    JDK 6
    Axis 1.4
    Windows Vista

    When I try to access http://localhost:8080/axis/services/calculator?wsdl, I get an exception.

    Exception - java.lang.UnsupportedClassVersionError: Bad version number in .class file

    Did try few things but no success. Ultimate solution used Tomcat6. It worked.

    Hope this helps.

    ReplyDelete
  28. Hi Manjesh,

    I'll try to post the details of setting up SOAP monitor as soon as possible. Please get subscribed through email, so that you will get notified.

    ReplyDelete
  29. Hi,
    This UnsupportedClassVersionError error must be raised due to version issue described here.

    Anyway thanks for sharing it with our readers.

    ReplyDelete
  30. Hi,

    Thanks, for such a nice article.Can u please also post some content on how to make a small part of already written application , a web service.My web App is already in place ,now i have to write a web service so that some PDF can access some functionality of my web App.Thanks, SS

    ReplyDelete
  31. Hi,

    While I'm generating the server and client slide classes through the following command.

    E:\jakarta-tomcat-5.0.28\webapps\axis>java org.apache.axis.wsdl.WSDL2Java -o src -p org.kamal.wssample.ws.generated -s NHLService.wsdl

    I'm getting this error below:


    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl/WSDL2Java

    ReplyDelete
  32. Hi,

    I'll try to provide you with a post on exposing existing functionalities as web services.

    ReplyDelete
  33. Hi,

    // Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl/WSDL2Java

    Your CLASSPATH variable does not point to all necessary .jar files. Just add them as I have mentioned at the start of the tutorial and try again.

    If you still have the issue, post us value of the CLASSPATH variable.

    ReplyDelete
  34. Thanks, this is really helpful.

    I'm going to subscribe to your site to get updates.

    ReplyDelete
  35. Hi Kamal, i have seen your article and it's really a good one for a newbie to web services. I hope you will help me with some issues in dealing with Apache Axis..I have generated a a server side classes from the given WSDL. Also, i have written a client side API which interfaces with those proxy classes, which i generated from the wsdl using axis..Now, i have written a client-side java program that uses the Client side API to invoke the service on the Server side...for that java program, i have to pass a SOAP request and i couldn't figure it out how all these pieces interact and come into work...any suggestions would be of great help...have a good day

    ReplyDelete
  36. Thanks a lot, this is pretty good

    ReplyDelete
  37. Hi

    Why I never found axis.jar in the lib folder? There are only axis2-adb-1.4.1.jar, axis2-adb-codegen-1.4.1.jar, axis2-kernel-1.4.1.jar... axix-*** jar files.

    Thanks.

    ReplyDelete
  38. Hi,
    I am very new to Axis WS. i am trying to run simple WS but getting problem.
    1) First created AddFunction.java file as
    public class AddFunction
    {
    public int add(int a, int b){
    System.out.println("Inside of WS: A="+a+"and B="+b);
    int sum = a+b;
    System.out.println("SUM : "+sum);
    return sum;
    }
    }

    2) copy it to ..axis\AddFunction.java and renamed as AddFunction.jws
    3) created server-config.wsdd in axis\WEB-INF

    and also mapped AddFunction WS as service in server-config.wsdd file

    4) Now created Client side file (i.e AddFunctionClient.java) to call AddFunction WS as following
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;

    import javax.xml.namespace.QName;

    public class AddFunctionClient
    {
    public static void main(String [] args) {
    try {
    if (args.length < 2){
    System.out.println("Usage:: java AddFunctionClient num1 num2");
    return;
    }
    int a = Integer.parseInt(args[0]);
    int b = Integer.parseInt(args[1]);
    String endpoint = "http://localhost:8080/axis/AddFunction.jws";

    Service service = new Service();
    Call call = (Call) service.createCall();
    call.setOperationName(new QName("http://localhost:8080/axis/AddFunction.jws", "add"));
    call.setTargetEndpointAddress( new java.net.URL(endpoint) );
    System.out.println("Usage:: ");
    Integer ret = (Integer) call.invoke( new Object[] { new Integer(a), new Integer(b)} );

    System.out.println("addInt(" + a + " + " + b + ") = " + ret);
    } catch (Exception e) {
    System.err.println("Execution failed. Exception: " + e);
    }
    }
    }

    5) When i am running the AddFunctionClient file by typing command as following
    java AddFunctionClient 10 20
    getting problem like
    Execution failed. Exception: java.lang.NullPointerException



    But on server side WS prited after getting call as
    17:08:06,833 INFO [STDOUT] Inside of WS: A=1and B=2
    17:08:06,833 INFO [STDOUT] SUM : 3


    Kindly sir let me know why i am geeting "Execution failed. Exception: java.lang.NullPointerException" problem at client side.

    or let me know other way if you have.

    Thanks in advance.

    Regards,
    Manjesh Kumar

    ReplyDelete
  39. // Why I never found axis.jar in the lib folder

    Seems you have downloaded Axis2 rather than Axis 1.4. Please download Axis 1.4 from here.

    ReplyDelete
  40. Hi Manjesh,

    To find out the place where NullPointerException is thrown, can you give the full stack trace of the exception.

    ReplyDelete
  41. Hi Kamal,

    after executing all the steps, I got the following exception while running the client......... Can you say the reason. I didn't also got wsdl on IE for calculator

    -------------

    c:\WS-Sample\WS-Sample-Client\classes>java -classpath %CLASSPATH%;.;..\lib\calcu
    latorClientSide.jar org.kamal.wsclient.CalcClient
    - Unable to find required classes (javax.activation.DataHandler and javax.mail.i
    nternet.MimeMultipart). Attachment support is disabled.
    Exception in thread "main" AxisFault
    faultCode: {http://xml.apache.org/axis/}Server.NoService
    faultSubcode:
    faultString: The AXIS engine could not find a target service to invoke! target
    Service is calculator
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}hostname:IND-1K151BSH1

    The AXIS engine could not find a target service to invoke! targetService is cal
    culator
    at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder
    .java:222)
    at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.
    java:129)
    at org.apache.axis.encoding.DeserializationContext.endElement(Deserializ
    ationContext.java:1087)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endEleme
    nt(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scan
    EndElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
    l$FragmentContentDispatcher.dispatch(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
    l.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
    nknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
    nknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown So
    urce)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Un
    known Source)
    at javax.xml.parsers.SAXParser.parse(Unknown Source)
    at org.apache.axis.encoding.DeserializationContext.parse(Deserialization
    Context.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnders
    tandChecker.java:62)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at org.kamal.wssample.ws.generated.CalculatorSoapBindingStub.add(Calcula
    torSoapBindingStub.java:118)
    at org.kamal.wsclient.CalcClient.main(CalcClient.java:13)

    c:\WS-Sample\WS-Sample-Client\classes>

    ReplyDelete
  42. //I didn't also got wsdl on IE for calculator
    First try the AxisServlet to get a list of all the services deployed on your Axis instance using following link.

    http://localhost:8080/axis/servlet/AxisServlet

    Check whether you can see your Calculator service there.

    ReplyDelete
  43. Good job on this article. I'm having a problem with the last step. I got all the way to the web service client and am gettting a NullPointerException in the client code. It looks like the "service.getCalculator()" code returns null. I have deployed the service to the server and I am able to access the wsdl via
    http://localhost:8080/axis/services/calculator?wsdl

    Basically, when "calc.add()" is called in the client, the "calc" object is null.

    Does anybody have a clue what is wrong here?

    Thanks!

    ReplyDelete
  44. thanks for your helpful tutorial. however, I get an error at "3. Java2WSDL - Generate WSDL file".
    when I want to execute the command:
    java org.apache.axis.wsdl.Java2WSDL -o ..\calculator.wsdl -n urn:org.kamal.calculator -l http://localhost:8080/axis/services/calculator org.kamal.wssample.ws.Calculator

    according to your instructions I always get this error:
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl/
    Java2WSDL
    Caused by: java.lang.ClassNotFoundException: org.apache.axis.wsdl.Java2WSDL
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    I checked the classpath, I have all the mentioned .JAR files linked in there. I also execute the commans from the correct path "\WS-Sample\classes".

    any hints what else could be the problem?

    thank you!

    ReplyDelete
  45. me again. I could solve the problem. solution for me was this command:
    set CLASSPATH=C:\axis-1_4\lib\axis.jar;C:\axis-1_4\lib\commons-discovery-0.2.jar;C:\axis-1_4\lib\commons-logging-1.0.4.jar;C:\axis-1_4\lib\jaxrpc.jar;C:\axis-1_4\lib\log4j-1.2.8.jar;C:\axis-1_4\lib\saaj.jar;C:\axis-1_4\lib\wsdl4j-1.5.1.jar;

    as a help for others. I first was searching to find the solution in Eclipse in the project. Although I had to set the classpath with the command prompt.

    ReplyDelete
  46. Hi E-Nature,

    Thanks for sharing your experience with our readers.

    Another alternative to this is to set an Environment variable named CLASSPATH with these libs.

    ReplyDelete
  47. Error at: "7. Register web service with axis"

    wrong:
    java org.apache.axis.client.AdminClient
    org\kamal\wsample\ws\generated\deploy.wsdd

    correct (with two 's'):
    java org.apache.axis.client.AdminClient
    org\kamal\wssample\ws\generated\deploy.wsdd

    ReplyDelete
  48. Hi Kamal,

    I am getting following error, while deploying.Could you please, look at the same. I have provided all class path and path correctly.

    Exception: AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.net.ConnectException: Connection refused: connect
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:519)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:153)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:120)
    at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
    at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:1792)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:439)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:404)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:410)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:320)
    at org.apache.axis.client.AdminClient.main(AdminClient.java:463)

    ReplyDelete
  49. // faultString: java.net.ConnectException: Connection refused: connect

    Seems you haven't stared Tomcat before running the AdminClient. You must start Tomcat before running this.

    ReplyDelete
  50. // correct (with two 's'):

    E-Nature, I'm fixing it right now.

    Thanks for pointing.

    ReplyDelete
  51. Hi Kamal,

    Thanks for following answer, but I have started/restarted tomcat multiple times but without any success.

    I changed the command to
    java org.apache.axis.client.AdminClient -l http://localhost:8084/axis/services/AdminService /pathname/deploy.wsdd

    and it worked.


    // faultString: java.net.ConnectException: Connection refused: connect

    Seems you haven't stared Tomcat before running the AdminClient. You must start Tomcat before running this.

    ReplyDelete
  52. Hi Kamal,

    Do you have any step by step example where a external webservice is called using axis(wsdl2java) e.g. StockQuote.

    Thanks.

    ReplyDelete
  53. // java org.apache.axis.client.AdminClient -l http://localhost:8084/axis/services/AdminService

    As you have been running Tomcat on port 8084, the above url must be used.

    ReplyDelete
  54. Hi Kamal,

    Thanks for your wonderful tutorial.
    Everything works fine for me but when i am trying to run the client i am getting exception, please find the stack trace below,
    Exception in thread "Main Thread" AxisFault
    faultCode: {http://xml.apache.org/axis/}Server.NoService
    faultSubcode:
    faultString: The AXIS engine could not find a target service to invoke! targetService is calculator
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}hostname:GBT

    The AXIS engine could not find a target service to invoke! targetService is calculator
    at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
    at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
    at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.works.test.CalculatorSoapBindingStub.add(CalculatorSoapBindingStub.java:131)
    at com.works.test.service.client.TestClientAction.main(TestClientAction.java:17)


    Thanks,
    Vijay.

    ReplyDelete
  55. Hi kamal,
    Thanks for the tutorial.

    Even if i started tomacat i am getting the exception
    Processing file org\sat\wssample\ws\generated\deploy.wsdd
    Exception: AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.net.ConnectException: Connection refused: connect
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Conne
    ction refused: connect

    could u please help as early as possible

    ReplyDelete
  56. //Connection refused: connect

    What is the port that you are running tomcat?

    ReplyDelete
  57. This is excellent place to start learning web services. I do a question regarding the WS-Sample and WS-Sample-client directories you created. Should they be part of the Axis directory that we copied under \tomcat\webapps\axis or these directories are seperate projects that run in tomcat\webapps?

    ReplyDelete
  58. Hi Kamal,

    Thank you for the tutorial, It is very easy to understand.

    I am getting the following error when I try to register ws with axis. I read all comments and tried to enter this url on browser http://localhost:8080/axis/services/AdminService

    I receive the text on the browser as following:

    Hi there, this is an AXIS service!

    Perhaps there will be a form for invoking the service here...

    Look like the AXIS serivce is running, but I am not able to register it. Please give me advice.


    C:\Users\Huynh Le\workspace\WS-Sample\src>java org.apache.axis.client.AdminClient org\hle\wssample\ws\genera
    ted\deploy.wsdd
    Processing file org\hle\wssample\ws\generated\deploy.wsdd
    Exception: AxisFault
    faultCode: {http://xml.apache.org/axis/}HTTP
    faultSubcode:
    faultString: (404)Not found
    faultActor:
    faultNode:
    faultDetail:
    {}:return code: 404
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <HTML><HEAD>
    <TITLE>404 Not found</TITLE>
    </HEAD><BODY><H1>Not found</H1>
    The requested URL /axis/services/AdminService was not found on this server</B
    ODY></HTML>

    {http://xml.apache.org/axis/}HttpErrorCode:404

    Thank you

    ReplyDelete
  59. Perfect, the only simple and strait forward Web Services tutorial on the web :))

    ReplyDelete
  60. Configuring Axis1.4, tomact5.5 with jdk1.4 after configuring all are working fine. But while deployment I am not able to deploy wsdd file .In normal case tomcat 5.5 doesn’t support jdk 1.4,but after putting some jar inside tomcat 5.5 it’s working fine.I have added some jar (jmx.jar, xercesImpl.jar, xml-apis.jar) to make it tomcat5 compatible with jdk 1.4.
    I Configured like that:
    tomact 5.5
    Axis 1.4
    jdk 1.4

    ReplyDelete
  61. Hi Kamal,

    Great job and Great mind!!

    A quick question that I have is, Axis 1.4 does not have bin directory, then how do I start the Axis server if I need.But Axis2 has bin folder.

    Thanks, Eas

    ReplyDelete
  62. Hi Kamal,

    Even after verfying that the Tomcat is up and running, xerces.jar is in place and also updated in classpath (as below). I am getting the error that I have given below the classpath.

    **************************
    classpath:
    .;%JAVA_HOME%\lib;%ANT_HOME%\lib;C:\axis-1_4\lib\log4j.properties;C:\Program Files\QuickTime\QTSystem\QTJava.zip;C:\axis-1_4\lib\axis.jar;C:\axis-1_4\lib\commons-discovery-0.2.jar;C:\axis-1_4\lib\commons-logging-1.0.4.jar;C:\axis-1_4\lib\jaxrpc.jar;C:\axis-1_4\lib\log4j-1.2.8.jar;C:\axis-1_4\lib\saaj.jar;C:\axis-1_4\lib\wsdl4j-1.5.1.jar;C:\axis-1_4\lib\mail-1.4.jar;C:\axis-1_4\lib\activation-1.1.jar;C:\axis-1_4\lib\Xerces.jar;C:\axis-1_4\WS-Sample-Client\lib;C:\axis-1_4\WS-Sample-Client\lib\calculatorClientSide.jar;C:\axis-1_4\WS-Sample-Client\lib\xerces.jar;C:\axis-1_4\lib\xercesImpl.jar;C:\axis-1_4\lib\xercesSamples.jar;C:\axis-1_4\WS-Sample-Client\lib\xercesImpl.jar;C:\axis-1_4\WS-Sample-Client\lib\xercesSamples.jar;

    ***********************************
    Exception in thread "main" AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.net.ConnectException: Connection refused: connect
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Conne
    ction refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:520)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
    ketFactory.java:153)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
    ketFactory.java:120)
    at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:1
    91)
    at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.ja
    va:404)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)

    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
    y.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at org.kalee.wssample.ws.generated.CalculatorSoapBindingStub.add(Calcula
    torSoapBindingStub.java:118)
    at org.kalee.wsclient.CalcClient.main(CalcClient.java:9)

    {http://xml.apache.org/axis/}hostname:48804B1

    java.net.ConnectException: Connection refused: connect
    at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)

    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
    y.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at org.kalee.wssample.ws.generated.CalculatorSoapBindingStub.add(Calcula
    torSoapBindingStub.java:118)
    at org.kalee.wsclient.CalcClient.main(CalcClient.java:9)
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:520)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
    ketFactory.java:153)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
    ketFactory.java:120)
    at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:1
    91)
    at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.ja
    va:404)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)

    ... 11 more
    *********************************************************

    ReplyDelete
  63. Dear Kamal,
    In continuation of my earlier comment, I rechecked once again carefully the classpath details and found that I had not linked the wsdl4j.jar. After correcting this and running step 3 for creating the wsdl file I get a message as under:
    WS-Sample\classes> java org.apache.axis.wsdl.Java2WSDL
    -o ..\calculator.wsdl
    -n urn:org.kamal.calculator
    -l http://localhost:8080/axis/services/calculator
    org.kamal.wssample.ws.Calculator

    log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectResourceBundle)
    log4j:WARN Please initialize the log4j system properly
    java.lang.ClassNotFoundException: org.kamal.wssample.ws.Calculator

    could you please guide to proceed further?

    kbs.

    ReplyDelete
  64. Hi kbs,

    Can you check whether this Calculator.class file is available inside classes/org/kamal/wssample/ws/ folder. This error means that the program can not find the specified .class file.

    Hope this helps.

    ReplyDelete
  65. Hi Kamal,
    Thanks for your guidance. The class file was present but apparently it was due to my mistake of deleting the jre link in the classpath. Once this was rectified the wsdl creation went through. It did however give the following message.

    log4j: WARN no appenders could be found for logger (org.apache.axis.i18n.ProjectResourceBundle)
    log 4j: WARN please initialize the log4j system properly

    After running through all the steps, the final result however was interesting! (I am not sure if I would deserve a mathematics Nobel Prize for this!!)

    There was the same warning and the final output was
    15 + 6 = -3
    15 - 6 = -3
    The command line details are:
    C:\WS-Sample-Client\classes> java
    -cp %CLASSPATH%;.;..\lib\calcuatorClientSide.jar
    org.kamal.wsclient.CalcClient
    log4j: WARN no appenders could be found for logger org.apache.axis.i18n.ProjectResourceBundle
    log 4j: WARN please initialize the log4j system properly
    15 + 6 = -3
    15 - 6 = -3
    C:\WS-Sample-Client\classes>

    I am looking forward to your guidance.

    Thanks,
    kbs

    ReplyDelete
  66. log4j warings: you can ignore them for the time being.

    But I can hardly guess how your results are always coming as -3. Have you checked your add() and subtract() methods?

    ReplyDelete
  67. Hi Kamal,
    I did little more probing. The problem seems to stem from the wrong creation of CalculatorSoapBindingImpl.java. The coding is below. I wonder as to from it is picking up -3 and puts it as return value which is apparently leading to incorrect result. I have also appended the calculator.wsdl
    I have checked and rechecked both SimpleCalculator.java a well as Calculator.java to ensure that they are ok.
    Any clue?

    Thanks,
    kbs

    /**
    * CalculatorSoapBindingImpl.java
    *
    * This file was auto-generated from WSDL
    * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
    */
    /*
    package org.kamal.wssample.ws.generated;

    public class CalculatorSoapBindingImpl implements org.kamal.wssample.ws.generated.Calculator{
    public int add(int in0, int in1) throws java.rmi.RemoteException {
    return -3;
    }

    public int subtract(int in0, int in1) throws java.rmi.RemoteException {
    return -3;
    }

    }
    **********************
    (?xml version="1.0" encoding="UTF-8"?)
    (wsdl:definitions targetNamespace="urn:org.kamal.calculator" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="urn:org.kamal.calculator" xmlns:intf="urn:org.kamal.calculator" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema")
    (!--WSDL created by Apache Axis version: 1.4
    Built on Apr 22, 2006 (06:55:48 PDT)--)

    (wsdl:message name="addResponse")

    (wsdl:part name="addReturn" type="xsd:int"/)

    (/wsdl:message)

    (wsdl:message name="subtractRequest")

    (wsdl:part name="in0" type="xsd:int"/)

    (wsdl:part name="in1" type="xsd:int"/)

    (/wsdl:message)

    (wsdl:message name="subtractResponse")

    (wsdl:part name="subtractReturn" type="xsd:int"/)

    (/wsdl:message)

    (wsdl:message name="addRequest")

    (wsdl:part name="in0" type="xsd:int"/)

    (wsdl:part name="in1" type="xsd:int"/)

    (/wsdl:message)

    (wsdl:portType name="Calculator")

    (wsdl:operation name="add" parameterOrder="in0 in1")

    (wsdl:input message="impl:addRequest" name="addRequest"/)

    (wsdl:output message="impl:addResponse" name="addResponse"/)

    (/wsdl:operation)

    (wsdl:operation name="subtract" parameterOrder="in0 in1")

    (wsdl:input message="impl:subtractRequest" name="subtractRequest"/)

    (wsdl:output message="impl:subtractResponse" name="subtractResponse"/)

    (/wsdl:operation)

    (/wsdl:portType)

    (wsdl:binding name="calculatorSoapBinding" type="impl:Calculator")

    (wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/)

    (wsdl:operation name="add")

    (wsdlsoap:operation soapAction=""/)

    (wsdl:input name="addRequest")

    (wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:org.kamal.calculator" use="encoded"/)

    (/wsdl:input)

    (wsdl:output name="addResponse")

    (wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:org.kamal.calculator" use="encoded"/)

    (/wsdl:output)

    (/wsdl:operation)

    (wsdl:operation name="subtract")

    (wsdlsoap:operation soapAction=""/)

    (wsdl:input name="subtractRequest")

    (wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:org.kamal.calculator" use="encoded"/)

    (/wsdl:input)

    (wsdl:output name="subtractResponse")

    (wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:org.kamal.calculator" use="encoded"/)

    (/wsdl:output)

    (/wsdl:operation)

    (/wsdl:binding)

    (wsdl:service name="CalculatorService")

    (wsdl:port binding="impl:calculatorSoapBinding" name="calculator")

    (wsdlsoap:address location="http://localhost:8080/axis/services/calculator"/)

    (/wsdl:port)

    (/wsdl:service)

    (/wsdl:definitions)

    ***************

    ReplyDelete
  68. Hi kbs,

    You haven't been following the steps, right? Have a look at step 5 named "Bind Web service with Functionality provider".

    ReplyDelete
  69. Kamal,
    It would be nice if you can rewrite your tutorial with annotations. I thought by using annotations you don't need to do anything other than to write the class

    ReplyDelete
  70. Hi Kamal,
    Thanks a lot for your guidance. I had indeed missed the crucial step 5. Once this was done it went through like a cake and I was delighted. Let me also join others in complimenting you for an excellent tutorial. While other tutorials give broad guidelines, yours was significantly different with minute details and step by step guidance. This brought home the concepts clearly.
    Now having had some idea of the whole process, I have a suggestion to make, for your consideration. We are compiling the generated classes in step 4 itself before tweaking/editing the CalculatorSoapBindingImpl class in step 5 to bind the Web service with Functionality provider. I therefore feel that compiling the generated classes should be done after step 5 and not before. This could possibly help the uninitiated like me who follow the tutorial.
    Thanks once again and looking forward to more such exhaustive tutorials in the days ahead.
    With regards,
    kbs.

    ReplyDelete
  71. Hello Kamal,
    Is there a way to debug the webservices code particularly the server side API.

    ReplyDelete
  72. Great tutorial!!! Very nice and very well explained...

    Cheers!!!
    jAY

    ReplyDelete
  73. Just Excellent. Thanks a lot!!

    ReplyDelete
  74. hi
    i want to create web service client using jsp..
    The web service is hosted on https://webservices.netsuite.com/wsdl/v2008_1_0/netsuite.wsdl
    how to invoke it in jsp....
    provie sample code if possble
    or some links
    please do help

    ReplyDelete
  75. Ravi: create web service client using jsp..
    It seems you are not asking the correct question. JSP is not a place to call a web service, you better write a java client using the WSDL file.

    ReplyDelete
  76. really nice work. it made my life simpler. thanks a lot -mathew

    ReplyDelete
  77. Hi
    I am trying to create and deploy the sample application as it has been stated.But I get an error in the third step.I am not able to convert Java to WSDL.The trace is:


    C:\WS-Sample\classes>java org.apache.axis.wsdl.Java2WSDL
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl/
    Java2WSDL
    Caused by: java.lang.ClassNotFoundException: org.apache.axis.wsdl.Java2WSDL
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    C:\WS-Sample\classes> -o ..\calculator.wsdl
    '-o' is not recognized as an internal or external command,
    operable program or batch file.

    C:\WS-Sample\classes> -n urn:org.kamal.calculator
    '-n' is not recognized as an internal or external command,
    operable program or batch file.

    C:\WS-Sample\classes> -l http://localhost:8080/axis/services/calculator
    '-l' is not recognized as an internal or external command,
    operable program or batch file.

    C:\WS-Sample\classes> org.kamal.wssample.ws.Calculator

    ReplyDelete
  78. Excellent article!
    Just a note to people who run into the null being retured to the client: everytime you do step 4 (generate server-side classes), you have to re-do step 5 (call implementation method from web service impl).

    ReplyDelete
  79. Thank U very much for the wonderful article which made my job easier.

    ReplyDelete
  80. hi my question was to consume web services using jsp page..
    i am generated client proxy and packed the class files into jar files and using the jar files in my jsp...
    Is that the correct way to do???
    please give some inputs...
    thanks and regrds
    Ravi

    ReplyDelete
  81. Hi,
    I tried doing the above steps by replacing the return type with my custom java class. That gives an "java.lang.reflect.InvocationTargetException" exception.
    What changes (if any) do I need to make to replace the integer return type with user-defined java class?
    Thanks

    ReplyDelete
  82. Hi Kamal
    Thanks for wonderful tutorial..
    It has actully given us a new direction..
    I've followed all this steps and all files are generated but while running client side java file an error is occurring..
    Command Line details are:-
    ----------------------------------------------------
    - Unable to find required classes (javax.activation.DataHandler and javax.mail.i
    nternet.MimeMultipart). Attachment support is disabled.
    15 + 6 = -3
    15 - 6 = -3
    -------------------------------------------------------
    Please tell me the solution..

    ReplyDelete
  83. Really great tutorial man. U r doing a great service. This tutorial helped me a lot with ma work. Thanks

    ReplyDelete
  84. Hi

    We recently had to implement standard J2EE web services to SAP NW Application Server (WAS), running on JDK1.4.1_09

    The approach was to use the bottom-up WS creation wizard in Eclipse 3.4.2 to convert a class to a service, using a dynamic web project in Eclipse, configured to run on Tomcat4.1 and JDK1.4.1_09 at servlet specification 2.3 (to comply with the 1.4.1_09 of the SAP NW AS).

    The WS wizard copied all the required Axis1 jars and web.xml entries into out dynamic web project...

    We were running into a strange exception – both locally on Tomcat and also on SAP NW:

    Invalid WSDD element 'transport' (wanted 'transport'), which was thrown from: org.apache.axis.deployment.wsdd.WSDDElement

    After a long struggle, we read in http://ws.apache.org/axis/java/install.html that Xerces is the preferred XML parser...

    After adding the latest (2.9.1) Xerces-J jars to our project, the issue was resolved for both Tomcat and SAP NW!

    I hope this solution can help someone else too.

    I'm guessing most of the odd "Invalid WSDD element" exceptions might be resolved with the Xerces jars...

    ReplyDelete
  85. Everything is perfectly explained here. I saw few people having issue with version and few getting wrong results.

    I think folowing should come at the end of step 5 not end of step 4.

    Now we should compile those generated classes using the following command.

    WS-Sample\src> javac –d ..\classes org\kamal\wssample\ws\generated\*.java

    ReplyDelete
  86. Thank you for the nice example. Would appreciate any advice on how to proceed with adding security? For example, requiring certificate on the client side, using HTTPS/SSL, encrypting contents?

    ReplyDelete
  87. Thank you for the tutorial. Any advice on how to proceed with securing the web service, for example with HTTPS/SSL and requiring a client certificate?

    ReplyDelete
  88. i'm not very good in java. when i try to do the compilation of the 5generated java files it generate an error saying

    javac: invalid flag: ud
    Usage: javac &lt option &gt &lt source files &gt

    can u please help me to solve this. regards.

    ps: nice tutorial. quite easy to understand

    ReplyDelete
  89. Hi Kamal thank you very much for Providing a good sample.
    really it helped me a lot. i am new bie to Apache Axis.

    ReplyDelete
  90. dear kamal aiya,

    i hav a little bit advanced excercise. can i hav an opinion on it or good if you can start and give a complete guide to it. i have tried so many web articles but no good answer found yet. the exercise is as follows....

    Exercises :

    1) Develop customer profile web service as below: which having two methods saveCustomer and retrieveCustomer

    Customer infomation data structure as follows

    CustomerID :string
    Name :string
    phoneNumber : int
    Address : Object which contain(home number(int), street(string), town(string))- Complex type object
    Age: int
    LastBalance: double

    Ex1:
    you send the SOAP request (in your web service call) with customer id or phone number the web service should return customer information and display as system out.

    Note Just hard code customer dummy data inside web service method call getCustomerData which return the customer object.

    Ex2

    Compose customer object (java object) in client side and send via web service using web service save method to write to a data to text file in server side (in your case same machine , but it create by customer profile web service not the web service client)

    ReplyDelete
  91. Hi Kamal,

    Thanks a lot for sharing this material and it is very useful for me in learning webservices-Apache Axis (1.4). Please share us any information if you prepared on Axis 2.0

    Regards,
    Sarayu

    ReplyDelete
  92. Hi kamal,

    I am still having a little problem. I managed to follow every step of the tutorial, except the last one, the actual test.

    I allways get the stack wich you can find at the bottom.

    Can you help me? Thx in advance
    Tim

    My classpath is as follows, and the jars are there in that folder:
    C:\axis\axis.jar;C:\axis\commons-discovery-0.2.jar;C:\axis\commons-logging-1.0.4.jar;C:\axis\jaxrpc.jar;C:\axis\saaj.jar;C:\ax
    is\wsdl4j-1.5.1.jar;C:\axis\log4j-1.2.8.jar;

    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    org.apache cannot be resolved to a type
    org.apache cannot be resolved to a type
    javax.xml.rpc cannot be resolved to a type
    javax.xml.rpc cannot be resolved to a type
    javax.xml.rpc cannot be resolved to a type
    The method getcalculator(URL) from the type CalculatorServiceLocator refers to the missing type ServiceException
    javax.xml.rpc cannot be resolved to a type
    The constructor CalculatorSoapBindingStub() refers to the missing type AxisFault
    The method setPortName(String) is undefined for the type CalculatorSoapBindingStub
    org.apache cannot be resolved to a type
    javax.xml.rpc cannot be resolved to a type
    The constructor CalculatorSoapBindingStub() refers to the missing type AxisFault
    The method setPortName(String) is undefined for the type CalculatorSoapBindingStub
    javax.xml.rpc cannot be resolved to a type
    javax.xml.rpc cannot be resolved to a type
    javax.xml.rpc cannot be resolved to a type
    The method getPort(Class) from the type CalculatorServiceLocator refers to the missing type ServiceException
    The method getcalculator() from the type CalculatorServiceLocator refers to the missing type ServiceException
    The method getPort(Class) from the type CalculatorServiceLocator refers to the missing type ServiceException
    org.apache.axis.client.Stub cannot be resolved to a type
    javax.xml.rpc cannot be resolved to a type
    javax.xml.rpc cannot be resolved to a type
    javax.xml.rpc cannot be resolved to a type
    The method setEndpointAddress(String, String) from the type CalculatorServiceLocator refers to the missing type ServiceException

    at org.kamal.wssample.ws.generated.CalculatorServiceLocator.(CalculatorServiceLocator.java:10)
    at org.kamal.wsclient.CalcClient.main(CalcClient.java:14)

    ReplyDelete
  93. Hi Sarayu, I'll try to prepare another tutorial with Axis 2.0.

    ReplyDelete
  94. // Exception in thread "main" java.lang.Error: Unresolved compilation problems:

    Can you paste the command you are using to compile your classes?

    ReplyDelete
  95. Hey Kamal,

    I used exact the command mentioned in the tutorial
    I also tried it in Eclipse.

    I suppose my problem is in the client jar file. should there be a reference to the jaxrpc.jar somewhere?

    thx
    Tim

    ReplyDelete
  96. As I have mentioned in the start, I was using jdk1.6 which includes these classes. If you are not using that, please try adding jaxrpc.jar into the classpath.

    ReplyDelete
  97. Hi Kamal,
    this is very nice and excellent tutorial for webservices.you done good job for beginners.
    i have faced one problem during running the webservice client.
    plz look into this problem and solve me asap.
    1. my tomcat is running under 8090 port number.oracle is running 8080 port in my system.so i have changed like that.
    2. while i am trying to registering webservice with AXIS.
    i.e.,java org.apache.axis.client.AdminClient org\kamal\wssample\ws\generated\deploy.wsdd
    i have faced the problem like this.
    > java org.apache.axis.client.AdminClient org\
    kamal\wssample\ws\generated\deploy.wsdd
    Processing file org\kamal\wssample\ws\generated\deploy.wsdd
    Exception: AxisFault
    faultCode: {http://xml.apache.org/axis/}HTTP
    faultSubcode:
    faultString: (404)Not found
    faultActor:
    faultNode:
    faultDetail:
    {}:return code: 404
    so i have changed registering like this.
    java org.apache.axis.client.AdminClient org\kamal\wssample\ws\generated\deploy.wsdd -p 8090
    so it is working fine and i have restarted the server and i saw calculator service in console.
    3. my actual problem is calling the webservice like
    java -cp %CLASSPATH%;.;..\lib\calculatorClientSide.jar org.kamal.wsclient.CalcClient
    i got this error
    Exception: AxisFault
    faultCode: {http://xml.apache.org/axis/}HTTP
    faultSubcode:
    faultString: (404)Not found
    faultActor:
    faultNode:
    faultDetail:
    {}:return code: 404

    Request you to look into my problem.is any wrong with port number.i am unable to change my oracle port no form 8080.
    waiting for your reply.

    ReplyDelete
  98. Hi Kamal,
    this is very nice and excellent tutorial for webservices.you done good job for beginners.
    i have faced one problem during running the webservice client.
    plz look into this problem and solve me asap.
    1. my tomcat is running under 8090 port number.oracle is running 8080 port in my system.so i have changed like that.
    2. while i am trying to registering webservice with AXIS.
    i.e.,java org.apache.axis.client.AdminClient org\kamal\wssample\ws\generated\deploy.wsdd
    i have faced the problem like this.
    > java org.apache.axis.client.AdminClient org\
    kamal\wssample\ws\generated\deploy.wsdd
    Processing file org\kamal\wssample\ws\generated\deploy.wsdd
    Exception: AxisFault
    faultCode: {http://xml.apache.org/axis/}HTTP
    faultSubcode:
    faultString: (404)Not found
    faultActor:
    faultNode:
    faultDetail:
    {}:return code: 404
    so i have changed registering like this.
    java org.apache.axis.client.AdminClient org\kamal\wssample\ws\generated\deploy.wsdd -p 8090
    so it is working fine and i have restarted the server and i saw calculator service in console.
    3. my actual problem is calling the webservice like
    java -cp %CLASSPATH%;.;..\lib\calculatorClientSide.jar org.kamal.wsclient.CalcClient
    i got this error

    ReplyDelete
  99. Hi Narayana,

    Can you try changing the 3rd step as follows?

    WS-Sample\classes> java org.apache.axis.wsdl.Java2WSDL
    -o ..\calculator.wsdl
    -n urn:org.kamal.calculator
    -l http://localhost:8090/axis/services/calculator
    org.kamal.wssample.ws.Calculator

    ReplyDelete
  100. Hi kamal,
    i have generated WSDL files using the port no 8090 like your suggestion only...
    I am looking forward to your guidance.

    ReplyDelete
  101. dear kamal, i get an error in the 4th step when i try to run
    WS-Sample\src> javac –d ..\classes
    org\kamal\wssample\ws\generated\*.java

    the error is

    javac: invalid flag: ud
    Usage: javac &lt option &gt &lt source files &gt

    how to overcome this? waiting for your reply.

    ReplyDelete
  102. hi kamal,

    this is regarding the previous post. this is the error.

    D:\Web Service Files\WS-Sample\src&gtjavac -d ..\classes org\ushan\wssample\ws\generated\Calculator.java
    javac: invalid flag: ûd
    Usage: javac &ltoptions&gt &ltsource files&gt
    where possible options include:
    -g Generate all debugging info
    -g:none Generate no debugging info
    -g:{lines,vars,source} Generate only some debugging info
    -nowarn Generate no warnings
    -verbose Output messages about what the compiler is doing
    -deprecation Output source locations where deprecated APIs are u
    sed
    -classpath &ltpath&gt Specify where to find user class files
    -cp &ltpath&gt Specify where to find user class files
    -sourcepath &ltpath&gt Specify where to find input source files
    -bootclasspath &ltpath&gt Override location of bootstrap class files
    -extdirs &ltdirs&gt Override location of installed extensions
    -endorseddirs &ltdirs&gt Override location of endorsed standards path
    -d &ltdirectory&gt Specify where to place generated class files
    -encoding &ltencoding&gt Specify character encoding used by source files
    -source &ltrelease&gt Provide source compatibility with specified release

    -target &ltrelease&gt Generate class files for specific VM version
    -version Version information
    -help Print a synopsis of standard options
    -X Print a synopsis of nonstandard options
    -J&ltflag&gt Pass &ltflag&gt directly to the runtime system

    ReplyDelete
  103. Hi mIsTiK cHaZeR,

    Try replacing the "*.java" part with the correct named of the files.

    ReplyDelete
  104. same error comes when i compile the files separately. is this error connected to the classpath?

    ReplyDelete
  105. Yes it is related to the classpath. Can you verify that your classpath is correct?

    ReplyDelete
  106. SET CLASSPATH=C:\axis-1_2_1\lib\activation.jar;.;C:\axis-1_2_1\lib\axis.jar;C:\axis-1_2_1\lib\axis-ant.jar;C:\axis-1_2_1\lib\jaxrpc.jar;C:\axis-1_2_1\lib\commons-discovery-0.2.jar;C:\axis-1_2_1\lib\commons-logging-1.0.4.jar;C:\axis-1_2_1\lib\wsdl4j-1.5.1.jar;C:\axis-1_2_1\lib\xalan-2.7.1.jar;C:\axis-1_2_1\lib\xercesImpl-2.9.1.jar;C:\axis-1_2_1\lib\xml-apis-1.3.04.jar;C:\axis-1_2_1\lib\mail.jar;C:\axis-1_2_1\lib\opensaml-1.1.jar;C:\axis-1_2_1\lib\wss4j.jar;C:\axis-1_2_1\lib\bcprov-ext-jdk15-140.jar;C:\axis-1_2_1\lib\bcprov-jdk15-140.jar;C:\axis-1_2_1\lib\xmlsec-1.4.0.jar;C:\axis-1_2_1\lib\log4j-1.2.8.jar;C:\axis-1_2_1\lib\saaj.jar;C:\axis-1_2_1\lib\xml-serializer-2.7.1


    this is my classpath.

    ReplyDelete
  107. Are you facing this issue only when using the "javac" command for these classes? Can you create a sample java class in a package on your machine (not inside this project) and try to compile it?

    ReplyDelete
  108. I just noticed something in your classpath.

    It ends as;

    ....;C:\axis-1_2_1\lib\saaj.jar;C:\axis-1_2_1\lib\xml-serializer-2.7.1

    The final jar file is not having the extension (xml-serializer-2.7.1.jar). Please correct that and try again.

    ReplyDelete
  109. yes i can compile java files in other packages. i corrected that error but no use. so i changed the directory and went inside D:\Web Service Files\WS-Sample\src\org\ushan\wssample\ws\generated and compiled the files and generated the .class files in the same directory and then copied them in to D:\Web Service Files\WS-Sample\classes\org\ushan\wssample\ws\generated. is that ok. when i was doing so i got this >>>


    D:\Web Service Files\WS-Sample\src>cd org\ushan\wssample\ws\generated

    D:\Web Service Files\WS-Sample\src\org\ushan\wssample\ws\generated>javac *.java
    Note: CalculatorServiceLocator.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.

    D:\Web Service Files\WS-Sample\src\org\ushan\wssample\ws\generated>

    ReplyDelete
  110. You can ignore those warning messages, however that is not the way to compile classes inside packages.

    I would suggest you to set the classpath explicitly inside command prompt with the required jar files and compile these classes from the src directory.

    ReplyDelete
  111. i retried the process. i guess now it's working. i got this same message same as above. this is ok rite??

    D:\Web Service Files\WS-Sample\src>javac -d ..\classes org\ushan\wssample\ws\gen
    erated\*.java
    Note: org\ushan\wssample\ws\generated\CalculatorServiceLocator.java uses uncheck
    ed or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.

    D:\Web Service Files\WS-Sample\src>

    ReplyDelete
  112. Ok, so your issue was in the classpath variable (missing .jar).

    You can ignore those warning messages for now.

    ReplyDelete
  113. thanks kamal. this helped me a lot. i'll buzz u if there are any other issues that matters me. thanx again for the great help.

    ReplyDelete
  114. dear kamal,

    i get the final out put of your tutorial successfully. it's really good and got a really nice understanding on web services. as i'm new to this topic i have more questions. is there a possible way to run this web service on a web browser and how to do that? and if i need to add two numbers which i like at the run time which files should i modify?

    ReplyDelete
  115. i hav to say more that i hav followed your tutorial using axis 1.2.1 tomcat 5.5 and jdk 1.5. it seems this guide works fine with these configurations too.

    ReplyDelete
  116. Hi mIsTiK cHaZeR,
    // if i need to add two numbers which i like at the run time

    You can use any number at the client side. As you can see from the CalcClient class, we pass the parameters to the web service in this class. So you only have to change the client class to pass runtime values.

    ReplyDelete
  117. Hi Kamal,

    Getting an error at step 4: WSDL2Java - Generate server side and client side classes for web service

    java -classpath "D:/lib/axis.jar;D:/lib/commons-discovery-0.2.jar;D:/lib/commons-logging-1.0.4.jar;D:/lib/jaxrpc.j
    ar;D:/lib/log4j-1.2.8.jar;D:/lib/saaj.jar;D:/lib/wsdl4j-1.5.1.jar;D:/lib/axis-ant.jar;D:/lib/activation.jar;D:/lib/mail.jar;."
    org.apache.axis.wsdl.Java2WSDL
    -o src
    -p sample.ws.generated
    -s
    calculator.wsdl

    Error: Unable to parse first argument for option -p
    Java2WSDL emitter
    Usage: java org.apache.axis.wsdl.Java2WSDL [options] class-of-portType

    What I am missing here?

    Thank you

    ReplyDelete
  118. Figured it out: wrong tool
    instead of Java2WSD should be WSDL2Java

    ReplyDelete
  119. hi Kamal,
    i got an error when i try to run a different web service deployed according to this tutorial. it says

    D:\My TSD\Web Service Files\Customer Web Service\CustomerClient\classes>java -cp
    %CLASSPATH%;.;..\lib\customerClientSide.jar ushan.CustomerServiceClient
    AxisFault
    faultCode: {http://xml.apache.org/axis/}Server.NoService


    faultSubcode:
    faultString: The AXIS engine could not find a target service to invoke! target
    Service is CustomerService
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}hostname:tsd-e6336916066



    The AXIS engine could not find a target service to invoke! targetService is Cus
    tomerService
    at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder
    .java:221)
    at org.apache.axi.............................................................................................................................................

    ReplyDelete
  120. Hi,

    I get the following error:

    java.lang.ClassNotFoundException: org.kamal.wssample.ws.Calculator
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
    at org.apache.axis.utils.ClassUtils$2.run(ClassUtils.java:187)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.axis.utils.ClassUtils.loadClass(ClassUtils.java:161)
    at org.apache.axis.utils.ClassUtils.forName(ClassUtils.java:100)
    at org.apache.axis.wsdl.fromJava.Emitter.setCls(Emitter.java:2079)
    at org.apache.axis.wsdl.Java2WSDL.run(Java2WSDL.java:584)
    at org.apache.axis.wsdl.Java2WSDL.main(Java2WSDL.java:682)

    My CLASSPATH includes all required libraries:

    /usr/share/java/axis/axis.jar:/usr/share/java/commons-discovery.jar:/usr/share/java/commons-logging.jar:/usr/share/java/axis/jaxrpc.jar:/usr/share/java/log4j.jar:/usr/share/java/axis/saaj.jar:/usr/share/java/wsdl4j.jar

    and I have replicated the directory strucutre exaclty as described in the article. Ijust do not know, how to get over this problem.

    I also tried to strace and ltrace the compilation. strace gives very little information. I do not see any attempt to touch the file whatsoever. ltrace end with "+++ killed by SIGTRAP +++". Total confusion on my side.

    ReplyDelete
  121. It turned out theat I did not have my current directory "." in my CLASSPATH, therefore the java2wsdl tool was not able to load the Calculator class.

    I ran into another problem - I could not deploy the service, because AdminService was not found. The reason was I installed Axis version 1.4.1 instead of Axis version 1.4, which is ni fact version 2.0. Very confusing. I spent several hours figuring out what went wrong. I could not understand the the AdminService just was not there.

    After this the example worked without any problem. An excelent tutorial. I am a complete newbie to web services.

    Just one remark - CalculatorSoapBindingImpl (step 5) has to be edited before compilation in step 4 takes place. Steps 4 and 5 have to be rearranged in the following way:

    A. generate server side and client side classes for web service
    B. bind Web service with Functionality provider
    C. compile

    I have nothing else to add. Great work. Thank you very much.

    ReplyDelete
  122. This is really Ultimate tutorial for the beginner.Thanks a lot for providing such good tutorial
    Kumar Saurabh

    ReplyDelete
  123. Great article, Kamal.

    Following your instructions, I got the expected results. But there's one thing unclear to me.

    After making changes to CalculatorSoapBindingImpl.java to bind SimpleCalculator to the web service, you did not compile the changed file. And yet. somehow, the web service worked. I redid the entire procedure a couple of times, and it worked every time.

    So, how does it work exactly that you don't have to compile CalculatorSoapBindingImpl.java and the web service can find the binding to SimpleCalculator class?

    ReplyDelete
  124. Hey Kamal

    Thanks for your posting.It is awsome.I am a new bee to webservices but working on live project.I am using axis 1.4 and soap 1.0.I wrote a client which calls a service using ssl over https.I wrote a callback handler to insert the security header tokens for authentication .i.e sending username,password,nonce and creation time.Now when i recieve the response i do get back security header along with envelope.Now i don't know what to do as i am getting following error.


    org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
    at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)

    ReplyDelete
  125. Hi Kamal,

    This is a very useful tutorial for the beginners.

    I am developing a client to a certain webservice. I have the wsdl with me. I generated the java classes using wsdl2java. Using the methods of service object, I am able to communicate with the webservice and I am getting the response objects. Everything is fine but for logging purpose, I want the soap request and response xml messages.

    I am new to axis and unable to find a way to get those xmls. Some suggested to use TCPMON but I want something which can work within my coding and I can save the request and response xmls.

    Can you please state one example on how to achieve it?

    Thanks in advance.

    ____
    Raju

    ReplyDelete
  126. Hi Kamal

    Nice article. I successfully completed it, now I wish to create on more function in the calculator class which accepts an Equation object (POJO) like following:
    ---------------------------
    public interface Calculator {
    int calculate(Equation equation);

    int add (int x, int y);
    int subtract(int x, int y);

    }

    --------------------------------
    Following is Equation's code:

    public class Equation {

    private int leftOpr;
    private int rightOpr;
    private String operator;
    public int getLeftOpr() {
    return leftOpr;
    }
    public void setLeftOpr(int leftOpr) {
    this.leftOpr = leftOpr;
    }
    public int getRightOpr() {
    return rightOpr;
    }
    public void setRightOpr(int rightOpr) {
    this.rightOpr = rightOpr;
    }
    public String getOperator() {
    return operator;
    }
    public void setOperator(String operator) {
    this.operator = operator;
    }
    -----------------------------------

    I placed equation in package org.kamal.wssample. But when I tried to bind the method in the binder class like this:

    public int calculate(org.kamal.wssample.ws.generated.Equation in0) throws java.rmi.RemoteException {
    return calc.calculate(in0);
    }

    it's showing error in return line : The method calculate(Equation) in the type SimpleCalculator is not applicable for the arguments (Equation)

    I observed that this is because the calculate function in the bindingImpl class is declared with argument type : org.kamal.wssample.ws.generated.Equation while the SimpleCalculator's calculate function accepts:org.kamal.wssample.Equation.

    I tried creating an interface for Equation class and using it to implement a baseEquation but still it's not working.

    So basically my question is: How to pass complex objects as arguments to a web service method. Can you please help? or give reference to some doc/book?

    Thanks & Regards
    Arun Raj

    ReplyDelete
  127. Hey, Kamal, its realy kamaaal.
    this post is realy hlpful for the people like me, the beginners.
    kp doing the gud job.

    thnx for the article

    ReplyDelete
  128. Hi Kamal, thank you very much for the article
    I am new to this and want some help.
    I want to get the soap request and response xmls which are sent and received by my axis client. I want these xmls for the logging purpose. Can you please suggest me how to get them?

    It will be of much help.

    Thanking you
    Raju

    ReplyDelete
  129. Great job man, keep it up.

    ReplyDelete
  130. I guess you are not able to solve my requested problem. No problem.

    Thanks and Regards,
    Raju

    ReplyDelete
  131. This is really very good tutorial. I've seen many tutorials but no one mention clearly.

    ReplyDelete
  132. HI KAMAL

    THANKS FOR THIS TUTORIAL. IT HELPED US A LOT IN COMPLETING OUR MAJOR PROJECT WEBSERVICES.THE ONLY PROBLEM WE GOT IS WITH DATABASE CONNECTIVITY BUT LATER ON WE SOLVED IT WITH ORACLE DRIVER.

    ReplyDelete
  133. Hi Kamal,

    First of all many thanks for writing such an easy to understand article. I have two questions related to my project work.

    1) Although a bad design, the project I work on does not seem to be having any interface (like Calculator.java created in step 2) to the service class implementation. Is it possible to continue with step 3 and further without doing step 2. Seems possible to me, although not a good design. Just wanted to clarify with you.

    2) This one is more baffling to me and I seriously need your help. I don't find any kind SoapBindingImpl. java class being used. Is it possible for a client to access the service directly (client is in .net, not in java) without the use of binding class. I don't even see the stub being used either. I mean I don't find it in the project. I only see deploy.wsdd and undeploy.wsdd.

    It is confusing, but are there any steps that are not mandatory in the article. Even though skipping some of these steps would promote bad design, I just wanted to know how the project might be working. Please let me know which steps are absolutely mandatory so that I try to relate those with my project work. Thanks a lot in advance. Your help is greatly appreciated.

    ReplyDelete
  134. PLS REPLY AS SOON AS POSSIBLE !!!

    Hi Kamal,

    Thanks for your tutorial. It is helping me ...

    On this step I am getting the exception on the browser

    AXIS error
    Sorry, something seems to have gone wrong... here are the details:

    Fault - ; nested exception is:
    org.apache.axis.ConfigurationException: Could not find class for the service named: org.sample.wssample.ws.generated.CalculatorSoapBindingImpl
    Hint: you may need to copy your class files/tree into the right location (which depends on the servlet system you are using).; nested exception is:
    java.lang.ClassNotFoundException: org.sample.wssample.ws.generated.CalculatorSoapBindingImpl
    AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
    faultSubcode:
    faultString: Could not find class for the service named: org.sample.wssample.ws.generated.CalculatorSoapBindingImpl
    Hint: you may need to copy your class files/tree into the right location (which depends on the servlet system you are using).; nested exception is:
    java.lang.ClassNotFoundException: org.sample.wssample.ws.generated.CalculatorSoapBindingImpl
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}hostname:cpltn84qvsb

    Could not find class for the service named: org.sample.wssample.ws.generated.CalculatorSoapBindingImpl
    Hint: you may need to copy your class files/tree into the right location (which depends on the servlet system you are using).; nested exception is:
    java.lang.ClassNotFoundException: org.sample.wssample.ws.generated.CalculatorSoapBindingImpl
    at org.apache.axis.providers.java.JavaProvider.getServiceClass(JavaProvider.java:432)
    at org.apache.axis.providers.java.JavaProvider.initServiceDesc(JavaProvider.java:461)
    at org.apache.axis.handlers.soap.SOAPService.getInitializedServiceDesc(SOAPService.java:286)
    at org.apache.axis.deployment.wsdd.WSDDService.makeNewInstance(WSDDService.java:500)
    at org.apache.axis.deployment.wsdd.WSDDDeployableItem.getNewInstance(WSDDDeployableItem.java:274)
    at org.apache.axis.deployment.wsdd.WSDDDeployableItem.getInstance(WSDDDeployableItem.java:260)
    at org.apache.axis.deployment.wsdd.WSDDDeployment.getService(WSDDDeployment.java:427)
    at org.apache.axis.configuration.FileProvider.getService(FileProvider.java:231)


    Please help me. Also please let me know is it possible to include xsd validations in the wsdl ??? thanks in advance ... eagerly waiting for ur reply... Pls reply soon ...

    ReplyDelete
  135. For:
    org.apache.axis.ConfigurationException: Could not find class for the service named: org.sample.wssample.ws.generated.CalculatorSoapBindingImpl

    It seems either you have changed the package structure or using incorrect package named, according to the originally package names following should be the correct name.
    org.kamal.wssample.ws.generated.CalculatorSoapBindingImpl

    If you have changed it, please check other locations that you haven't changed.

    ReplyDelete
  136. Very Nice , Clear and Greate Work.Thank You - Rajesh Kumar Raj

    ReplyDelete
  137. Hi Kamal,

    I am new with implementing WebServices with Axis. On reading your article I have few questions which is pretty not clear for me, can you please help me out with the following questions?

    1) In the 3rd step, you have mentioned the interface class alone to create the wsdl file and nowhere you havent mentioned the actual class, i.e SimpleCalculator.java when creating the wsdl file

    2) Then in the 4th step you perform the wsdl2java, in that you mention the wsdl file alone to create client and server side code to deploy and invoke the webservice.

    3) After doing wsdl2java, you get five automatically generated java classes. Out of which, in CalculatorSoapBindingImpl.java class how do you get the following line included?

    private SimpleCalculator calc = new SimpleCalculator().....

    and hows this possible? Because you havent mentioned of SimpleCalculator.java anywhere when creating the wsdl file or wsdl2java operation.

    ReplyDelete
  138. Hi Kamal

    I am done every thing on Weblogic 8.1 but whenever i run client.I am getting following exception.Please help me.....

    C:\WS-Workspace\WS-Client\class>java -classpath %CLASSPATH%;..\lib\calculatorCli
    entSide.jar com.xav.wsclient.CalcClient
    Exception in thread "main" AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.lang.NullPointerException
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}hostname:xss-444

    java.lang.NullPointerException
    at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder
    .java:222)
    at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.
    java:129)
    at org.apache.axis.encoding.DeserializationContext.endElement(Deserializ
    ationContext.java:1087)
    at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
    at org.apache.crimson.parser.Parser2.content(Unknown Source)
    at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
    at org.apache.crimson.parser.Parser2.content(Unknown Source)
    at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
    at org.apache.crimson.parser.Parser2.parseInternal(Unknown Source)
    at org.apache.crimson.parser.Parser2.parse(Unknown Source)
    at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source)
    at javax.xml.parsers.SAXParser.parse(Unknown Source)
    at org.apache.axis.encoding.DeserializationContext.parse(Deserialization
    Context.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnders
    tandChecker.java:62)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.xav.wssample.ws.generated.CalculatorSoapBindingStub.add(Calculato
    rSoapBindingStub.java:118)
    at com.xav.wsclient.CalcClient.main(CalcClient.java:14)

    ReplyDelete
  139. Thanks for your swift reply.
    I am developing a small project which will help us to test the main application. To develop that I got a wsdl and xsd from them. I have installed all the below s/W,
    1. Jdk1.5
    2. Tomcat 6.0
    3. Apache Axis 1.4
    4. SOAP UI (instead of client)
    From given wsdl, I have generated server side classes (like stub, skeleton, other java classes and wsdd) by using wsdl2java tool. Then added all the compiled classes in the web-inf folder and deploy the service by using admin client tool.
    Now I am able to see the service in the axis service list page. From there I got a wsdl file and I am planning to use soapUI as client to test this project.Now if I use this wsdl (system generated) in soapUI client. It is throwing null pointer exception where as that wsdl (client provided) is not. I found the diff between the 2 version of wsdl.

    Continuing in the next comment.

    ReplyDelete
  140. Great tutorial bhai. This was very useful to revise my Axis knowledge in less then 10 minutes and prepare for interview. Reading documents takes way too much time and this is what I needed.
    -Madhu

    ReplyDelete
  141. Hi,
    while Generating WSDL file using java2wsdl this exception occur.i m using jboss-4.0.5.GA server and jdk1.6.0_11.
    java.lang.UnsupportedClassVersionError: org/kamal/wssample/ws/Calculator (Unsupp
    orted major.minor version 50.0)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.apache.axis.utils.ClassUtils$2.run(ClassUtils.java:177)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.axis.utils.ClassUtils.loadClass(ClassUtils.java:160)
    at org.apache.axis.utils.ClassUtils.forName(ClassUtils.java:100)
    at org.apache.axis.wsdl.fromJava.Emitter.setCls(Emitter.java:2079)
    at org.apache.axis.wsdl.Java2WSDL.run(Java2WSDL.java:584)
    at org.apache.axis.wsdl.Java2WSDL.main(Java2WSDL.java:682)

    Please help me.

    ReplyDelete
  142. Hi, Please let me know what the problem is, I am trying to deploy on local OAS.
    I deployed Axis as a war on OAS.

    C:\Testws\WS-Sample\src>java org.apache.axis.client.AdminClient org\kamal\wssamp
    le\ws\generated\deploy.wsdd
    Processing file org\kamal\wssample\ws\generated\deploy.wsdd
    Exception: AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.net.ConnectException: Connection refused: connect
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Conne
    ction refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:507)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
    ketFactory.java:153)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
    ketFactory.java:120)
    at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:1
    91)
    at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.ja
    va:404)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)

    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
    y.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:1792)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:439)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:404)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:410)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:320)
    at org.apache.axis.client.AdminClient.main(AdminClient.java:463)

    {http://xml.apache.org/axis/}hostname:SKAKKERLLWS1007

    ReplyDelete
  143. Hi,
    while executing the web service client pgm( java -cp %CLASSPATH%;.;..\lib\calculatorClientSide.jar org.kamal.wsclient.CalcClient ), i got the following error:
    Exception in thread "main" java.lang.NoClassDefFoundError: org/kamal/wsclient/CalcClient
    Caused by: java.lang.ClassNotFoundException: org.kamal.wsclient.CalcClient
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: org.kamal.wsclient.CalcClient. Program will exit.

    please help me

    Thanks in advance..
    Nithya

    ReplyDelete
  144. Thanks a lot Kamal, this is excellent tutorial for newbies.
    I am wondering if you can provide a way to for web clients to access the services.
    For example a form to access this service.
    I believe web services is for web clients most of the time.

    Thank you.

    ReplyDelete
  145. Hello Kamal,
    I have follow all your steps, my last steps was
    cd WS-sample/src
    java org.apache.axis.client.AdminClient org/yagnesh/wssample/ws/generated/deploy.wsdd -p 8081
    Processing file org/yagnesh/wssample/ws/generated/deploy.wsdd

    Done processing

    ### but when I try to access http://localhost:8081/axis/services/calculator?wsdl

    I get this error:
    AXIS error

    Could not generate WSDL!

    There is no SOAP service at this location

    Any idea?

    ReplyDelete
  146. // Anonymous (August 10, 2009 9:00 AM)
    // private SimpleCalculator calc = new SimpleCalculator().....
    // and hows this possible? Because you havent mentioned of SimpleCalculator.java anywhere when creating the wsdl file or wsdl2java operation.

    In Step 5: I have mentioned this; you are editing the generated BindingImpl class to delegate all method calls to this SimpleCalculator class.

    ReplyDelete
  147. // 127. Anonymous (September 11, 2009 11:40 AM)
    // java.lang.UnsupportedClassVersionError: org/kamal/wssample/ws/Calculator (Unsupported major.minor version 50.0)

    This seems to be related to the JDK/JRE version issue. Please read the explanation here.

    ReplyDelete
  148. // 128. Anonymous (September 24, 2009 1:08 AM)
    // Exception: AxisFault
    // faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    // faultSubcode:
    // faultString: java.net.ConnectException: Connection refused: connect

    Seems you haven't stared Tomcat before running the AdminClient. You must start Tomcat before running this.

    ReplyDelete
  149. // Nithya (September 24, 2009 3:10 PM)
    // Exception in thread "main" java.lang.NoClassDefFoundError: org/kamal/wsclient/CalcClient
    Caused by: java.lang.ClassNotFoundException: org.kamal.wsclient.CalcClient

    Hi Nithya,
    This is simply a classpath error; runtime could not find the CalcClient class. Please correct the classpath error and try again.

    Are you running this command from "classes" folder of the project?

    ReplyDelete
  150. // 130. Anonymous (October 03, 2009 3:57 AM)
    // I am wondering if you can provide a way to for web clients to access the services.

    If you are trying to use the web services with a web application; you can use a Servlet to act as a client to your web services.

    ReplyDelete
  151. // 131. Yagnesh (October 10, 2009 2:25 AM)
    // but when I try to access http://localhost:8081/axis/services/calculator?wsdl

    It seems you have started Tomcat on 8081? Have you correctly changed the WSDL generation step?

    ReplyDelete
  152. Hello Kamal,
    Yes I did, as a matter of fact here are all the steps.

    cd WS-sample/classes
    java org.apache.axis.wsdl.Java2WSDL -o ../calculator.wsdl -n urn:org.yagnesh.calculator -l http://verity2.hwwilsonweb.com:8081/axis/services/calculator org.yagnesh.wssample.ws.Calculator
    cd WS-sample
    java org.apache.axis.wsdl.WSDL2Java -o src -p org.yagnesh.wssample.ws.generated -s calculator.wsdl

    javac -d ../classes org/yagnesh/wssample/ws/generated/*.java

    edit
    WS-sample/src/org/yagnesh/wssample/ws/generated/CalculatorSoapBindingImpl.java

    package org.yagnesh.wssample.ws.generated;

    import org.yagnesh.wssample.SimpleCalculator;

    public class CalculatorSoapBindingImpl implements org.yagnesh.wssample.ws.genera
    ted.Calculator{
    private SimpleCalculator calc = new SimpleCalculator();
    public int add(int in0, int in1) throws java.rmi.RemoteException {
    return calc.add(in0, in1);
    }

    public int subtract(int in0, int in1) throws java.rmi.RemoteException {
    return calc.subtract(in0,in1);
    }

    }

    recompile
    javac -d ../classes org/yagnesh/wssample/ws/generated/*.java

    create jar file:
    cd WS-sample/classes
    jar cvf ../calculatorServerSide.jar org/yagnesh/wssample/*.class org/yagnesh/wssample/ws/*.class org/yagnesh/wssample/ws/generated/*.class

    jar cvf ../calculatorClientSide.jar org/yagnesh/wssample/ws/generated/CalculatorSoapBindingStub.class org/yagnesh/wssample/ws/generated/CalculatorServiceLocator.class org/yagnesh/wssample/ws/generated/CalculatorService.class org/yagnesh/wssample/ws/generated/Calculator.class
    cd WS-sample/src
    java org.apache.axis.client.AdminClient org/yagnesh/wssample/ws/generated/deploy.wsdd -p 8081
    Processing file org/yagnesh/wssample/ws/generated/deploy.wsdd

    ReplyDelete
  153. It is a very good tutorial for a beginner. Thank you very much Kamal for your effort. Keep it up! All the best!
    -Harihar

    ReplyDelete
  154. Hi Kamal,
    Do you know where should I look? for resolving the conflict, as describe at post #131

    ReplyDelete
  155. Hi Kamal,
    Thanks for this wonderful tutorial, it helped me a lot.

    Can we customize the access url http://localhost:8080/MyApp/MyServices/calculator

    If yes, will we be able to use the AdminClient for registering webservice ?

    Also can we deploy Axis 1.4 web services on Oracle 9iAS ?

    Thanks in advance.

    ReplyDelete
  156. Hi Kamal,

    Should we run the AdminClient to register webservice from the same machine where we are hosting webservices or can we run it remotely also ? Please advice, Thanks.

    ReplyDelete
  157. Great Tutorial, one minor change required though. We need to customize the server Side classes BEFORE compiling them. This issue has also been mentioned by someone else( in comment number 113) and I quote that person again since the changes proposed by him have not yet materialized.Here it goes.

    "CalculatorSoapBindingImpl (step 5) has to be edited before compilation in step 4 takes place. Steps 4 and 5 have to be rearranged in the following way:

    A. generate server side and client side classes for web service
    B. bind Web service with Functionality provider
    C. compile"

    Thanks again for a great tutorial
    Ahsun Taqveem

    ReplyDelete
  158. Hi Kamal,

    I am new to web services and trying to use services from 3rd party. I have all jars required to consume those services and it is working on weblogic 9.2 with Axis 1.4 jars. Now we are migrating to weblogic 10.3, else every thing is same. I have put all axis jars in startweblogic script classpath but getting error as

    Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.axis.configuration.FileProvider

    please suggest why it is not finding axis.jar ? is there any incompetibility with weblogic 10.3? PLease reply ASAP as i am stuck beacause of this issue.

    Thanks in advance.

    ReplyDelete
  159. Hi,
    I am new in web services, I go through the above said way
    but I am getting an error when I am running the command

    C:\workspace\WS Sample>java org.apache.axis.wsdl.WSDL2Java -o src -p org.kamal.wssample.ws.generated -s calculator.wsdl

    I am getting an error like

    java.net.MalformedURLException: no protocol: calculator.wsdl
    at java.net.URL."init"(URL.java:567)
    at java.net.URL."init"(URL.java:464)
    at java.net.URL."init"(URL.java:413)
    at weblogic.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:8
    at weblogic.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntityManage
    at weblogic.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocumentSca
    at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:499)
    at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
    at weblogic.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
    at weblogic.apache.xerces.parsers.DOMParser.parse(DOMParser.java:257)
    at weblogic.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:2
    at weblogic.xml.jaxp.RegistryDocumentBuilder.parse(RegistryDocumentBuilder.java:149
    at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:369)
    at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:420)
    at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:482)
    at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
    at java.lang.Thread.run(Thread.java:619)

    Please help me.Thanks in advance.

    ReplyDelete
  160. Hi

    I am new in web services,I am getting an error when I am executing dos command on point 4 as

    C:\workspace\WS Sample>java org.apache.axis.wsdl.WSDL2Java -o src -p org.kamal.wssample.ws.generated -s calculator.wsdl

    I am getting the following error
    java.net.MalformedURLException: no protocol: calculator.wsdl
    at java.net.URL.init(URL.java:567)
    at java.net.URL.init(URL.java:464)
    at java.net.URL.init(URL.java:413)
    at weblogic.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:836)
    at weblogic.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntityManager.java
    at weblogic.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocumentScannerIm
    at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:499)
    at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
    at weblogic.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
    at weblogic.apache.xerces.parsers.DOMParser.parse(DOMParser.java:257)
    at weblogic.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:201)
    at weblogic.xml.jaxp.RegistryDocumentBuilder.parse(RegistryDocumentBuilder.java:149)
    at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:369)
    at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:420)
    at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:482)
    at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
    at java.lang.Thread.run(Thread.java:619)

    Please help me.Thanks in Advance

    ReplyDelete
  161. Hi Kamal,

    I go through your tutorials and run the web services.Initially I found some issue in making the server side as well as Client side java core generation.But finally I run the application.It really a nice tutorials for the new Web services developer.
    It will be nice if you add the tutorials for the Apache Axis2.It really a nice work.Thanks a lot.

    Thanks
    Chhote

    ReplyDelete
  162. thank you. you did a great job. Very easy to understand and nice tutorial,

    Thank,
    Srikanth G

    ReplyDelete
  163. I tried to generate WSDL from java file using RAD7.0 run command and by passing the required arguments as mentioned, but I am getting the following error

    The java class is not found: javax.xml.rpc.encoding.TypeMappingRegistry

    Can you please suggest.

    ReplyDelete
  164. Hi,
    Really this is very helpful for any ws newbies.
    I have used axis1.4 to generate client side ws stubs and made jar of the classes of the same. When I tried http://localhost:8080/axis/happyaxis.jsp , i am getting warnings "could not find class org.apache.xml.security.Init from file xmlsec.jar
    XML Security is not supported.". And also I have written a client file for accessing the ws through generated jar file and I am getting error "An error was discovered processing the header
    " . I am using 1.4 jdk, and tomcat 5.5.

    Anybody please help me out of this issue if you could..

    ReplyDelete
  165. Hi Kamal,

    i am getting above error after running below java2WSDL statement at command prompt:

    " Unrecognized Option: -o
    Could not create the Java virtual machine "


    java org.apache.axis.wsdl.Java2WSDL
    -o ..\calculator.wsdl
    -n urn:org.kamal.calculator
    -l http://localhost:8080/axis/services/calculator
    org.kamal.wssample.ws.C alculator


    Could please help me on this...?

    ReplyDelete
  166. // 149 Anonymous
    You need to enter the complete command in one line, even though I have shown each option in separate line.

    ReplyDelete
  167. Hi Kamal,

    Regarding 149 issue,
    Thanks for your response.

    Actually i tried complete statement in the same line only. Eventhough i got below error .

    "Unrecognized Option: -o
    Could not create the Java Virtual machine"

    Even i just tried with "java -classpath org.apache.axis.wsdl.Java2WSDL -o" at command line. Then also i got same error.

    I have the all jar files in class path.

    It seems command prompt is not able to find Java2WSDL class.

    is there any clue please?

    Thanks,
    Vijay

    ReplyDelete
  168. // 149
    java org.apache.axis.wsdl.Java2WSDL

    Can you try the above command and see whether it displays the options list. If the options list is not shown, then there's a classpath issue.

    Or else I doubt this is happening due to a typo. Please try adding one option at a time and see where you encounter the issue.

    ReplyDelete
  169. Kamal,

    Reg 149,

    Thank you very much for your valuable support.
    Its due to classpath issues only.
    I used environment variable as just "Path" instead of "CLASSPATH".

    Now, this Java2WSDL statmement has executed well.

    Thanks,
    Vijay

    ReplyDelete
  170. Hi Kamal,
    I am geeting a soap fault response like "ws security header missing".
    I need to pass the UsernameToken header in the request. I generated the client side jar using axis and wrriten a client to call the services by using the generated classes. But it is expecting a security header in the request. I am newbie to webservice. I am not sure how to pass the ws security header through my client program as I didnt have any stub class to provide a username to the service calss. Please help me to resolve this..

    ReplyDelete
  171. i asked some question about web serivce and select the comment as google account????thinking that it would ask my gmail id but i don;t where it went.

    Please help

    ReplyDelete
  172. I'm new to Web service and your tutorial helped me a log to get started in Webservices.

    I was able to run through your tutorial which brought me some question.
    Can we create our own web application and register one of its classes as Web service?That is instead of copying the class file into the webapps/axis/WEB-INF classes webapps/MyWebApp/Web-INF..?

    Please explain the steps.

    ReplyDelete
  173. I have the same problem as in 120 comment. I didn't change package structure but I have error after go to link "http://localhost:8080/axis/services/calculator?wsdl":
    java.lang.ClassNotFoundException: org.kamal.wssample.ws.generated.CalculatorSoapBindingImpl

    I verify my calculatorServerSide.jar in %CATALINA_HOME%\webapps\axis\WEB-INF\lib - it there. Why axis can't find this class? the package=org.kamal.wssample.ws.generated
    WSDD=

    Thanks for answer,
    -Vit

    ReplyDelete
  174. Wonderful work!! I really appreicate this. Indeed I developed my first web service with your help!! Thanks again

    KARTHIK

    ReplyDelete
  175. Related to my previous post 157. When I do copy my classes from calculatorServerSide.jar into %AXIS_HOME%\WEB-INF\classes it works fine !!
    But it can't find the classes in jar file which located in %AXIS_HOME%\WEB-INF\lib

    What is wrong?
    Thanks,
    -Vit

    ReplyDelete
  176. Hi Kamal, congratulations by your excelent work.

    I'm having a problem, my result is :

    15 + 6 = -3
    15 – 6 = -3

    My CalculatorSoapBindingImpl.java :

    package org.kamal.wssample.ws.generated;

    public class CalculatorSoapBindingImpl implements org.kamal.wssample.ws.generated.Calculator{
    public int add(int in0, int in1) throws java.rmi.RemoteException {
    return calc.add(in0,in1);
    }

    public int subtract(int in0, int in1) throws java.rmi.RemoteException {
    return calc.subtract(in0,in1);
    }

    }

    Please, Kamal, i need your help, thanks.

    Best Regards, Valter Henrique.

    ReplyDelete
  177. Dear Valter Henrique

    Looks like your binding class is not compiled after coupling with original class, hence results are -3

    ReplyDelete
  178. in wich step, of the tutorial says to compile the binding class?
    Becausa i do everything, what kamal says,but maybe i'm missing this step,unfortunately.

    Thanks 161.

    ReplyDelete
  179. Hi Kamal, great tutorial! I have a problem with deploying the service, when i browse "http://127.0.0.1:8080/axis//services/calculator?wsdl" i get the following message from axis:

    Sorry, something seems to have gone wrong... here are the details:

    Exception - java.lang.ClassFormatError: Incompatible magic value 1885430635 in class file org/kamal/wssample/ws/generated/CalculatorSoapBindingImpl

    I'm guessing i might have messed with CalculatorSoapBindingImpl as i replaced its previous code with the one you present here (which includes the SimpleCalculator implementation)...and saved it. Didn't use command prompt for this, i manually opened the file, replaced the data and saved it with the same name...could this be the fault?


    Thanks in advance...

    Also, the calculator service does not appear on axis services page...

    ReplyDelete
  180. Thanks Kamal! Your tutorial really helps me to learn how to create a web service using Apache Axis. I searched through the Internet for tutorials but yours is the best!

    Regina

    ReplyDelete
  181. I would like to deploy this webservice on weblogic 8.1, instead of tomcat. Can you please mention the steps for the same?..........Santosh Aherkar (santosh.aherkar@gmail.com)

    ReplyDelete
  182. Hi kamal,

    I am trying to invoke a web service inside another web service and encountering errors. I am using axis1.4, Tomcat 6. Is it possible to do this ? I would really appreciate if could provide me some starting point on this.

    --
    Esh

    ReplyDelete
  183. Hi, my webservice returns an array of javax.activation.DataHandler but when I generate the wsdl file using jva2wsdl...the wsdl file is generated in error... it gives some schema related error. Can anyone help on this issue...

    Thanks
    Parul

    ReplyDelete
  184. Kamal Mettananda,

    This is an awesome article, step-by-step, simple and easy to remember.

    Keep up the good work.

    Cheers!

    Daniel Suarez Jabonete
    Pragmatic Developer
    Philippines

    ReplyDelete
  185. This is an excellent startup tutorial

    ReplyDelete
  186. Hi Kamal,

    It's really gr8. I am new in web service. And wana learn since past few month. But I did not got anything. But now I got you tutorial. I did every thing and now I m satisfy.

    I am getting an error. When I am going to deploy it. I changed the port to 8090. But still getting same error.

    ********************************************
    d:\WS-Sample\src>java org.apache.axis.client.AdminClient org\kamal\wssample\ws\g
    enerated\deploy.wsdd
    log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectR
    esourceBundle).
    log4j:WARN Please initialize the log4j system properly.
    Processing file org\kamal\wssample\ws\generated\deploy.wsdd
    Exception: AxisFault
    faultCode: {http://xml.apache.org/axis/}HTTP
    faultSubcode:
    faultString: (404)Not Found
    faultActor:
    faultNode:
    faultDetail:
    {}:return code: 404
    <html><head><title>Apache Tomcat/6.0.26 - Error report</tit
    le><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;ba
    ckground-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;
    color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Ari
    al,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-f
    amily:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-famil
    y:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:
    Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color :
    black;}A.name {color : black;}HR {color : #525D76;}--></style> </hea
    d><body><h1>HTTP Status 404 - /axis/services/AdminService</h1&
    gt;<HR size="1" noshade="noshade"><p><b>ty
    pe</b> Status report</p><p><b>message</b> <u&gt
    ;/axis/services/AdminService</u></p><p><b>description&lt
    ;/b> <u>The requested resource (/axis/services/AdminService) is not ava
    ilable.</u></p><HR size="1" noshade="noshade"
    ><h3>Apache Tomcat/6.0.26</h3></body></html>
    {http://xml.apache.org/axis/}HttpErrorCode:404
    *******************************************************

    Is there I am missing somthing.

    Thanks,

    Vinay

    ReplyDelete
  187. problem in creating wsdl..
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl/
    Java2WSDL


    plz help..

    ReplyDelete
  188. THank you very much for this excellent tutorial...

    ReplyDelete
  189. Am getting the following exception,can you please help me out?

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl
    Java2WSDL
    Caused by: java.lang.ClassNotFoundException: org.apache.axis.wsdl.Java2WSDL
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: org.apache.axis.wsdl.Java2WSDL. Program will ex
    t.

    ReplyDelete
  190. Exception: AxisFault
    faultCode: {http://xml.apache.org/axis/}HTTP
    faultSubcode:
    faultString: (404)Not found
    faultActor:
    faultNode:
    faultDetail:
    {}:return code: 404
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <HTML><HEAD>
    <TITLE>404 Not found</TITLE>
    </HEAD><BODY><H1>Not found</H1>
    The requested URL /axis/services/AdminService was not found on this server</B
    ODY></HTML>

    {http://xml.apache.org/axis/}HttpErrorCode:404

    ReplyDelete
  191. Hi and thanx for the tutorial. I have a problem though running teh Java2WSDL command. I get the following error about :
    Usage: java org.apache.axis.wsdl.Java2WSDL [options] class-of-portType
    Options:
    -h, --help
    print this message and exit
    -I, --input
    input WSDL filename
    -o, --output
    output WSDL filename
    ... etc
    This is my command:

    java org.apache.axis.wsdl.Java2WSDL
    -o ..\calculator.wsdl
    -n urn:org.kamal.calculator
    -l http://localhost:8080/axis/services/calculator
    org.kamal.wssample.ws.Calculator

    What I am missing?

    Daniel

    ReplyDelete
  192. Thanks Kamal for great post!

    I am getting following error when trying to run AdminClient step.

    WS-Sample\src>java org.apache.axis.client.AdminClient or
    g\kamal\wssample\ws\generated\deploy.wsdd
    Processing file org\kamal\wssample\ws\generated\deploy.wsdd
    Exception: AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.lang.NumberFormatException: For input string: "Not"

    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}stackTrace:java.lang.NumberFormatException:
    For input string: "Not"
    at java.lang.NumberFormatException.forInputString(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at org.apache.axis.transport.http.HTTPSender.readHeadersFromSocket(HTTPS
    ender.java:640)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:143)

    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
    y.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:1792)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:439)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:404)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:410)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:320)
    at org.apache.axis.client.AdminClient.main(AdminClient.java:463)

    Only different I have is, I am using tomcat 6 and port 9090. I made sure that I have Tomcat up and running.

    Can you help?

    ReplyDelete
  193. renaming xerces-1.4.4.jar to xerces.jar worked in the lib directory of ur class path worked for me

    ReplyDelete
  194. i want to implement the above with web logic 8.1 .so what changes needs to be done in the above tutorial. I tried the same with weblogic but it is not working.when i type this command java org.apache.axis.client.AdminClient it gives me error java.lang.noClassDefFound exception. i added the above jars in classpath also.please help me to implement this tutorial in web logic.
    thanks in advance.

    ReplyDelete
  195. I had never worked on WS earlier.
    This gives a clear understanding of what are Web Services are.
    Good article and good example.

    Thanks
    -Ananymous.

    ReplyDelete
  196. Hi Kamal, really excellent tutorial!
    I only encountered on problem a lot of people already mentioned as well. I get a connection refused when trying to register the web service. Tomcat 6.14 is up and running and provides the WSDL for the AdminService. The Tomcat is using the port 8090 and I even changed the default of 8080 in the WSDL of the example to 8090 and generated the stubs again, comiled and jar'd them. Restarted Tomcat, but I get the following exception when registering.
    I also included the activation.jar library as the exception mentions that class javax.activation.DataHandler is missing. That did not help either.

    Thanks for any help!

    - Unable to find required classes (javax.activation.DataHandler and javax.mail.i
    nternet.MimeMultipart). Attachment support is disabled.
    Processing file ..\src\com\wssample\ws\generated\deploy.wsdd
    Exception: AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.net.ConnectException: Connection refused: connect
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Conne
    ction refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
    at java.net.Socket.connect(Socket.java:452)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
    ketFactory.java:153)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
    ketFactory.java:120)
    at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:1
    91)
    at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.ja
    va:404)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)

    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
    y.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:1792)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:439)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:404)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:410)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:320)
    at org.apache.axis.client.AdminClient.main(AdminClient.java:463)

    ReplyDelete
  197. hai,

    this is good sight for learners. i got the following exception
    so reply this problem


    F:\calc\src>java org.apache.axis.client.AdminClient gopi\gg\generated\deploy.wsd
    d
    log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectR
    esourceBundle).
    log4j:WARN Please initialize the log4j system properly.
    Processing file gopi\gg\generated\deploy.wsdd
    Exception: AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.net.ConnectException: Connection refused: connect
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Conne
    ction refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(Unknown Source)
    at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
    ketFactory.java:153)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
    ketFactory.java:120)
    at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:1
    91)
    at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.ja
    va:404)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)

    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
    y.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:1792)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:439)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:404)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:410)
    at org.apache.axis.client.AdminClient.process(AdminClient.java:320)
    at org.apache.axis.client.AdminClient.main(AdminClient.java:463)

    {http://xml.apache.org/axis/}hostname:cotelligentsys


    F:\calc\src>

    ReplyDelete
  198. Hi Kamal,

    Thanks so much for your useful tutorial.
    I have a little question:

    Everything went fine till I run the client, it is returing '-3' as a result and the following error:

    Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.

    15 + 6 = -3
    15 - 6 = -3


    Can you help with that please.
    Jaxrpc.jer is in the classpath

    Many thanks for your precious help.

    ReplyDelete
  199. Solution:
    --------

    It was to do step 5.
    The problem is that most readers do not notice that step 5 is about to ADD the 2 lines of code into the existing class 'CalculatorSoapBindingImpl' .

    return calc.add(a, b);
    return calc.substract(a,b):


    In the tutorial it is not explicit :) it emphasis the fact that the reader should ANALYSE the code :)

    Thanks for the tutorial!

    ReplyDelete

Post a Comment

We appreciate your opinions, suggestions and criticism.

Creative Commons License Digizol by Kamal Mettananda is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 License .
URL of this page must be supplied in attribution
© 2004-2017