xseguib / ksoap2-android

Automatically exported from code.google.com/p/ksoap2-android
0 stars 0 forks source link

implicitTypes ignored when adding Vectors to SOAP request. #75

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

create a client using dotNet = true, setAdornments(false), and implicitTypes = 
true.  then try to send a vector(i'm using string) to a .net webservice

What is the expected output? What do you see instead?
I expect tags like 
<ListArray><list>1</list><list>2</list><list>3</list></ListArray>

i get

<ListArray c:arrayType="c:Array[1]"><list i:type="d:string">2</list></ListArray>

the c:array type and other stuff is causing problems.. in the same request i'm 
using basic types (also doing it in multiple other requests) and the xml comes 
out clean <contactName>bob</contactName>  in the same envelope.

What version of the product are you using? On what operating system?
i'm using kSoap2 2.5.7  eclipse helios, android sdk12 targeting android 2.1, on 
windows 7 64 bit.  and java 6 i think.

Please provide any additional information below.

It seems this problem has been noticed as there is a comment in the 
writeVectorBody method in the SoapSerializationEnvelope.java file under 
ksoap2-android / ksoap2-base / src / main / java / org / ksoap2 / serialization 
/.   For some reason i havent yet been able to build a copy of the source code 
from github, if a check was added to simply not add the c:arrayType or i:Type 
bits to the xml when implicitTypes = true, like the way the primitive or non 
array types are written, i think it would solve this issue and i'd be greatly 
appreciative.  If i have the time to spend on it i'll try to get the code 
building and submit a fix, but i dont know if i'll be able to.

Original issue reported on code.google.com by jwLindem...@gmail.com on 1 Aug 2011 at 1:43

GoogleCodeExporter commented 8 years ago
To build the code you just have to run

mvn clean install 

in the root of the project. A patch would be great.. 

Original comment by mosa...@gmail.com on 2 Aug 2011 at 5:59

GoogleCodeExporter commented 8 years ago
I've managed to fix the main issue of the c:arrayType="c:Array[1]" attribute, 
but i cant seem to get rid of the i:type="d:string" attribute.  but since its 
not actually breaking anything the only reason i can see to remove it is so the 
xml looks clean and all the tags are formatted the same way when implicitTypes 
is true.  I have a couple more functions to test with before I send the file 
over.  I should be done in the next few days.   Thanks for your help.

Original comment by jwLindem...@gmail.com on 2 Aug 2011 at 2:29

GoogleCodeExporter commented 8 years ago
Great. Send it as a patch file or as pull request on github. Whatever you 
prefer? Ideally with some tests and also you contact details for the license 
file. 

Original comment by mosa...@gmail.com on 2 Aug 2011 at 5:19

GoogleCodeExporter commented 8 years ago

Original comment by mosa...@gmail.com on 2 Aug 2011 at 5:19

GoogleCodeExporter commented 8 years ago
https://github.com/mosabua/ksoap2-android/pull/8 should fix this and will be 
released with 2.5.8 coming up, please test from the github master branch and 
confirm

Original comment by mosa...@gmail.com on 23 Aug 2011 at 5:07

GoogleCodeExporter commented 8 years ago
I deleted my local copy of files and got a fresh copy from github, everything 
seems to be working correctly.

Original comment by jwLindem...@gmail.com on 25 Aug 2011 at 1:18

GoogleCodeExporter commented 8 years ago

Original comment by mosa...@gmail.com on 26 Aug 2011 at 5:34

GoogleCodeExporter commented 8 years ago
I have a similar problem (with ver. 2.6.4). I must send an array of custom 
objects to a .NET 4.0 WebService and the less verbose SOAP envelope I succeeded 
to get is the following:

<v:Envelope xmlns:i="http://www.w3.org/1999/XMLSchema-instance" 
xmlns:d="http://www.w3.org/1999/XMLSchema" 
xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
   <v:Header/>
   <v:Body>
      <SetDeliveries xmlns="http://tempuri.org/">
         <n0:deliveries i:type="c:Array" xmlns:n0="http://tempuri.org/">
            <n1:InputDeliveryInfo xmlns:n1="http://schemas.datacontract.org/2004/07/onPostServer">
               <n1:Code>AD00001</n1:Code>
               <n1:DeliveryDate>2012-05-23T11:29:17.904Z</n1:DeliveryDate>
               <n1:Latitude>0.0</n1:Latitude>
               <n1:Longitude>0.0</n1:Longitude>
               <n1:Recipient>serf</n1:Recipient>
               <n1:Status>0</n1:Status>
            </n1:InputDeliveryInfo>
            <n2:InputDeliveryInfo xmlns:n2="http://schemas.datacontract.org/2004/07/onPostServer">
               <n2:Code>AD00002</n2:Code>
               <n2:DeliveryDate>2012-05-23T07:12:48.678Z</n2:DeliveryDate>
               <n2:Latitude>0.0</n2:Latitude>
               <n2:Longitude>0.0</n2:Longitude>
               <n2:Recipient>giivanni</n2:Recipient>
               <n2:Status>0</n2:Status>
            </n7:InputDeliveryInfo>
         </n0:deliveries>
      </SetDeliveries>
   </v:Body>
</v:Envelope>

The namespace declaration is added to every item of the array (useless and too 
verbose). The only way I have to make the server accept the data is to use 
VER10 otherwise I get a parsing error because KSOAP2 does not remove the 
attribute i:type="c:Array" in <deliveries>. The java code that produces the 
SOAP envelope above is the following:

SoapObject request = new SoapObject(wsai.getNamespace(), 
WSAccessInfo.methodSendDeliveries);

HttpTransportSE androidHttpTransport = new HttpTransportSE(wsai.getURL());
androidHttpTransport.debug = true;
MarshalDate mdate = new MarshalDate();
MarshalFloat mfloat = new MarshalFloat();

PropertyInfo pInfo = new PropertyInfo();
pInfo.setName("deliveries");
pInfo.setValue(listDeliveriesWSO);
pInfo.setNamespace(wsai.getNamespace());
pInfo.setType(Object.class);
pInfo.elementType = new PropertyInfo();
pInfo.elementType.type = DeliveryInfoWSO.class;
pInfo.elementType.name = "InputDeliveryInfo";
pInfo.elementType.namespace = 
"http://schemas.datacontract.org/2004/07/onPostServer";
request.addProperty(pInfo);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope 
SoapEnvelope.VER10);/*If I set VER12 I get an exception (strange behavior). If 
I set VER11 the sttibute i:type causes the server to return an unknown type 
error (and it is right...ksoap2 is faulty)*/

mdate.register(envelope);
mfloat.register(envelope);

envelope.avoidExceptionForUnknownProperty = true;
envelope.dotNet = true;
envelope.implicitTypes = true;
envelope.setAddAdornments(false);

envelope.setOutputSoapObject(request);

envelope.addMapping(wsai.getNamespace(),
wsai.getMethosReturnTypeName(WSAccessInfo.methodSendDeliveries),
                    new DeliveryInfoWSO().getClass());

androidHttpTransport.call(wsai.getAction(WSAccessInfo.methodSendDeliveries), 
envelope);

ksoap2 should produce as less verbose XML as possible instead it generates and 
adds useless and verbose attributes and namespaces. For a mobile device with 
limited resources that is not exactly waht we would like to get

Original comment by sergio.b...@gmail.com on 23 May 2012 at 3:07

GoogleCodeExporter commented 8 years ago
Please do not comment on closed issues but rather create a new one. Also if you 
want to improvements making the requeste lighter feel free to do so and send a 
pull request on github.

Original comment by mosa...@gmail.com on 23 May 2012 at 6:57

GoogleCodeExporter commented 8 years ago
Sorry, but I'm not commenting a closed issue...it is very open indeed. In fact 
I have the last version of ksoap2 and the problem is still present.

Original comment by sergio.b...@gmail.com on 24 May 2012 at 7:26

GoogleCodeExporter commented 8 years ago
This issue is verified/closed... it was closed in August last year. Please 
create a new one and maybe link to this one.. 

Original comment by mosa...@gmail.com on 24 May 2012 at 4:08