Reputation: 887
I am new to web service. i am trying to implement a sample wsdl web service through Axis2 engine.
Versions: Axis2 - > axis2-1.1.1, Ant - > apache-ant-1.8.2
web service are created with out any errors. when am testing through command prompt( Ant Test ) am getting error like
[java] Exception in thread "main" org.apache.axis2.AxisFault: Please implem
ent jdl.helloworld.webservices.service.HelloWorldSkeleton#SayHello
[java] at org.apache.axis2.description.OutInAxisOperationClient.send(Ou
tInAxisOperation.java:271)
[java] at org.apache.axis2.description.OutInAxisOperationClient.execute
(OutInAxisOperation.java:202)
[java] at jdl.helloworld.webservices.service.HelloWorldStub.SayHello(Un
known Source)
[java] at jdl.helloworld.webservices.client.Client.main(Unknown Source)
[java] Java Result: 1
This is HelloWorldServiceSkeleton.java under jdl\helloworld\webservices\service directory
package jdl.helloworld.webservices.service;
import org.apache.ws.axis2.helloworld.SayHello;
import org.apache.ws.axis2.helloworld.SayHelloResponse;
import org.apache.ws.axis2.helloworld.PrintValues;
public class HelloWorldServiceSkeleton
{
public org.apache.ws.axis2.helloworld.SayHelloResponse SayHello(org.apache.ws.axis2.helloworld.SayHello param0)throws Exception {
SayHelloResponse sayHelloResponse=new SayHelloResponse();
try{
sayHelloResponse.setName(param0.getName());
System.out.println("Hello World Service called");
}catch(Exception e){
System.out.println(" Error Occured : "+e);
}
return sayHelloResponse;
}
public String PrintValues(org.apache.ws.axis2.helloworld.PrintValues param1){
return "printvalues";
}
}
Client.java file
package jdl.helloworld.webservices.client;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import jdl.helloworld.webservices.service.HelloWorldStub;
import jdl.helloworld.webservices.service.HelloWorldStub.SayHello;
import jdl.helloworld.webservices.service.HelloWorldStub.SayHelloResponse;
import jdl.helloworld.webservices.service.HelloWorldStub.PrintValues;
import jdl.helloworld.webservices.service.HelloWorldStub.PrintValuesResponse;
public class Client
{
public static void main(String[] args)throws Exception
{
System.out.println("-- Inside Client --");
ConfigurationContext configurationContext=ConfigurationContextFactory.createConfigurationContextFromFileSystem("C:\\axis2-1.1.1\\repository", "C:\\axis2-1.1.1\\conf\\axis2.xml");
HelloWorldStub helloWorldStub=new HelloWorldStub(configurationContext,"http://localhost:8080/axis2/services/HelloWorld");
System.out.println(" --> sayHello Begin");
SayHello sayHello=new SayHello();
sayHello.setName("user");
SayHelloResponse sayHelloResponse=helloWorldStub.SayHello(sayHello);
System.out.println(" --> sayHello Response : "+sayHelloResponse.getName());
}
}
HelloWorld.wsdl file
<wsdl:definitions name="HelloWorld"
xmlns:tns="http://ws.apache.org/axis2/HelloWorld/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://ws.apache.org/axis2/HelloWorld/">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://ws.apache.org/axis2/HelloWorld/">
<xsd:element name="SayHello">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" name="Name" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="SayHelloResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Name" minOccurs="0" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="PrintValues">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Name" minOccurs="0" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="PrintValuesResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Name" minOccurs="0" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="SayHelloSoapIn">
<wsdl:part name="parameters" element="tns:SayHello"/>
</wsdl:message>
<wsdl:message name="SayHelloSoapOut">
<wsdl:part name="parameters" element="tns:SayHelloResponse"/>
</wsdl:message>
<wsdl:message name="PrintValuesSoapOut">
<wsdl:part name="parameters" element="tns:PrintValues"/>
</wsdl:message>
<wsdl:message name="PrintValuesSoapOut">
<wsdl:part name="parameters" element="tns:PrintValuesResponse"/>
</wsdl:message>
<wsdl:portType name="HelloWorldSoap">
<wsdl:operation name="SayHello">
<wsdl:input message="tns:SayHelloSoapIn"/>
<wsdl:output message="tns:SayHelloSoapOut"/>
</wsdl:operation>
<wsdl:operation name="PrintValues">
<wsdl:input message="tns:PrintValuesSoapIn"/>
<wsdl:output message="tns:PrintValuesSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloWorldSoap" type="tns:HelloWorldSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="SayHello">
<soap:operation soapAction="http://localhost:8080/axis2/HelloWorld/SayHello" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="PrintValues">
<soap:operation soapAction="http://localhost:8080/axis2/HelloWorld/PrintValues" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloWorld">
<wsdl:port name="HelloWorldSoap"
binding="tns:HelloWorldSoap">
<soap:address location="http://localhost:8080/axis2/services/HelloWorld" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Please help me.
Upvotes: 0
Views: 8662
Reputation: 25439
Did you use wsdl2java to generate Java classes from your WSDL? wsdl2java generates a skeleton service class for you, and it generates a services.xml file which says to use the skeleton class as the service class. The automatically-generated skeleton throws an AxisFault with that message for any web service call that it handles. It appears that Axis2 is using this skeleton class as the service class, instead of your service class.
Normally, you will write a service class which extends the skeleton class (or else implements the skeleton interface). When you package the service, you should alter the services.xml file so that it specifies your class as the service class, instead of the automatically generated skeleton class.
Upvotes: 0