Reputation: 161
My SOAP request format is as follows:
<authentication>
<LoginID>string</LoginID>
<Password>string</Password>
</authentication>
<Id>int</Id>
<Str>string</Str>
I have to pass the Loginid,pass,id,str as input .So i am setting this through addproperty which is as follows:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo usrid =new PropertyInfo();
usrid.setName("LoginID");
usrid.setValue(userid);
usrid.setType(String.class);
request.addProperty(usrid);
//
PropertyInfo pass =new PropertyInfo();
pass.setName("Password");
pass.setValue(password);
pass.setType(String.class);
request.addProperty(pass);
PropertyInfo rote =new PropertyInfo();
rote.setName("Id");
rote.setValue(4114616);
rote.setType(int.class);
request.addProperty(rote);
//
PropertyInfo dte =new PropertyInfo();
dte.setName("Str");
dte.setValue(date);
dte.setType(String.class);
request.addProperty(dte);
Is this the correct way i am setting.Because i am receiving the error:
SoapFault - faultcode: 'soap:Server'
faultstring: 'System.Web.Services.Protocols.SoapException: Server was unable to
process request. ---> System.ArgumentNullException: String reference not set to an
instance of a String.
Anybody can please help me.
Upvotes: 1
Views: 2037
Reputation: 3057
Try this snippet to create your soap request:
String YOUR_LOGIN_ID = "Your login id";
String YOUR_PASSWORD = "Your password";
int YOUR_ID = 1;
String YOUR_STR = "Your str value";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapObject authentication = new SoapObject(NAMESPACE, "authentication");
authentication.addProperty("LoginID", YOUR_LOGIN_ID);
authentication.addProperty("Password", YOUR_PASSWORD);
request.addProperty("authentication", authentication);
request.addProperty("Id", YOUR_ID);
request.addProperty("Str", YOUR_STR);
Upvotes: 1