Created
September 7, 2017 15:38
-
-
Save anjijava16/7a0d85715c2a759dc2f7627601f3e725 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sample WebService Example (Service Side ) | |
public class LoginWsServiceImpl implements LoginWsService { | |
private static Logger LOGGERS = Logger.getLogger("common"); | |
private static Logger EDRS = Logger.getLogger("common1"); | |
private LoginServiceIF loginServiceIF; | |
public Response login(String username, String password, String appName, String appId) throws RemoteException { | |
LOGGERS.info("Enter into the login operation"); | |
String generatedId = TACGenerator.generateOTP(8); | |
EDRS.info("LOG_REQ" + "|" + generatedId + "|" + username + "|" + password + "|" + appName + "|" + appId + "|" | |
+ DateUtils.processTimestampYYYYMMDD()); | |
Response response = new Response(); | |
loginServiceIF = ServiceFactory.getLoginFactory(); | |
String isValid = validateParams(username, password, appName, appId); | |
if ("0".equalsIgnoreCase(isValid)) { | |
if (username == null) { | |
response.setStatusCode("10"); | |
response.setStatusMessage("Username is man"); | |
} else { | |
response.setStatusCode("0"); | |
response.setStatusMessage("SUCCESS"); | |
} | |
} else { | |
response.setStatusCode(isValid); | |
response.setStatusMessage(PropertiyRaderUtils.getPropertiesValue(isValid)); | |
EDRS.info("LOG_RES" + "|" + generatedId + "|" + isValid + "|" | |
+ PropertiyRaderUtils.getPropertiesValue(isValid) + "|" + DateUtils.processTimestampYYYYMMDD()); | |
LOGGERS.info("Exit into the login operation"); | |
} | |
return response; | |
} | |
} | |
// WebServic Client Code | |
public static String deleteLocation(Integer locationId){ | |
String deleteLocation=LocationConstants.LOCATION_CHANGE_DEFAULT; | |
HttpClient client = new HttpClient(); | |
PostMethod method = new PostMethod(LocationConstants.LOCATION_URL); | |
int returnCode = LocationConstants.DEFAULT_VALUE; | |
try { | |
returnCode=client.executeMethod(method); | |
} catch (HttpException e) { | |
} catch (IOException e) { | |
} | |
if(returnCode==LocationConstants.HTTP_SUCCESS){ | |
LocationServiceWSImplService locationService=new LocationServiceWSImplService(LocationServiceWSImplService.WSDL_LOCATION,LocationServiceWSImplService.SERVICE); | |
LocationService locationServiceIF=locationService.getLocationServiceWSImplPort(); | |
try { | |
deleteLocation=locationServiceIF.deleteLocationOperation(locationId); | |
} catch (WsException_Exception e) { | |
} | |
}else{ | |
deleteLocation=LocationConstants.UNABLE_CONNECT_SYSTEM; | |
} | |
return deleteLocation; | |
} | |
Refere Link https://github.com/anjijava16/wsService_Client/blob/master/wsServiceClient/src/com/bug/iwinner/ws/client/WsHandlerFactory.java | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment