Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16241] TiAPI: XML Response null when requesting binary attachment

GitHub Issuen/a
TypeBug
Priorityn/a
StatusReopened
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsTiAPI
Labelshttpclient, request, response, soap, xml, xmlparsing
ReporterBernhard Dengler
AssigneeUnknown
Created2013-06-28T13:17:19.000+0000
Updated2018-02-28T20:04:14.000+0000

Description

https://developer.appcelerator.com/question/152474/createhttpclient-soap-response-null-when-attachment-returned We tried it with SoapUI with the same request and the attachment is contained in the response, but as soon as we request it with Titanium, the (whole!!!) response is null. No header any more, nothing.

Attachments

FileDateSize
test.txt2014-01-08T08:04:23.000+000061382
XML Test.1.zip2014-01-04T23:15:57.000+00002895661

Comments

  1. Daniel Sefton 2013-07-01

    Hi Bernhard, Please can you provide a reproducible test case that we can drop into an app.js and run? Thanks!
  2. Bernhard Dengler 2013-07-05

    I attached a project "XML Test.zip" that does a live request. In ui/common/FirstView.js happens all the magic. There you also can change the type of ouput. The variable var responseType = "XML"; sets the response to XML var responseType = "PDF+XML"; should return a soap response, but returns null... Try it with SoapUI and you'll see it works with PDF there, so there has to be some issue with the Titanium parser...
  3. Bernhard Dengler 2013-07-08

    Did you try the example? Which results did you experience?
  4. Mostafizur Rahman 2013-09-18

    Hello Bernhard Dengler, I test your code. It is showing an error. Please can you check your username and password?
       [INFO] :   <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>UVST service error</faultstring><detail><UvstFault xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns="http://uvst.at/sws/typen"><faultCode>UVST-5007</faultCode><faultMessage>Benutzername oder Passwort falsch.</faultMessage><faultDetail xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/></UvstFault></detail></soap:Fault></soap:Body></soap:Envelope>
       
       
    Thanks
  5. Bernhard Dengler 2013-09-19

    Please replace "FirstView.js" with the one I attached above. We deleted the user that was configured there because no activity happened. We now configured a new user...please try again.
  6. Mostafizur Rahman 2013-09-19

    Hello, I test your new code. its return following data:-
       --uuid:3402beb6-ba03-4c72-b4e1-47756c470e2f
         Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
        Content-Transfer-Encoding: binary
        Content-ID: <root.message@cxf.apache.org>
         
        <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GdbAbfrageResponse xmlns="http://uvst.at/sws/typen" xmlns:xmime="http://www.w3.org/2005/05/xmlmime"><ErgebnisZeitpunkt>2013-09-19T19:23:59+02:00</ErgebnisZeitpunkt><TransactionId>tid://20130919.20130939232357.00030031.GB@imd.at</TransactionId><ErgebnisArt><Gdb><XmlStream xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:base64Binary"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1eb84673-216d-47ab-b8c5-1c295d6c6bee-325@uvst.at"/></XmlStream><Aktualitaet><Historisch>true</Historisch><Text>Diese Abfrage wurde, mit den selben Abfrageparametern, innerhalb der letzten 15 Minuten bereits durchgeführt.</Text></Aktualitaet></Gdb></ErgebnisArt></GdbAbfrageResponse></soap:Body></soap:Envelope>   --uuid:3402beb6-ba03-4c72-b4e1-47756c470e2f
         Content-Type: application/xml; charset=UTF-8
         Content-Transfer-Encoding: binary
         Content-ID: <1eb84673-216d-47ab-b8c5-1c295d6c6bee-325@uvst.at>
         
       <?xml version="1.0" encoding="UTF-8"?><ns3:GBAuszugAntwort xmlns:ns3="ns://erv.justiz.gv.at/gb/types" xmlns:ns2="ns://erv.justiz.gv.at/gb/AbgTags"><ns2:Datenvorhanden>0</ns2:Datenvorhanden><ns2:Abfragezeit>2013-09-19T19:23:59.264+02:00</ns2:Abfragezeit><ns3:GBAuszug><ns3:VollstaendigerAuszug>false</ns3:VollstaendigerAuszug><ns3:Kopf><ns3:Bezirksgericht>40</ns3:Bezirksgericht><ns3:Einlage><Katastralgemeinde><Katastralgemeindenummer>04021</Katastralgemeindenummer><Katastralgemeindebezeichnung>Möllersdorf</Katastralgemeindebezeichnung></Katastralgemeinde><Einlagezahl>457</Einlagezahl></ns3:Einlage></ns3:Kopf><ns3:Aufschrift><ns3:LetzteTZ><LNR>7244</LNR><Jahr>2011</Jahr></ns3:LetzteTZ><ns3:Aufschrifttextliste><ns3:Aufschrifttext>Letzte TZ 7244/2011</ns3:Aufschrifttext><ns3:Aufschrifttext>Einlage umgeschrieben gemäß Verordnung BGBl. II, 143/2012 am 07.05.2012</ns3:Aufschrifttext></ns3:Aufschrifttextliste></ns3:Aufschrift><ns3:BlattA1><ns3:Grundstuecksliste><ns3:Grundstueck><ns3:Katastralgemeinde><Katastralgemeindenummer>04021</Katastralgemeindenummer><Katastralgemeindebezeichnung>Möllersdorf</Katastralgemeindebezeichnung></ns3:Katastralgemeinde><ns3:Grundstuecksnummer><Stammnummer>1024</Stammnummer></ns3:Grundstuecksnummer><ns3:Grenzkataster>true</ns3:Grenzkataster><ns3:Nutzungsliste><ns3:Nutzen><ns3:Nutzungsart>Bauflächen (Gebäude)</ns3:Nutzungsart><ns3:Teilflaeche>3153</ns3:Teilflaeche></ns3:Nutzen><ns3:Nutzen><ns3:Nutzungsart>Sonstige (Betriebsflächen)</ns3:Nutzungsart><ns3:Teilflaeche>5163</ns3:Teilflaeche></ns3:Nutzen></ns3:Nutzungsliste><ns3:Flaechenermittlung>*</ns3:Flaechenermittlung><ns3:Flaeche>8316</ns3:Flaeche><ns3:Adressliste><ns3:Adresse><Strasse>Wiener Straße</Strasse><Hausnummer>105-107</Hausnummer></ns3:Adresse><ns3:Adresse><Strasse>Marzek-Straße</Strasse><Hausnummer>2</Hausnummer></ns3:Adresse></ns3:Adressliste></ns3:Grundstueck></ns3:Grundstuecksliste><ns3:Gesamtflaeche>8316</ns3:Gesamtflaeche></ns3:BlattA1></ns3:GBAuszug><ns3:Produkt><ProduktID>GT_GBA03</ProduktID><Preis>1.6</Preis></ns3:Produkt></ns3:GBAuszugAntwort>
         --uuid:3402beb6-ba03-4c72-b4e1-47756c470e2f--
       
    I think that is your desired response’s text. Thanks
  7. Bernhard Dengler 2013-09-19

    Hi, NO! Please read the initial postings: if you set the variable var responseType = "PDF+XML" in the FirstView.js (it's now set to "XML"), then the response is "NULL". BUT if you do the same request with e.g. SoapUI, there is a full response including the PDF. So as soon as the response includes binary data, the Titanium parser returns "NULL"... So I tried it with 3.1.3 now and it's still NOT working
  8. Bernhard Dengler 2013-10-07

    Any news on this?
  9. Bernhard Dengler 2014-01-04

    This one ISN'T resolved! Please give some feedback about your results, I'm still getting "null" when I request "PDF+XML"...and don't forget to replace the FirstView.js as mentioned above. Tried it with 3.2.0 now...
  10. Shak Hossain 2014-01-04

    Hi Bernhard, We tested this issue with your code. However, we were unable to complete the test due to server error. Here is server response logs: 1 [INFO] : http://schemas.xmlsoap.org/soap/envelope/">soap:ServerUVST service errorhttp://www.w3.org/2005/05/xmlmime" xmlns="http://uvst.at/sws/typen">UVST-5005Die TransactionId entspricht nicht der Struktur: tid://JJJJMMTT.freier_teil.anschriftcode.anwendungskennung@domain-name.http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> Can you please send us a detailed test case and server test access to review this further? Regards,
  11. Bernhard Dengler 2014-01-04

    The actual test project
  12. Bernhard Dengler 2014-01-04

    Hi Shak, I updated the whole project and tested it again with 3.2.0, it works here. See the attached file above (I removed the old ones). The error message you posted above says that the transaction ID (which is based on the actual date and time) is in wrong format. These both lines are responsible: [...] ''+AbfrageDate1+''+ ' tid://'+AbfrageDate2+'.'+AbfrageKennung+'.00030031.GB@imd.at'+ [...] The variable "AbfrageDate2" should be in format "YYYYMMDD" and the variable "AbfrageKennung" should be in format "YYYYMMDDhhmmss"+20000000 If your locale settings are wrong or anything else, you have to hardcode these values. But they have to be actual, otherwise the request will be unsuccessful.
  13. Bernhard Dengler 2014-01-04

    ...and don't forget to do the request in both ways: var responseType = "XML"; and var responseType = "PDF+XML"; The first line: response -> OK The second line: response -> null
  14. Bernhard Dengler 2014-01-06

    When are you planning to do the next tests? We really need this asap... As mentioned: the testfiles work, but the response is still NULL if it contains binary data. Otherwise it's working fine...
  15. Bernhard Dengler 2014-01-07

    I found out something: the response is contained in the "responseData" Object! But it contains non-ASCII characters so you can't do anything with it. It's just there (as blob). But every function like .toString or .text returns no value (because of the non-ASCII characters).
  16. Ritu Agrawal 2014-01-08

    This is a pdf attachment so I am assuming you are expecting the binary data back. You should be able to read the blob object content using Blob object API. http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Blob
  17. Bernhard Dengler 2014-01-08

    Hi, no, it's no pure PDF, it's header says "XOP+XML". I've tried working with the Ti.Blob Object, but there's no possibility to read the file or separate the attachments out of it, I just can save it to the device. I'll attach the file that comes in the response...you can try yourself working with it and the Ti.Blob Object.
  18. Bernhard Dengler 2014-01-08

    See attachment "test.txt"... This is the response that comes through the responseData object from the httpClient request. Save it to the application folder on the device and try reading it with this code: var fileStream = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,"test.txt"); var fileContent = fileStream.read(); Ti.API.info("Response: " + fileContent.toString()); OR Ti.API.info("Response: " + fileContent.text()); OR Ti.API.info("Response: " + fileContent.file()); OR Ti.API.info("Response: " + fileContent.mimeType()); The last one returns the type of the file. As soon as I'm cropping the PDF part manually out of the file, I can read the file. What I'd like to do: I'd like to read everything as a string, separate the header & attachments and save them seaparetly to the device.
  19. Ritu Agrawal 2014-01-19

    Moving this to engineering for further evaluation and prioritization.
  20. Bernhard Dengler 2014-04-06

    Any news on this?

JSON Source