错误使用Ksoap2从Android发送Params到Webservice PHP

时间:2012-06-20 09:53:22

标签: android ksoap2

我使用kso​​ap2在android中向webservice PHP发送了resquest 为:

  String NAMESPACE="http://www.localhost:81/wsdl";
             String METHOD_NAME="insertUser";
             String SOAP_ACTIONS="http://www.localhost:81/wsdl#insertUser";
             String URL="http://10.0.2.2:81/phpWebservice/pgsql.php";
             SoapObject request=new SoapObject(NAMESPACE, METHOD_NAME);
             **request.addProperty("name","地獄");**       
             request.addProperty("birthday", "2012/02/01");     
             SoapSerializationEnvelope envelope=new   SoapSerializationEnvelope(SoapEnvelope.VER11);
             //envelope.dotNet=true;
             envelope.setOutputSoapObject(request);
             HttpTransportSE androidhttpTranport=new HttpTransportSE (URL);
androidhttpTranport.call(SOAP_ACTIONS, envelope);

Webservicde php as:

  require("nusoap.php");
  $server = new soap_server();
  $server->register('insertUser',                    // method name     
  array('name' => 'xsd:string','birthday'=>'xsd:string'),          // input parameters
  array('return' => 'xsd:int'),    // output parameters
  $namespace,                         // namespace
  $namespace . '#insertUser',                   // soapaction
  'rpc',                                    // style
  'encoded',                                // use
  'Get all user id dua vao =0'        // documentation
);  

function insertUser($name,$birthday)
{
value of $name=?? Why
}
来自android的'name'的值是“地狱” 但是webserver $ name ='??' webservice上$ name的值是错误的。 你能救我吗?

1 个答案:

答案 0 :(得分:0)

您可以编码和解码

String encoded =URLEncoder.encode("地獄", "UTF-8"); at app            
String de= URLDecoder.decode(encoded, "UTF-8"); at server

http://php.net/manual/en/function.urldecode.php