SAP HR的webservice调用心得(https)
前提:
SAP HR提供给你webservice到wsdl文件
第一步:将wsdl文件转成java
下载axis2-1.6.2-bin
转到文件夹 \axis2-1.6.2\bin
cmd到\axis2-1.6.2\bin文件夹 执行
wsdl2java -uri 800_SI_HR_ORG_INService.wsdl
//wsdl2java -uri 800_SI_HR_PERSON_INService.wsdl
在bin文件夹中可以看到src代码
第二步:将代码拷入工程调用
将src拷入工程
写如下调用代码:
SI_HR_ORG_INServiceStub stub = new SI_HR_ORG_INServiceStub();
Authenticator authenticator = new Authenticator();
authenticator.setAuthSchemes(authScheme);
authenticator.setUsername(Conf.getValue("hr_user"));
authenticator.setPassword(Conf.getValue("hr_password"));
// authenticator.setHost("HOST");
// authenticator.setDomain("DOMAIN");
// authenticator.setPort(443);
authenticator.setAllowedRetry(true);
authenticator.setPreemptiveAuthentication(true);
Options options = stub._getServiceClient().getOptions();
options.setProperty(HTTPConstants.AUTHENTICATE, authenticator);
options.setProperty(
org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
options.setProperty(HTTPConstants.CHAR_SET_ENCODING,"utf-8");
options.setTransportInProtocol("https");
options.setProperty(HTTPConstants.SO_TIMEOUT, 300000);
// options.setTo(new
// EndpointReference("https://abc.def.com/EWS/Exchange.asmx"));
stub._getServiceClient().setOptions(options);
//TODO 调用具体方法
stub.方法名();