0
我需要將此soap請求轉換爲java(Android)。我正在使用ksoap2庫來做到這一點,但我不斷收到需要的錯誤認證。 對Java的安全請求(Android)
我的Java代碼
SoapObject remoteUser = new SoapObject(NAMESPACE, "RemoteUser");
remoteUser.addProperty("UserLogin", "ws_admin");
remoteUser.addProperty("UserPassword", "Password1");
SoapObject userContact = new SoapObject(NAMESPACE, "UserContact");
userContact.addProperty("UserLogin", "sqa101");
userContact.addProperty("UserPassword", "Password1");
request.addSoapObject(remoteUser);
request.addSoapObject(userContact);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
webResponse = response.toString();
這是錯誤我得到: 九月八日至19日:58:35.690:W/System.err的(737):的SOAPFault - 的faultcode:「SOAP-ENV :服務器'faultstring:'3001:未知用戶試圖執行消息類型UserAuthenticationRequest。需要認證。' faultactor:'null'detail:[email protected]
任何幫助將不勝感激。
更新:我找到了答案。問題在於我使用的格式。以下代碼工作。
PropertyInfo remoteUser =new PropertyInfo();
remoteUser.setName("RemoteUser");
SoapObject login = new SoapObject();
login.addProperty("UserLogin", "admin");
login.addProperty("UserAuthenticator", "Password");
remoteUser.setValue(login);
remoteUser.setType(String.class);
request.addProperty(remoteUser);
PropertyInfo userContact =new PropertyInfo();
userContact.setName("UserContact");
SoapObject login2 = new SoapObject();
login2.addProperty("UserLogin", "username");
login2.addProperty("UserPassword", "Password");
userContact.setValue(login2);
userContact.setType(String.class);
request.addProperty(userContact);