How to transfer an object from android to a soapy web service?

I need to pass an object from android to a soapy web service, but I get an error that the driver object is null. How to transfer an object to a soap network without receiving this error?

Here is the object:

<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> 

Here is my code:

 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; 
+4
source share
1 answer

check this topic, he had a similar problem, and there was provided a solution to Problems with the ksoap2 parameter for Android

  SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); //Use this to add parameters //request.addProperty("Parameter","Value"); //Declare the version of the SOAP request SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.setOutputSoapObject(request); //Needed to make the internet call HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); try { //this is the actual part that will call the webservice androidHttpTransport.call(SOAP_ACTION, envelope); } catch (Exception e) { e.printStackTrace(); } // Get the SoapResult from the envelope body. SoapObject result = (SoapObject)envelope.bodyIn; 
0
source

Source: https://habr.com/ru/post/1439326/


All Articles