A testQTws.java class was created to demostrate calling a web service. For an integrator to invoke the web service, they will have to construct the following code. This code creates a SoapBindingStub object, sets the username and password and then invokes the web service.
|
public static qtracswebws.datatype.VehicleInfo getVehInfo(String username, String password, AssetIdentifier ai) throws Exception
{
setSSL();
qtracswebws.websvcs.QTWebSvcsSoapBindingStub binding;
qtracswebws.datatype.VehicleInfo info = new qtracswebws.datatype.VehicleInfo() ;
try
{
binding = (qtracswebws.websvcs.QTWebSvcsSoapBindingStub)
new qtracswebws.websvcs.QTWebSvcsServiceLocator().getQTWebSvcs();
binding.setTimeout(60000);
try
{
binding.setUsername(username);
binding.setPassword(password);
info = binding.getVehicleInformation(ai);
}
catch (sharedws.exception.WSException e1)
{
System.out.println("WSException Exception caught: " + e1);
}
}
catch (javax.xml.rpc.ServiceException jre)
{
if(jre.getLinkedCause()!=null)
jre.getLinkedCause().printStackTrace();
}
return info;
}
|
This code would be invoked by:
|
AssetIdentifier ai = new AssetIdentifier();
ai.setId("TESTVEH");
ai.setScac("SCAC");
qtracswebws.datatype.VehicleInfo info = new qtracswebws.datatype.VehicleInfo();
// get Vehicle Info
info = testQTws.getVehInfo("USER@COMPANY", "password", ai);
|