I have an error since 2-3 days from now so I have an axis2 project and I'm trying to use the following webservice on the server side :
HelloService.java
public class HelloService {
public String sayHelloWorldFrom(String from) {
String result = "Hello, world, from " + from;
System.out.println(result);
return result;
}
}
Here is the wsdl that I've generated :
<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://hello.org" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" targetNamespace="http://hello.org">
<wsdl:documentation>HelloService</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://hello.org">
<xs:element name="sayHelloWorldFrom">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="from" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="sayHelloWorldFromResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="sayHelloWorldFromRequest">
<wsdl:part name="parameters" element="ns:sayHelloWorldFrom"/>
</wsdl:message>
<wsdl:message name="sayHelloWorldFromResponse">
<wsdl:part name="parameters" element="ns:sayHelloWorldFromResponse"/>
</wsdl:message>
<wsdl:portType name="HelloServicePortType">
<wsdl:operation name="sayHelloWorldFrom">
<wsdl:input message="ns:sayHelloWorldFromRequest" wsaw:Action="urn:sayHelloWorldFrom"/>
<wsdl:output message="ns:sayHelloWorldFromResponse" wsaw:Action="urn:sayHelloWorldFromResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloServiceSoap11Binding" type="ns:HelloServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="sayHelloWorldFrom">
<soap:operation soapAction="urn:sayHelloWorldFrom" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="HelloServiceSoap12Binding" type="ns:HelloServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="sayHelloWorldFrom">
<soap12:operation soapAction="urn:sayHelloWorldFrom" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="HelloServiceHttpBinding" type="ns:HelloServicePortType">
<http:binding verb="POST"/>
<wsdl:operation name="sayHelloWorldFrom">
<http:operation location="sayHelloWorldFrom"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloService">
<wsdl:port name="HelloServiceHttpSoap11Endpoint" binding="ns:HelloServiceSoap11Binding">
<soap:address location="http://localhost:8080/Server_war_exploded/services/HelloService.HelloServiceHttpSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="HelloServiceHttpSoap12Endpoint" binding="ns:HelloServiceSoap12Binding">
<soap12:address location="http://localhost:8080/Server_war_exploded/services/HelloService.HelloServiceHttpSoap12Endpoint/"/>
</wsdl:port>
<wsdl:port name="HelloServiceHttpEndpoint" binding="ns:HelloServiceHttpBinding">
<http:address location="http://localhost:8080/Server_war_exploded/services/HelloService.HelloServiceHttpEndpoint/"/>
</wsdl:port>
</wsdl:service>
But when I'm trying to use the hello world service from client side, I have the following error :
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis2/databinding/ADBException
at org.hello.HelloService.main(HelloService.java:10)
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.databinding.ADBException
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 1 more
Process finished with exit code 1
So as you can see in the HelloService.java, I don't use the jaw-xs annotations because Tomcat server doesn't identify the annotations
Thanks for your help.
//Edit : 05/05/2020 I'm using maven and the axis2 jars are already added in the module :
Some dependencies are defined with Provided scope which is not automatically added in runtime.
The solution is to either change the scope of the dependencies in pom.xml
or change the Run/Debug configuration to include the dependencies with the provided scope in runtime.