Android 使用java访问sharePoint Web服务 StringEntity实体=新的StringEntity(““我的用户名”“我的密码”); 实体。setContentEncoding(“utf-8”); post1.设置实体(实体); System.out.println(“呼叫服务”); 字符串响应=client.execute(post,handler); System.out.println(“响应为”+响应);
我得到的xml响应如下:Android 使用java访问sharePoint Web服务 StringEntity实体=新的StringEntity(““我的用户名”“我的密码”); 实体。setContentEncoding(“utf-8”); post1.设置实体(实体); System.out.println(“呼叫服务”); 字符串响应=client.execute(post,handler); System.out.println(“响应为”+响应);,android,web-services,sharepoint,Android,Web Services,Sharepoint,我得到的xml响应如下: StringEntity entity = new StringEntity("<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://sche
StringEntity entity = new StringEntity("<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><Login xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\"><username>"myusername"</username><password>"mypassword"</password></Login></soap:Body></soap:Envelope>");
entity.setContentEncoding("utf-8");
post1.setEntity(entity);
System.out.println("calling service");
String response = client.execute(post, handler);
System.out.println("response is "+response);
密码不匹配
0
谁能告诉我我哪里错了?”
提前感谢 使用以下任一方法以哈希格式发送密码。但在此之前,请检查您的服务器是否接受哈希密码,如果接受,则检查哪种类型(SHA/MD5) 对于SHA-256:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<LoginResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<LoginResult>
<ErrorCode>PasswordNotMatch</ErrorCode>
<TimeoutSeconds>0</TimeoutSeconds>
</LoginResult>
</LoginResponse>
</soap:Body>
</soap:Envelope>
/**
* Perform SHA-256 hash on the given string.
* It returns a hashed string as Base64 string.
* @param str String to be hashed in SHA-256
* @return Base64 string if hashed successfully, else NULL
*/
public static String getHashSHA256(String str){
String hash = null;
try{
MessageDigest digest = null;
try { digest = MessageDigest.getInstance("SHA-256"); }
catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return hash;
}
digest.reset();
hash = Base64.encodeToString(digest.digest(str.getBytes()),
Base64.DEFAULT).trim();
digest = null;
}
catch (Exception e) {
Log.e("SHA-256", "Error in getHashSHA256() due to -> " + e.toString());
}
return hash;
}
对于MD5:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<LoginResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<LoginResult>
<ErrorCode>PasswordNotMatch</ErrorCode>
<TimeoutSeconds>0</TimeoutSeconds>
</LoginResult>
</LoginResponse>
</soap:Body>
</soap:Envelope>
/**
* Perform SHA-256 hash on the given string.
* It returns a hashed string as Base64 string.
* @param str String to be hashed in SHA-256
* @return Base64 string if hashed successfully, else NULL
*/
public static String getHashSHA256(String str){
String hash = null;
try{
MessageDigest digest = null;
try { digest = MessageDigest.getInstance("SHA-256"); }
catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return hash;
}
digest.reset();
hash = Base64.encodeToString(digest.digest(str.getBytes()),
Base64.DEFAULT).trim();
digest = null;
}
catch (Exception e) {
Log.e("SHA-256", "Error in getHashSHA256() due to -> " + e.toString());
}
return hash;
}
您是否缺少任何安全要求?我的意思是,你们的网络服务接受明文密码还是散列密码?你们能告诉我如何以散列格式发送它吗?若你们可以访问服务器,为什么不干脆禁用密码检查,看看你们的网络呼叫是否仍然失败?我在使用在线sharepoint web services,所以密码是必需的