Hi all,
I have installed Axis 1.4 ,Tomcat-4.1.34 ,jdk 1.4 to try out web services examples.
I'm trying to deploy and test a simple HelloService program.
This program has a method sayHello that takes a string parameter and returns a string result.
This is the web service
public class HelloService
{
public String sayHello(String name)
{
System.out.println("sayHelloTo(String name)");
return "Hello " + name + ", How are you doing?";
}
}
This is the client
public class TestClient
{
public static void main(String [] args)
{
String endpoint = "http://localhost:8080/axis/HelloService.jws";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName("sayHello");
call.addParameter( "op1", org.apache.axis.Constants.XSD_STRING, ParameterMode.IN );
call.setReturnType( org.apache.axis.Constants.XSD_STRING );
String ret = (String) call.invoke( new Object[] { "Hello!" } ); /* Line 52 : exception is thrown */
System.out.println("Sent 'Hello!', got '" + ret + "'");
}
When i run the client file which invokes the web service,i get the following NullPointerException.
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.lang.NullPointerException
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.lang.NullPointerException
at org.apache.axis.message.MessageElement.addTextNode(MessageElement.java:1396)
at org.apache.axis.message.SOAPHandler.addTextNode(SOAPHandler.java:148)
at org.apache.axis.message.SOAPHandler.endElement(SOAPHandler.java:112)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at weblogic.apache.xerces.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:585)
at weblogic.apache.xerces.impl.XMLNamespaceBinder.handleEndElement(XMLNamespaceBinder.java:898)
at weblogic.apache.xerces.impl.XMLNamespaceBinder.endElement(XMLNamespaceBinder.java:644)
at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndEle
ment(XMLDocumentFragmentScannerImpl.java:1008)
at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentCo
ntentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1469)
at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocume
nt(XMLDocumentFragmentScannerImpl.java:329)
at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:525)
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.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:135)
at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:138)
java.lang.NullPointerException
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(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:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at samples.userguide.example1.TestClient.main(TestClient.java:52)
Caused by: java.lang.NullPointerException
at org.apache.axis.message.MessageElement.addTextNode(MessageElement.java:1396)
at org.apache.axis.message.SOAPHandler.addTextNode(SOAPHandler.java:148)
I checked the TCP monitor.It shows the string sent in the request soap message and the result string sent in the SOAP response.
If however i write another method that takes an integer as a parameter and returns an integer,there is no problem.The method successfully returns the integer result.
Can somebody give me a solution to this problem.
regards,
kumari