我需要将一个对象从 android 传递给一个肥皂网络服务,但我得到一个错误,即驱动程序对象为空。如何在不出现此错误的情况下将对象传递给soap Web 服务?
这是对象:
<soap:Body>
<CreateDriver xmlns="http://tempuri.org/">
<objDriver>
<status>int</status>
<DriverId>int</DriverId>
<FirstName>string</FirstName>
<LastName>string</LastName>
<AccessCode>string</AccessCode>
<Picture>string</Picture>
<Signature>string</Signature>
<Email>string</Email>
<Phone>string</Phone>
<Status>int</Status>
<CreationDate>dateTime</CreationDate>
<ModificationDate>dateTime</ModificationDate>
<CreatedUserId>int</CreatedUserId>
<CreatedUser>
<status>int</status>
<UserID>int</UserID>
<FirstName>string</FirstName>
<LastName>string</LastName>
<UserName>string</UserName>
<Password>string</Password>
<ConfirmPassword>string</ConfirmPassword>
<UserMail>string</UserMail>
<CreationDate>dateTime</CreationDate>
<ModificationDate>dateTime</ModificationDate>
<Status>int</Status>
<CreatedUserId>int</CreatedUserId>
<ModifiedUserId>int</ModifiedUserId>
</CreatedUser>
<ModifiedUserId>int</ModifiedUserId>
<ModifiedUser>
<status>int</status>
<UserID>int</UserID>
<FirstName>string</FirstName>
<LastName>string</LastName>
<UserName>string</UserName>
<Password>string</Password>
<ConfirmPassword>string</ConfirmPassword>
<UserMail>string</UserMail>
<CreationDate>dateTime</CreationDate>
<ModificationDate>dateTime</ModificationDate>
<Status>int</Status>
<CreatedUserId>int</CreatedUserId>
<ModifiedUserId>int</ModifiedUserId>
</ModifiedUser>
</objDriver>
<bytArrPicture>base64Binary</bytArrPicture>
<bytArrSignature>base64Binary</bytArrSignature>
</CreateDriver>
</soap:Body>
</soap:Envelope>
这是我的代码:
public void postData() throws IOException, XmlPullParserException {
CreateDriver cDriver = new CreateDriver();
cDriver.setFirstName("n");
cDriver.setLastName("n");
SoapObject objDriver = new SoapObject(NAMESPACE, METHOD_NAME);
objDriver.addProperty("FirstName", "n");
objDriver.addProperty("LastName", "n");
// request.
// request.addProperty("CreateDriverSimple",request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(objDriver);
envelope.dotNet = true;
// this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject) envelope.bodyIn;