Пожалуйста, помогите мне только новичку в программировании веб-сервисов и Android
это мой веб-сервис
<br>
<?php
function aes256_cbc_decrypt($key = '', $data = '')
{
$iv = $key;
if ($data == '' || $key == ''){ return ''; }
if (32 !== strlen($key)) $key = hash('SHA256', $key, true);
if (16 !== strlen($iv)) $iv = hash('MD5', $iv, true);
$data = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv);
$padding = ord($data[strlen($data) - 1]);
return substr($data, 0, -$padding);
}
// Web Service Key
$wskey = "Your WSKey Here";
// Encryption Key;
$key = "";
$soap_result = "";
$wsdl = "http://localhost/womb_ci/webservice/wsdl";
try {
// Initialize Soap Client
$server_wsdl = "Soap WSDL Here";
$soap_server = new SoapClient($wsdl);
// Prepare SOAP Header Parameter Request
// ReturnFormat : json or xml
$header_param = array(
'WSKey'=>$wskey,
'ReturnFormat'=>'json'
);
$header_param = new SoapVar($header_param,SOAP_ENC_OBJECT);
$soap_header = new SoapHeader($server_wsdl,'Authentication',$header_param);
/*------------------------encryption and decreption function------------------------*/
$Response_Result = '';
/* ---------------- Call Soap Method (Web Service Method) -------------------- */
// Web Service Method (Function) to Call
$wsMethod = "WOMB_account";
// Web Service Parameter
$wsParam['WOMBaccountData'] = array(
'username' => 'DFDGDFG_0_40',
'password' => '123456',
);
//dont know how to call this in android
// Call Web Service Method
echo $soap_result = $soap_server->__soapCall($wsMethod, array($wsParam), NULL,$soap_header);
/* -- Get Soap Response Body -- */
// Note : SOAP Response Body contains encrypted string
$Response_Result = $soap_result;
// Decrypt $Response_Result
$Decoded_Result = base64_decode($Response_Result);
$Decrypted_Result = aes256_cbc_decrypt($key,$Decoded_Result);
// Display Result
// Note : Decrypted Result can be String or Array --> Please check the response code return type
echo $Decrypted_Result;
} catch(SoapException $e) {
print_r($e);
}
?>
и это мой код в android
public class UserSynchronization extends AsyncTask<Void, Integer, String>{
private Context context;
private ProgressDialog dialog;
private String alertMessage;
private String urlWebservice;
public UserSynchronization(Context context) {
super();
this.context = context;
dialog = new ProgressDialog(context);
urlWebservice = "http://" + WombConstants.configurationInfo.getServerIp() + "/womb_ci/index.php/webservice/";
Log.i("IP Address", "IP Address : " + urlWebservice);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
dialog.setMessage("Getting Data from Local Server : Please wait....");
dialog.setCancelable(true);
dialog.show();
// dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
// dialog.setProgress(0);
// dialog.setMessage("Synchronizing Data");
// dialog.setCancelable(false);
// dialog.show();
}
protected String doInBackground(Void... users) {
String NAMESPACE = "http://" + WombConstants.configurationInfo.getServerIp() + "/womb_ci/webservice/wsdl";
//String NAMESPACE = "http://womb_ci.webservice.womb_account";
String METHODNAME = "WOMB_account";
String SOAPACTION = "http://" + WombConstants.configurationInfo.getServerIp() + "/womb_ci/webservice/wsdl/WOMB_account";
SoapObject request;
SoapSerializationEnvelope envelope;
HttpTransportSE ht;
SoapPrimitive response;
Serializer serializer;
String json = "";
String wsReply;
//String[] wsReply;
Gson gson;
try {
System.out.println("NAMESPACE = " + NAMESPACE);
System.out.println("SOAPACTION = " + SOAPACTION );
request = new SoapObject(NAMESPACE, METHODNAME);
//parameter
//request.addProperty("WOMBaccountData",new HashMap<String,String>{["username","DFDGDFG_0_40"],["password","123456"]});
request.addProperty("username","DFDGDFG_0_40");
request.addProperty("password", "123456");
//serialization
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
System.out.println("Serialize= " + request);
//transport
ht = new HttpTransportSE(this.urlWebservice,5000000);
System.out.println("Start Get Data");
//call
ht.call(SOAPACTION, envelope);
wsReply = (String)envelope.getResponse();
//byte[] decodedresponse = new String(Base64.decode(new String(Base64.decode(wsReply, Base64.DEFAULT),Base64.DEFAULT)));
System.out.println("WEB SERVICE RESPONSE = " + wsReply);
//Log.d("TEST", "decodeValue = " + new String(decodedresponse));
//String onins = "cuenco";
//String pare = Base64.encode(onins,Base64.DEFAULT);
//Log.d("TEST", "encoded = " + pare);
//gson = new Gson();
// UserResponse r;
// r = gson.fromJson(wsReply, UserResponse.class);
//System.out.println("Resp r: " + r.toString());
//UserService service = new UserService(this.context);
// service.insert(r.getResponseValue().getUserList());
// System.out.println("Response : " + wsReply);
} catch (Exception e) {
Log.d("error_UserSynchronization", e.getMessage(), e);
}
return "DONE ";
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
dialog.dismiss();
Toast toast = Toast.makeText(context, "Synchronization " + result, Toast.LENGTH_SHORT);
toast.show();
}
}
это ответ в Logcat
04-27 09:18:58.452 26467-26467/ph.gov.doh.womb D/InputMethodManager: windowDismissed mLockisused = false
04-27 09:18:58.452 26467-26646/ph.gov.doh.womb I/System.out: NAMESPACE=http://192.168.1.109/womb_ci/webservice/wsdl
SOAPACTION=http://192.168.1.109/womb_ci/webservice/wsdl/WOMB_account
Serialize= WOMB_account{username=DFDGDFG_0_40; password=123456; }
Start Get Data
04-27 09:18:58.462 26467-26467/ph.gov.doh.womb D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
*FMB* isFloatingMenuEnabled return false
04-27 09:18:58.482 26467-26646/ph.gov.doh.womb I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
(HTTPLog)-Static: isShipBuild true
(HTTPLog)-Thread-3451-671080272: SmartBonding Enabling is false, SHIP_BUILD is true, log to file is false, DBG is false
(HTTPLog)-Thread-3451-671080272: SMARTBONDING_FEATURE_ENABLED is false
(HTTPLog)-Static: isSBSettingEnabled false
KnoxVpnUidStorageknoxVpnSupported API value returned is false
KnoxVpnUidStorageknoxVpnSupported API value returned is false
04-27 09:18:58.502 26467-26467/ph.gov.doh.womb E/ViewRootImpl: sendUserActionEvent() mView == null
04-27 09:19:00.454 26467-26646/ph.gov.doh.womb I/System.out: WEB SERVICE RESPONSE = Array
ответом всегда будет слово ARRAY, потому что я не знаю, как добавить это в свой
soap call $wsParam['WOMBaccountData'] = array(
'username' => 'DFDGDFG_0_40',
'password' => '123456',
);
hope somebody can help thank you
сэр, возможно, вы знаете, как включить это в мой вызов мыла $ wsParam ['WOMBaccountData'] = array ('username' => 'DFDGDFG_0_40', 'password' => '123456',);
пожалуйста, помогите заранее спасибо





