Java 创建SOAP请求头

Java 创建SOAP请求头,java,android,soap,ksoap2,Java,Android,Soap,Ksoap2,我想通过使用ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar以编程方式创建具有以下结构的SOAP请求: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:con="http://www.google.com/Consumer/"> <soapenv:Header> <con:

我想通过使用ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar以编程方式创建具有以下结构的SOAP请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:con="http://www.google.com/Consumer/">
   <soapenv:Header>
      <con:RequestHeader>
         <!--Optional:-->
         <serviceId></serviceId>
         <serviceCode>CUSTREG</serviceCode>
         <phaseCode>MOBREG</phaseCode>
         <subTransactionCode>MOBREG</subTransactionCode>
         <interactionCode>LOGIN</interactionCode>
         <!--Optional:-->
         <bearer></bearer>
         <!--Optional:-->
         <clientRefId></clientRefId>
      </con:RequestHeader>
   </soapenv:Header>
   <soapenv:Body>
      <con:Login>
         <LoginRequest>
            <uniqueId>+911234567890</uniqueId>
            <password>123456</password>
            <!--Optional:-->
            <uuid></uuid>

         </LoginRequest>
      </con:Login>
   </soapenv:Body>
</soapenv:Envelope>

卡斯特雷格
莫布雷格
莫布雷格
登录
+911234567890
123456

提前感谢。

请先更新您的ksoap jar,这是最新的ksoap jar??最新版本-3.3.0:感谢您的快速回复。如何在请求中添加标头??如果答案对您有帮助,请接受。在SOAP请求中,我想发送标头信息。您还可以提供如何使用ksoap jar创建标头请求。为什么要发送标头?上面的代码不起作用?
public class GetLogin extends AsyncTask<String, Void, String>
    {
        ProgressDialog pd ;
        public String WSDL_TARGET_NAMESPACE = "http://tempuri.org/"; // initialise it with your NAMESPACE
        private Context _context;
        public String URL = "";  // initialise it with your URL
        public GetLogin(Context c)
        {
            _context = c;
        }

        protected void onPreExecute()
        {
            super.onPreExecute();
            pd = new ProgressDialog(_context);
            pd.setTitle("Authenticating");
            pd.setMessage("Please wait...");
            pd.setCancelable(true);
            pd.setIndeterminate(true);
            pd.show();
        }

        @Override
        protected String doInBackground(String... params) {
            // TODO Auto-generated method stub
            if (params[0].trim().equals("")) {
                return "";
            }

            SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, params[0].trim());

            request.addProperty("uniqueId",params[1]);
            request.addProperty("password",params[2]);   // uniqueId and password are method parameters. You should use exactly the way it is.

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

            envelope.dotNet = true;

            envelope.setOutputSoapObject(request);


            HttpTransportSE httpTransport = new HttpTransportSE(URL);

            try
            {
                httpTransport.call(WSDL_TARGET_NAMESPACE + params[0].trim(), envelope);

                SoapPrimitive response = (SoapPrimitive) envelope.getResponse();

                return response.toString();
            }

            catch (Exception e)
            {
                if (pd.isShowing())
                    pd.dismiss();

            }

        }


        protected void onPostExecute(String str)
        {
            super.onPostExecute(str);

                if (pd.isShowing())
                    pd.dismiss();
            // str has the retrieved information from the web service.
        }
 new GetLogin(yourActivity.this).execute("MethodName", "Parameter1", "Parameter2");