SuperHich / ksoap2-android

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

Send and receive Array Byte with ksoap #116

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the product are you using? On what operating system?
Ksoap 2.5.4  Windows Seven

Please provide any additional information below.

How can i send an array of byte to a WS?
And waht have I to do when receive it?

Original issue reported on code.google.com by daume...@gmail.com on 20 Apr 2012 at 1:53

GoogleCodeExporter commented 9 years ago
I'm trying in this mode:

 String path = Environment.getExternalStorageDirectory().getAbsolutePath();
                       String FILE = "/PdfCheck1.pdf";
                       String pathCompleto = path+FILE;
                       Log.i("","Path completo : "+ pathCompleto);
                       byte[] filefirma = convertDocToByteArray(pathCompleto);
                       Intervento.addProperty("FileFirma",filefirma);

         SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                    new MarshalDouble().register(envelope);
                    new MarshalBase64().register(envelope);   //serialization
                    envelope.encodingStyle = SoapEnvelope.ENC;

                    envelope.bodyOut = request;
                   envelope.dotNet = true; 
                   envelope.setOutputSoapObject(request);
                   envelope.setAddAdornments(false);
                   envelope.implicitTypes= true;
//                 Log.i("Envelope","settata"); 

                   HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
                   androidHttpTransport.debug = true;
                   Log.i("","Prima di androidHttpTransport.call ");
                   androidHttpTransport.call(SOAP_ACTION, envelope);
                   Log.i("","" + androidHttpTransport.requestDump);
                   Log.i("","" + androidHttpTransport.responseDump);
                   Log.i("call","call");

                   SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse(); 
                  Log.i("SoapPrimitive","Result" + resultsRequestSOAP);
                  Log.i("GetAttribute","Count" + resultsRequestSOAP.getAttributeCount());

                  b = Boolean.parseBoolean(resultsRequestSOAP.toString());
                  Log.i("","risultato boolean Straordinario "+b);

public static byte[] convertDocToByteArray(String sourcePath) throws 
IOException {
          File f = new File(sourcePath);
          long l = f.length();
          byte [] buf = new byte[(int) l];
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
                try {
                      InputStream fis = new FileInputStream(sourcePath);

                      for (int readNum; (readNum = fis.read(buf)) != -1;) {
                          bos.write(buf, 0, readNum);
                          Log.i("","read num bytes: "+readNum);
                      }
               } catch (IOException e) {
                    System.out.println("IO Ex"+e);
                }
                byte[] bytes = bos.toByteArray();

//              for(int i = 0;i<bytes.length;i++)
//              {
//                  Log.i("","bytes : "+bytes[i]);
//              }

          }

And I send something like this:

<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><UpdateInterventi 
xmlns="http://tempuri.org/"><login>admin</login><password>admintechno</password>
<deviceId>99461300-C57D-0801-47FC-FC47020000000000000000000</deviceId><listaInte
rventi><Intervento><IdEvent>60</IdEvent><IdTypeEvent>4</IdTypeEvent><IdAutor>2</
IdAutor><IdPerson>8</IdPerson><IdContact>0</IdContact><IdResponsible>2</IdRespon
sible><IdCampaign>0</IdCampaign><IdFather>0</IdFather><IdNextAction>0</IdNextAct
ion><IdLastAction>0</IdLastAction><IdFatherRepeat>0</IdFatherRepeat><IdProject>0
</IdProject><CodeBusiness>mtechno</CodeBusiness><Status>1</Status><Private>false
</Private><CodeProduct></CodeProduct><StartDate>04/04/2012</StartDate><EndDate>0
4/04/2012</EndDate><StartTime>07:00</StartTime><EndTime>07:15</EndTime><Subject>
0</Subject><CreationDate>04/04/2012 
12.23.01</CreationDate><ToDo>true</ToDo><StatusToDo>0</StatusToDo><Enabled>true<
/Enabled><Deleted>false</Deleted><Title></Title><Location></Location><Descriptio
n></Description><Notes>test intervento straordinario per domenico - CENTRALE 
N2O</Notes><IdPriority>0</IdPriority><CodiceIntervento>08/04/2012</CodiceInterve
nto><ID>60</ID><Impianto_ID>7</Impianto_ID><ODM_ID>0</ODM_ID><KmPercorsi></KmPer
corsi><ODM_Codice></ODM_Codice><StatoIntervento>3</StatoIntervento><Tipo>1</Tipo
><IdComponenti><string>4491</string><string>4492</string><string>4493</string><s
tring>4494</string><string>4495</string><string>4496</string><string>4497</strin
g><string>4498</string><string>4499</string><string>4500</string><string>4501</s
tring><string>4502</string><string>4503</string><string>4504</string><string>450
5</string><string>4506</string><string>4507</string><string>4576</string><string
>4577</string></IdComponenti><IdRichiestaIntervento>0</IdRichiestaIntervento><De
scrizioneInterventoEseguito>intervento ore 17.03 del 
04/04/2012</DescrizioneInterventoEseguito><OreImpiegate>0.0</OreImpiegate><Impor
to>0.0</Importo><NomeFileFirma></NomeFileFirma><FileFirma>JVBERi0xLjQKJeLjz9MKMy
AwIG9iago8PC9GaWx0ZXIvRmxhdGVEZWNvZGUv
TGVuZ3RoIDgwMD4+c3RyZWFtCkiJrVZdb9owFH3Pr7gv0+gDNDbOF28Zoywb
JBTSapp4cSFFntKY5oNJ+/WzA2Uln9BWCEg4Occ+914f8aw8Kwj+KH0ddAvD
k6JpVn4VKgvlVryelS++RE1VB3+tIMPoqQS6KL+7vkEgrx6Vzny08Iae63sw
/DYa/rjyfysdkJ/dA0WVBKyZPUE40jEgnNPhFeHwUE5QK5YaTpyR648Gds/r
wYJGMGZZEmy3AUx5sqIpA3sXhCGLuJQrLqLWCzvTmWMLC/XKFwp+tX17gPRr
lVxjFeEL2d7cHqjWAFkX8nxn5g0WaUx5vGYRjRmvJpwteOc6vv0ZJt7YGdoD
GIrqz+3JCOxfnu+9Rfv/vaZfRGyTw/3L9M4wOfTw+yyaH173sb0Ax4WpsxiO
B3R6eZhgQOxpI4gwCN8YILdwBPzE8BffCc17cGdTxzLHYNl+uDBdG6ZmAI4P
nhNYtmuC6QK56091vdTP3fgTUTU0ieiXIHHiLDyTw8MaOAXZoTAXDqcPwxOj
TgVZ0uCDm6JrKmCC2JWZkidCUEN4pLM/R5EiS3obVrEh4V58zt1GwPUhUAzQ
eSP7pofHJE836SqGlJbJNk/LL0hgleV5UpYZF99ka4SzxU1FP9OMxvuEnmNY
T406eDTiajul/IyCXSTbKu1jqUw57qUlRVHRGGhWxk1BF0ItKqUFa+UcwjL/

I think filefirma isn't send in rigth mode,I think it would be a lot of 
number,what is wrong?Please help me

Original comment by daume...@gmail.com on 21 Apr 2012 at 9:37

GoogleCodeExporter commented 9 years ago
Looks fine to me .. can the server decode it? 

Original comment by mosa...@gmail.com on 24 Apr 2012 at 5:33

GoogleCodeExporter commented 9 years ago
I solved yesterday..The problem was the server,it can't decode.Thanks..

Original comment by daume...@gmail.com on 24 Apr 2012 at 7:17

GoogleCodeExporter commented 9 years ago

Original comment by mosa...@gmail.com on 24 Apr 2012 at 4:05

GoogleCodeExporter commented 9 years ago
I have the same problem,What did you do to resolve it?

Original comment by pauloski...@gmail.com on 20 Feb 2013 at 10:36

GoogleCodeExporter commented 9 years ago
Problem got fixed after using KSOAP 3.0.0 RC 4 . 

Original comment by rbhhere on 17 Apr 2013 at 12:23