SoapObject Result returns anyType {} as value when migrating complexType

I call the web service in my Android application and the getGramaNiladhariData () method, I get the result as a SoapObject.

result = (SoapObject) envelope.bodyIn; Log.d("WS", String.valueOf(result)); 

And this is what I got for String.valueOf (result)

getGramaNiladhariDataResponse {getGramaNiladhariDataResult = anyType {gnName = anyType {}; address = anyType {}; = anyType Workers {}; gnDivision = anyType {}; contactNumber = anyType {}; }; }

Here the method that I call returns a complexType object consisting of 5 attributes. As I found on the Internet, I cannot get a soap object as a result of the webservice method, which returns a complexType object. If so, how do I get the values.

I want to decide why I get anyType {} as a value, instead of a real value. Any help would be appreciated

+4
source share
3 answers

Too late to answer. but FYI and others who find this useful,

By executing String.valueOf(result) , you print the entire contents of the body. but in order to get your values ​​using parameters, first of all you need to click to fix SoapObject .

I don't know if there is any easy way to find the correct SoapObject , but still this method does the trick, and as soon as you get the correct SoapObject , then you are done. find below how to find the correct SoapObject ,

First you need to check the number of parameters in your first SoapObject ,

 result.getPropertyCount(); 

you will receive less quantity for this, as this is the very first cover,

then print and see which parameter gives you corect data,

 result.getProperty(0); result.getProperty(1); etc ... 

Once you find the right parameter, take SoapObject . eg,

 SoapObject result2 = (SoapObject) result.getProperty(0); 

then check the amount of this object. and do the same as above until you get the correct SoapObject .

After you find the latest SoapObject , it will print as follows without useless lines,

 anyType{gnName = Prasad; address = Address of the person; ; workingDays = 5; gnDivision = California; contactNumber = 0123456789} 

Now you can continue this object as follows:

 SoapObject result3 = (SoapObject) result2.getProperty(5); Log.v("Name : ", result3.getProperty("gnName").toString()); 

And you will get the result in DDMS as below,

 Name : Prasad 

I think this will help you, let me know if you have any additional problems.

+5
source

anytype {} appears when you get a null value from a web service. Enter some data first, and then try to retrieve the data from the web service.

0
source

I had this problem before. And I decided that. I used to have this problem. And I decided that. I seemed to spend a lot of time finding a solution to this problem. My project is working. I am creating a .Net Object Array web service. Hope this helps you.

  //................................. SoapObject requestx = new SoapObject(NAMESPACE, METHOD_NAME); SoapSerializationEnvelope envelopex = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelopex.dotNet = true; envelopex.setOutputSoapObject(requestx); HttpTransportSE httpTransportx = new HttpTransportSE(URL); try { httpTransportx.call(SOAP_ACTION, envelopex); SoapObject responsex = (SoapObject)envelopex.getResponse(); // not envelopex.bodyIn; int i=0; int RCount=responsex.getPropertyCount(); int[] tbIDArray = new int[RCount+1]; int[] iMonthAarray = new int[RCount+1]; int[] iYearAarray = new int[RCount+1]; String[] sDetailAarray = new String[RCount+1]; for (i = 0; i < RCount; i++) { Object property = responsex.getProperty(i); if (property instanceof SoapObject) { SoapObject info = (SoapObject) property; String tbID = info.getProperty("tbID").toString(); String iMonth = info.getProperty("iMonth").toString(); String iYear = info.getProperty("iYear").toString(); String sDetail = info.getProperty("sDetail").toString(); tbIDArray[i] =Integer.valueOf(tbID); iMonthAarray[i] =Integer.valueOf(iMonth); iYearAarray[i] =Integer.valueOf(iYear); sDetailAarray[i] =sDetail; }//if (property instanceof SoapObject) { }//for (i = 0; i < RCount; i++) { } catch (Exception exception) { MsgBox1(exception.toString() , "Error"); } 
-1
source

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


All Articles