Ksoap2 non-Primitives attribs in Complex Objects arrive NULL

708 views
Skip to first unread message

Hugo Cunha

unread,
May 5, 2011, 7:21:16 PM5/5/11
to ksoap2-android
Hello dears,

I'm sorry for the poor English but I'm a beginner brazillian in
english.

I have a web service JAX-WS and I have an android application in
android 2.2 api 8.

In my application I have already communicated my application with my
server passing 2 or more parameters (int, String, etc) for a
webmethod. I had several difficulties because the server always got
the parameters with null values, but I have already solved this
problem putting the annotation "@webparam(name= "param_name")" in the
parameters of my web methods. That problem ocurred because the server
parser was searching in the Soap Request Xml parameters like "arg0,
arg1, etc" - so when I put that annotation everything was alright.

And NOW I have another problem... I need send a complex object as
parameter. Something like a "TesteDTO" class. That class has 2
attributes:

++ int Id;
++ String Name;
++ Float Grade;

But the problem is that when I send the TesteDTO, in my server I have
the int attribute with the value which I have passed, BUT the String
and Float attributes, always arrive NULL.

What I do not understand is: If I send all these parameters separated
like:

public int method (@webparam(name="Id") int Id, @webparam(name="Name")
String Name, @webparam(name="Grade") float Grade) --> the data comes
alright, BUT

If I send these parameters inside a complex object like:

public int method (@webparam(name="testeDTO") TesteDTO testeDTO) -->
the String and Float values arrive at server NULL.

Please help me....

I have already used ksoap 2.4, ksoap 2.5.2, ksoap 2.5.4 and
nothing...... I have already tried using Marshal, but I don't know if
I used correctly...

Thank you for the attention.

Regards Hugo Cunha.

Manfred Moser

unread,
May 6, 2011, 2:14:44 PM5/6/11
to ksoap2-...@googlegroups.com

What does the ksoap code look like? Have looked at the request dump as docuented on the wiki?

Hugo Cunha

unread,
May 7, 2011, 3:27:32 PM5/7/11
to ksoap2-...@googlegroups.com
I made a class which extends HttpTransportSE and I could print the ksoap xml in the logcat, and it's below:
===================================
<?xml version="1.0" encoding="UTF-8"?>
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
   <n0:testeWs id="o0" c:root="1" xmlns:n0="http://idw/idwws">
      <testeDTO i:type="n0:TesteDTO">
         <resultadoEvento i:type="d:int">13</resultadoEvento>
         <Nome i:type="d:string">Hugo</Nome>
         <Nota i:type="d:float">2.0</Nota>
      </testeDTO>
   </n0:testeWs>
</v:Body>
</v:Envelope>
=========================================
But the only variable that arrives at server is the "resultadoEvento" which is "int" and the other variables like "Nome" (String) and "Nota" (float) arrive "null" and "0.0" respectively.....

I don't know why this happens and I have already tried everything....

Thanks for your help Sir Manfred

Regards, Hugo Cunha

2011/5/6 Manfred Moser <mos...@gmail.com>



--
Hugo Assis Cunha
7º período de Ciência da Computação - UFAM
Grupo PET - Computação
Laboratório de Computação Móvel e Ubíqua
hugo.ass...@gmail.com

Manfred Moser

unread,
May 9, 2011, 12:23:40 AM5/9/11
to ksoap2-...@googlegroups.com
Your server might be case sensitive when parsing the xml or have trouble with the data types. You will have to debug this on the server.. 

manfred

Hugo Cunha

unread,
May 10, 2011, 11:28:44 AM5/10/11
to ksoap2-...@googlegroups.com
Yep, but when I put to debug it on the server, I just can debug from
the moment which the Webmethod is called......

Do you know how can I debug the server's xml parsing????

Where can I see the xml that arrives to server and where can I see the
class which parse the xml coming, to know what is wrong in the
server's parser????

Or where can I change my server settings for not to be case sensitive
or something like that????

Because when I call the method with 3 String parameters, for example,
the data comes to server normally.... but when I put these variables
in a complex object, the String data comes all null, just the int data
comes with the value set....... WEIRD.......

Thanks for help....

Regards, Hugo Cunha

2011/5/9, Manfred Moser <mos...@gmail.com>:

Manfred Moser

unread,
May 10, 2011, 12:25:26 PM5/10/11
to ksoap2-...@googlegroups.com
No since I dont know what server you are using. Sorry .. you are going to have to ask in whatever forum is available for the server side app or framework you are using.

Hugo Cunha

unread,
May 19, 2011, 11:01:13 AM5/19/11
to ksoap2-...@googlegroups.com
Hello Manfred, thanks for your help. But I have researched about the problem, how to debug the xml parsing on server, but no success....

My server is a JAX-WS 2.2 web service in my work's computer and I'm using the ksoap 2.4 full dependencies (I've already tested the 1.5, 1.7, 2.1, 2.5 versions of ksoap, and nothing).

I don't know if you remember but my client app can send several attributes (int, float, string) as parameters, but when I put all these in a single class, only int attribute arrives at server with no NULL nor "0" (zero) value.....

Do you know how to check the xml parsing in a Jax-ws 2.2 application???

Just about information, I'm pragramming in the Android 2.2 Galaxy Tab....

Thank you,
Regards, Hugo.


2011/5/10 Manfred Moser <mos...@gmail.com>

Reuel Jose

unread,
May 25, 2011, 3:47:02 AM5/25/11
to ksoap2-...@googlegroups.com
try to research about marshaling.

Hugo Cunha

unread,
Jun 7, 2011, 3:11:38 PM6/7/11
to ksoap2-...@googlegroups.com
I have solved my problem, everything was right, but the client was sending upcase objects like "Name, Grade", and I changed the letters to lowcase letter like "name, grade", the communication worked fine. Even I put the client objects in lowcase and the server objects in upcase, the communication works too..

Great but desperately, because I had almost 1 month of stopped project because the letters were upcase...

=/

But, thank you all very much for the help.

Regards, Hugo.

2011/5/25 Reuel Jose <reuel...@gmail.com>

Manfred Moser

unread,
Jun 7, 2011, 5:13:32 PM6/7/11
to ksoap2-...@googlegroups.com
Great you found the problem at least ;-)
Reply all
Reply to author
Forward
Message has been deleted
0 new messages