Skip to main content

Hello FME-community. 


I'm having trouble downloading data with the HttpCaller to a zip file. 


1. First I upload text/xml below with a file key to say which file I want to download. See image . 

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetOrder xmlns="http://Vagverket.VIS.Lastkajen.LastkajenLogistics">
      <orderKey>@Value(FileKey)</orderKey>
    </GetOrder>
  </soap:Body>
</soap:Envelope>

2. I then receive (according to the data download specification) a download stream in base64Binary, see example below. 

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetOrderResponse xmlns="http://Vagverket.VIS.Lastkajen.LastkajenLogistics">
      <GetOrderResult>base64Binary</GetOrderResult>
    </GetOrderResponse>
  </soap:Body>
</soap:Envelope>

3. I use the XMLFlattener to filter out GetOrderResult, BUT I can't seem to get the download stream into a proper functional zip file. I have tried numerous ways (writing to a file directly from the httpcaller, using the datafile-writer and the attributewriter but I just can't make it work). 

GetOrderResult (base64Binary) follows. This data contains, if I'm correct, a zip file containing a shape file TESTNVDB_DKC_Cykelled.shp (the file contains zero objects), a dbf file TESTNVDB_DKC_Cykelled_domainmap.dbf and a text file.

UEsDBBQAAAAIAG+HuUiDBir8bQAAACIBAAAZACQAVEVTVE5WREJfREtDX0N5a2VsbGVkLmRiZgoAIAAAAAAAAQAYAMlbqgqWttEBNsrpEJa20QE2yukQlrbRAWMuYZVkAAJFxhUMGCCcgcHP0dcPynMGEUZoSgKCPH0d/cJATLA6FjT5IB9PF2T9amjywSGOQSGOYcEhDAxuIL4wN5q8TyhUGoe8h2OAa7yPqx8OebcgR794F8eQUF+I+zjR7A/x9PHBJ88rBQBQSwMEFAA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uc2h4CgAgAAAAAAABABgAJ76sCpa20QFvLOwQlrbRAW8s7BCWttEBUEsBAi0AFAAAAAgAcYe5SOQ87tnTAAAAuhAAACMAJAAAAAAAAAAgAAAADwMAAFRFU1ROVkRCX0RLQ19DeWtlbGxlZF9kb21haW5tYXAuZGJmCgAgAAAAAAABABgAg1KGDZa20QFvLOwQlrbRAW8s7BCWttEBUEsBAi0AFAAAAAgAcYe5SLFHyhX1AAAAqQEAACYAJAAAAAAAAAAgAAAARwQAAFRFU1ROVkRCX0RLQ19DeWtlbGxlZF9maWVsZGFsaWFzZXMudHh0CgAgAAAAAAABABgAx42BDZa20QFvLOwQlrbRAW8s7BCWttEBUEsFBgAAAAAGAAYAmQIAAKQFAAAAAA==

Any suggestions helping me out here are welcome. 

Kind regards, 
Peter

Hi @peteralstorp, did you try saving the response into a file by the HTTPCaller with setting File to the 'Save Response Body To' parameter?


Hi @peteralstorp, did you try saving the response into a file by the HTTPCaller with setting File to the 'Save Response Body To' parameter?

Thanks, takashi. Yes I did. I figure it must be a character encoding problem or maybe I need to understand the zip format better.


Thanks, takashi. Yes I did. I figure it must be a character encoding problem or maybe I need to understand the zip format better.

I think you can read the zip file with a FeatureReader following to the HTTPCaller, once you have saved it into the disk. Have you tried this?


I think you can read the zip file with a FeatureReader following to the HTTPCaller, once you have saved it into the disk. Have you tried this?

I think the zip file is the problem. I tried your suggestion (although I need to pass an xml-transformer to get rid of some xml-code. See image. takashi.png. The featurereader will not accept the zipfile.


I think the zip file is the problem. I tried your suggestion (although I need to pass an xml-transformer to get rid of some xml-code. See image. takashi.png. The featurereader will not accept the zipfile.

How about setting fme-binary to the 'Target File Character Encoding' parameter of the AttributeFileWriter?


I think the zip file is the problem. I tried your suggestion (although I need to pass an xml-transformer to get rid of some xml-code. See image. takashi.png. The featurereader will not accept the zipfile.

Tried it but no. The zip file can't be read properly. Error msg: Error status STK_FAILURE pending -- message is: Error while processing folders


I think the zip file is the problem. I tried your suggestion (although I need to pass an xml-transformer to get rid of some xml-code. See image. takashi.png. The featurereader will not accept the zipfile.

Well, the TextDecoder might help you to decode the Base64 string to an fme-binary string before writing.

  • Encoding Type: Base64

  • Character Encoding for Binary Data: Binary (fme-binary)

I think you can read the zip file with a FeatureReader following to the HTTPCaller, once you have saved it into the disk. Have you tried this?

Hm, still no readable zip file. Thanks for your efforts so far, Takashi!


Thanks, takashi. Yes I did. I figure it must be a character encoding problem or maybe I need to understand the zip format better.

I was able to read your sample Base64 string as a zipped Shepfile dataset. See the attachment: base64-to-fme-binary.fmw (FME 2016.1)


I was able to read your sample Base64 string as a zipped Shepfile dataset. See the attachment: base64-to-fme-binary.fmw (FME 2016.1)

Takashi, you are the king! Thank you kindly. I can't yet see what you did different than me, but there must be something!


Reply