1

我在我的应用程序中使用 SOAP 请求,因为我的 SOAP 请求结构如下:

 <Data>
       <Keys>
          <String>
            <V>string</V>
            <K>string</K>
          </String>
          <String>
            <V>string</V>
            <K>string</K>
          </String>
        <Keys>
        <CriteriaKeys>
          <String>
            <V>string</V>
            <K>string</K>
          </String>
          <String>
            <V>string</V>
            <K>string</K>
          </String>
        </CriteriaKeys>
        <No>int</No>
        <Size>int</Size>
      </Data>

在此我在设置请求的输入时遇到问题。如何使用 addproperty 方法为这种复杂类型设置输入。以下是我的 SOAP 调用代码:

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);    
            SoapObject authentication = new SoapObject(NAMESPACE,"authentication"); 

                 Setting property for authentication

                request.addSoapObject(authentication);
               SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.setOutputSoapObject(request);
            envelope.dotNet=true;
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
            try
            {               
                androidHttpTransport.call(SOAP_ACTION,envelope);
                SoapObject result=(SoapObject)envelope.getResponse(); 
                Log.i("myApp",result.toString());  
                } 
4

1 回答 1

1

如果您使用的是 HTTP 的本机方法/类,那么有一种简单的方法可以在您的网络调用中设置此请求:

HttpPost post = new HttpPost(url);
post.setEntity(new StringEntity(yourxmlrequestString, "utf-8"));
于 2012-05-18T05:46:28.407 回答