[TIMOB-16241] TiAPI: XML Response null when requesting binary attachment
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Reopened |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | TiAPI |
Labels | httpclient, request, response, soap, xml, xmlparsing |
Reporter | Bernhard Dengler |
Assignee | Unknown |
Created | 2013-06-28T13:17:19.000+0000 |
Updated | 2018-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
File | Date | Size |
---|---|---|
test.txt | 2014-01-08T08:04:23.000+0000 | 61382 |
XML Test.1.zip | 2014-01-04T23:15:57.000+0000 | 2895661 |
Hi Bernhard, Please can you provide a reproducible test case that we can drop into an app.js and run? Thanks!
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...
Did you try the example? Which results did you experience?
Hello Bernhard Dengler, I test your code. It is showing an error. Please can you check your username and password?
Thanks
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.
Hello, I test your new code. its return following data:-
I think that is your desired response’s text. Thanks
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
Any news on this?
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...
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] :
The actual test project
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: [...] '
...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
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...
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).
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
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.
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.
Moving this to engineering for further evaluation and prioritization.
Any news on this?