Hi,
I am new to Webservice. Please see my code below and the exception I am
getting. Can someone please explain where am I going wrong?
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceFactory;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
.
.
.
.
.
try {
Service service = new Service();
Call call = (Call)service.createCall(new
QName("ValidateEmailSoap"));
String endpoint =
"http://www.webservicex.net/ValidateEmail.asmx";
call.setPortName(new QName("ValidateEmailSoap"));
call.setProperty( Call.SOAPACTION_USE_PROPERTY, new Boolean(
true ) );
call.setProperty( Call.SOAPACTION_URI_PROPERTY,
"http://www.webservicex.net/IsValidEmail");
call.setTargetEndpointAddress(new URL(endpoint));
call.setOperationName( new QName("IsValidEmail") );
String email = new String("[email protected]"); // pass email
call.addParameter("Email",org.apache.axis.Constants.XSD_STRING,
ParameterMode.INOUT);
call.setReturnType(org.apache.axis.Constants.XSD_ANY);
Object answer = call.invoke(new Object [] {email});
System.out.println("Got result : " + answer.toString());
} catch (Exception e) {
//System.err.println(e.toString());
e.printStackTrace();
}
I am getting following error. Can someone please explain what am I missing??
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
faultSubcode:
faultString: System.Web.Services.Protocols.SoapException: Server was unable to
process request. ---> System.NullReferenceException: Object reference not
set to an instance of an object.
at ValidateEmail.ValidateEmail.VerifyEmail(String Email)
at ValidateEmail.ValidateEmail.IsValidEmail(String Email)
--- End of inner exception stack trace ---
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:System.Web.Services.Protocols.SoapException:
Server was unable to process request. ---> System.NullReferenceException:
Object reference not set to an instance of an object.
at ValidateEmail.ValidateEmail.VerifyEmail(String Email)
at ValidateEmail.ValidateEmail.IsValidEmail(String Email)
--- End of inner exception stack trace ---
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 org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
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 za.co.pps.servicemanager.ServiceManager.main(ServiceManager.java:51)
Regards,
VJ