Forums Register Login

Problem in Telephony webservices!!!

+Pie Number of slices to send: Send
I am trying to build a simple client application which can make use of the Telephony webservices exposed through Avaya Application Enablement Server(AES)server.I am using eclipse3.1 on Windows2000 server.I have correctly added all the jar files like jaxrpc,saaj,telSvcStubs,axis etc.
I just want to use makeCall procedure of this webservice to call from one destination to another but I am getting two null pointer exceptions.Please help me out to solve this problem.
My code is as following:
package com.avaya.aes.telephonyPortal;
import java.net.URL;
import java.net.MalformedURLException;
import java.rmi.RemoteException;
//import javax.xml.rpc.ServiceException;
import org.apache.axis.Constants;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.SOAPHeaderElement;
import com.avaya.xml.ws.TelephonyService._2005._04._04.TelephonyServiceService;
import com.avaya.xml.ws.TelephonyService._2005._04._04.TelephonyServiceServiceLocator;
import com.avaya.xml.ws.TelephonyService._2005._04._04.TelephonyServiceSoapBindingStub;
public class TelephonyS {

/**
* @param args
*/

public static final String AXIS_SESSION_NAMESPACE = "http://xml.avaya.com/ws/session";
public static final String AXIS_SESSIONID_HEADERNAME = "sessionID";
public TelephonyServiceSoapBindingStub telephonyStub = null;
//public TelephonyService port=null;
public TelephonyServiceService service = null;
public String sessionID;
public String remoteSessionID;
String userName="ctiuser";//to be added
String password="agclpso123";//to be added
String switchName="2010";// to be added
URL serviceURL=null;
public TelephonyS()
{
remoteSessionID="0";
}
public void initiate()
{
service = new TelephonyServiceServiceLocator();
try{
serviceURL = new URL("http://192.168.210.17:8080/axis/services/TelephonyService"); //can be 8443
//System.out.println("Exception123"+serviceURL);
}catch(MalformedURLException e){System.out.println("Exceptioninfirst"+e);}
try{
telephonyStub = (TelephonyServiceSoapBindingStub) service.getTelephonyService(serviceURL );
//System.out.println(telephonyStub);
}catch(Exception e){System.out.println("Exception1:"+e);}
String userAtSwitch = userName + "@" + switchName;
try{
telephonyStub.clearHeaders();
telephonyStub.setUsername( userAtSwitch );
telephonyStub.setPassword( password );
setRemoteSessionID( "0" );
System.out.println("1"+telephonyStub);
telephonyStub.attach();// throwing nullpointer exception
System.out.println("2"+telephonyStub);
setRemoteSessionID( getRemoteSessionID() );
}catch(Exception e)
{
System.out.println("3"+telephonyStub);
telephonyStub.clearHeaders();
telephonyStub.setUsername( null );
telephonyStub.setPassword( null );
setRemoteSessionID( "0" );
System.out.println("Exception2:"+e);}
}

public String getRemoteSessionID()
{

try{
Call previousCall = ( (Service) service ).getCall();
SOAPEnvelope response = previousCall.getResponseMessage().getSOAPEnvelope();
SOAPHeaderElement header = response.getHeaderByName( AXIS_SESSION_NAMESPACE, AXIS_SESSIONID_HEADERNAME );
return (String) header.getValueAsType( Constants.XSD_STRING );
}
catch ( Exception e )
{
return "0";
}
}
public void setRemoteSessionID( String id )
{
TelephonyServiceSoapBindingStub stub = (TelephonyServiceSoapBindingStub) telephonyStub;

// Set SOAP session header
stub.clearHeaders();
stub.setHeader( AXIS_SESSION_NAMESPACE, AXIS_SESSIONID_HEADERNAME, id );
remoteSessionID = id;

}
public void makeCall( String ext1, String ext2 ) throws RemoteException
{
System.out.println("Starting to make a call"+telephonyStub);
telephonyStub.makeCall( ext1, ext2 );// throwing null pointer exception
setRemoteSessionID( getRemoteSessionID() );
}
public static void main(String[] args) {
// TODO Auto-generated method stub
TelephonyS ts=new TelephonyS();
ts.initiate();

try{
ts.makeCall("2010","2200");
}catch(Exception e)
{
System.out.println("Exception3:"+e);
}
}

}

And the exceptions are as following:

1com.avaya.xml.ws.TelephonyService._2005._04._04.TelephonyServiceSoapBindingStub@1bb9a58
3com.avaya.xml.ws.TelephonyService._2005._04._04.TelephonyServiceSoapBindingStub@1bb9a58
Exception2:java.lang.NullPointerException
Starting to make a callcom.avaya.xml.ws.TelephonyService._2005._04._04.TelephonyServiceSoapBindingStub@1bb9a58
Exception3:java.lang.NullPointerException

Then I tried to code this application other way round.Please have a look at it:
package com.avaya.aes.telephonyPortal;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import org.apache.axis.AxisFault;
import org.apache.axis.Constants;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.SOAPHeaderElement;
import com.avaya.xml.ws.TelephonyService._2005._04._04.TelephonyService;
import com.avaya.xml.ws.TelephonyService._2005._04._04.TelephonyServiceService;
import com.avaya.xml.ws.TelephonyService._2005._04._04.TelephonyServiceServiceLocator;
import com.avaya.xml.ws.TelephonyService._2005._04._04.TelephonyServiceSoapBindingStub;
public class Telsvc {
private TelephonyService port = null;
private TelephonyServiceService service = null;
private TelephonyServiceSoapBindingStub telSvcSoap = null;
private static final String serviceName="http://xml.avaya.com/ws/TelephonyService/2005/04/04";
private static final String sessionNameSpace ="http://xml.avaya.com/ws/session";
private static final String sessionKey = "sessionID";
/**
* @param args
*/
public Telsvc(String serviceIP, String username, String password,String switchName, boolean useSSL) {
URL serviceURL=null;
service = new TelephonyServiceServiceLocator();
try {
if (useSSL) {
serviceURL = new URL("https://" + serviceIP +":8443/axis/services/TelephonyService");
}
else {
serviceURL = new URL("http://" + serviceIP+":8080/axis/services/TelephonyService");} }
catch(Exception e)
{System.out.println("Error accessing URL");}
if(serviceURL==null)
{try
{
port = service.getTelephonyService();
telSvcSoap = (TelephonyServiceSoapBindingStub)port;
System.out.println("Service URL is NULL");
} catch(Exception e)
{
System.out.println("Error binding to Telephony Service");
e.printStackTrace();
return;
}
}
else {
try {
port = service.getTelephonyService(serviceURL);
telSvcSoap = (TelephonyServiceSoapBindingStub)port;
} catch(Exception e)
{
System.out.println("Error binding to Telephony Service");
e.printStackTrace();
return;
}
}
try {
setHTTPHeader(username, password, switchName);
}
catch (Exception e)
{
System.out.println("Received exception when setting header " + e);
e.printStackTrace();
}
}
public void attach() throws Exception
{
port.attach();
setSessionID();
}
public void release() throws Exception
{
port.release();
}
public void makeCall(String ext1, String ext2)
{
System.out.println("Starting to make a call");
try {
port.makeCall(ext1, ext2);
} catch(Exception e){
System.out.println("Error invoking makecall to the Telephony Web service " + e);
e.printStackTrace();
return;
}
setSessionID();
}
public void disconnectCall(String ext1) {
System.out.println("Disconnecting call");
try {port.disconnectActiveCall(ext1);}
catch(Exception e)
{System.out.println("Error invoking disconnect to the Telephony Web service " + e);
e.printStackTrace();
return;
}
setSessionID();
}
public void answerCall(String ext1)
{
System.out.println("Answering call");
try {
port.answerAlertingCall(ext1);}
catch(Exception e){System.out.println("Error invoking answer to the Telephony Web service " + e); e.printStackTrace();
return;
}
setSessionID();
}
public void conferenceCall(String ext1, String ext2)
{System.out.println("Conferencing call");
try {
port.singleStepConferenceCall(ext1, ext2);
} catch(Exception e){
System.out.println("Error invoking conference to the Telephony Web service " + e);
e.printStackTrace();
return;}
setSessionID();
}
public void transferCall(String ext1, String ext2)
{
System.out.println("Transfering call");
try {
port.singleStepTransferCall(ext1, ext2);
} catch(Exception e)
{System.out.println("Error invoking transfer to the Telephony Web service " + e);
e.printStackTrace();
return;}
setSessionID();
}
private String getSessionID() {
String sessionID = "0";
Call lastCall = null;
SOAPEnvelope returnEnv;
SOAPHeaderElement hdr;
try {
lastCall = ((Service)service).getCall();
}
catch (ServiceException e)
{
System.out.println("Error getting call object" + e);
}try
{
returnEnv = lastCall.getResponseMessage().getSOAPEnvelope();
hdr = returnEnv.getHeaderByName(sessionNameSpace, sessionKey);
sessionID = (String)hdr.getValueAsType(Constants.XSD_STRING);
} catch (AxisFault e)
{
System.out.println("Could not get session header" + e);
}
catch (Exception e)
{
System.out.println("Could not get session header" + e);
}
return sessionID;
}
private void setSessionID() {
String sessionID = getSessionID();
telSvcSoap.setHeader(sessionNameSpace, sessionKey, sessionID);
System.out.println("setHeader(): sessionID="+sessionID);
}
private void setHTTPHeader(String userName, String password,String switchName) throws Exception, ServiceException, RemoteException
{
telSvcSoap.clearHeaders();// Set credentials in the HTTP header
String userAtSwitch = userName+"@"+switchName;
telSvcSoap.setUsername(userAtSwitch);
telSvcSoap.setPassword(password);
System.out.println("setHTTPHeader: username="+userAtSwitch+" password=*****");
}


public static void main(String[] args) {
// TODO Auto-generated method stub
Telsvc obj=new Telsvc("192.168.210.17","ctiuser","agclpsouser123","2010",false);
try {
obj.attach();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
obj.makeCall("2010","2200");
}

}

And the errors are as following:
setHTTPHeader: username=ctiuser@2010 password=*****
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 java.util.Hashtable.put(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.setProperty(Unknown Source)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:246)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at com.avaya.xml.ws.TelephonyService._2005._04._04.TelephonyServiceSoapBindingStub.attach(TelephonyServiceSoapBindingStub.java:440)
at com.avaya.aes.telephonyPortal.Telsvc.attach(Telsvc.java:71)
at com.avaya.aes.telephonyPortal.Telsvc.main(Telsvc.java:176)


java.lang.NullPointerException
at org.apache.axis.AxisFault.makeFault(AxisFault.java:129)
at org.apache.axis.client.Call.invoke(Call.java:2251)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at com.avaya.xml.ws.TelephonyService._2005._04._04.TelephonyServiceSoapBindingStub.attach(TelephonyServiceSoapBindingStub.java:440)
at com.avaya.aes.telephonyPortal.Telsvc.attach(Telsvc.java:71)
at com.avaya.aes.telephonyPortal.Telsvc.main(Telsvc.java:176)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.put(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.setProperty(Unknown Source)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:246)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
... 5 more
Starting to make a call
Error invoking makecall to the Telephony Web service java.lang.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 java.util.Hashtable.put(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.setProperty(Unknown Source)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:246)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at com.avaya.xml.ws.TelephonyService._2005._04._04.TelephonyServiceSoapBindingStub.makeCall(TelephonyServiceSoapBindingStub.java:461)
at com.avaya.aes.telephonyPortal.Telsvc.makeCall(Telsvc.java:82)
at com.avaya.aes.telephonyPortal.Telsvc.main(Telsvc.java:181)


java.lang.NullPointerException
at org.apache.axis.AxisFault.makeFault(AxisFault.java:129)
at org.apache.axis.client.Call.invoke(Call.java:2251)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at com.avaya.xml.ws.TelephonyService._2005._04._04.TelephonyServiceSoapBindingStub.makeCall(TelephonyServiceSoapBindingStub.java:461)
at com.avaya.aes.telephonyPortal.Telsvc.makeCall(Telsvc.java:82)
at com.avaya.aes.telephonyPortal.Telsvc.main(Telsvc.java:181)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.put(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.setProperty(Unknown Source)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:246)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
... 5 more
Please help me out.I am unable to resolve the problem.
I knew that guy would be trouble! Thanks tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2470 times.
Similar Threads
axis -ClassCastException...Pls help
Simple Web Service using Axis
problem in Axis sample application
Consuming Webservice in Java
faultString: org.xml.sax.SAXParseException: Premature end of file.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:26:15.