无法使用java程序连接到workday帐户。我们需要测试的功能是“获取帐户详细信息,获取工作人员详细信息”等。
我们从我们的一个客户那里收到了一个特定于租户的workday WSDL文件。使用eclipse和Apache,CXF2.3.1生成了所有的java类和客户端类。客户端类具有main方法。但是当我运行client类时,我得到了一个错误。
公共最终类HumanResourcesPort_HumanResources_Client {
private static final QName SERVICE_NAME = new QName("urn:com.workday/bsvc/Human_Resources", "Human_ResourcesService");
private HumanResourcesPort_HumanResources_Client() {
}
public static void main(String args[]) throws Exception {
org.apache.cxf.jaxws.JaxWsProxyFactoryBean factory = new org.apache.cxf.jaxws.JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
// Utilize the class which was auto-generated by Apache CXF wsdl2java for service interface
factory.setServiceClass(HumanResourcesService.class);
factory.setAddress("https://wd9-impl-services23.workday.com/ccx/service/abc/Human_Resources/v32.1");
long timeout = 10000L;
org.apache.cxf.transports.http.configuration.HTTPClientPolicy policy = new org.apache.cxf.transports.http.configuration.HTTPClientPolicy();
policy.setConnectionTimeout(timeout);
policy.setReceiveTimeout(timeout);
URL wsdlURL = HumanResourcesService.WSDL_LOCATION;
if (args.length > 0) {
File wsdlFile = new File(args[0]);
try {
if (wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
} else {
wsdlURL = new URL(args[0]);
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
HumanResourcesService ss = new HumanResourcesService(wsdlURL, SERVICE_NAME);
HumanResourcesPort port = ss.getHumanResources();
org.apache.cxf.endpoint.Client client = org.apache.cxf.frontend.ClientProxy.getClient(port);
org.apache.cxf.transport.http.HTTPConduit httpConduit = (org.apache.cxf.transport.http.HTTPConduit) client.getConduit();
org.apache.cxf.configuration.security.AuthorizationPolicy authorization = httpConduit.getAuthorization();
authorization.setUserName("UserName12357@abc");
authorization.setPassword("Passw0rd@123#");
httpConduit.setClient(policy);
getservertime(port);
System.exit(0);
}
公共静态void getservertime(HumanResourcesPort端口)
{
System.out.println("Invoking getServerTimestamp...");
workday.com.bsvc.ServerTimestampGetType _getServerTimestamp_body = new workday.com.bsvc.ServerTimestampGetType();
_getServerTimestamp_body.setVersion("Version-202634838");
try {
workday.com.bsvc.ServerTimestampType _getServerTimestamp__return = port.getServerTimestamp(_getServerTimestamp_body);
System.out.println("getServerTimestamp.result=" + _getServerTimestamp__return);
} catch (ValidationFaultMsg e) {
System.out.println("Expected exception: Validation_FaultMsg has occurred.");
System.out.println(e.toString());
} catch (ProcessingFaultMsg e) {
System.out.println("Expected exception: Processing_FaultMsg has occurred.");
System.out.println(e.toString());
}
}
}
预期结果: Java程序应该能够连接到Workday帐户,并且应该能够正确使用web服务。
实际结果:
正在调用getServerTimestamp...在线程"main“源中出现异常:在org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:146)的com.sun.proxy.$Proxy32.getServerTimestamp(Unknown源中,无效的用户名或密码)在workday.com.bsvc.human_resources.HumanResourcesPort_HumanResources_Client.main(HumanResourcesPort_HumanResources_Client.java:78)的workday.com.bsvc.human_resources.HumanResourcesPort_HumanResources_Client.getservertime(HumanResourcesPort_HumanResources_Client.java:89)中导致发件人: org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:46)的org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:75)上的org.apache.cxf.binding.soap.SoapFault:用户名或密码无效
发布于 2019-07-17 02:26:16
可能设置用户名和密码的模式是错误的。如果可以的话,测试这个模式。
HumanResourcesPort port = ss.getHumanResources();
BindingProvider prov = (BindingProvider) port;
prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "username");
prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "password");
https://stackoverflow.com/questions/57051159
复制相似问题