Quantcast
Channel: SCN : Popular Discussions - SAP Cloud Applications Studio
Viewing all articles
Browse latest Browse all 1333

Storing PDF-File from Webservice-Result as Attachment

$
0
0

Dear communinty,

 

I invoked a REST web service call to get a PDF file from a server. The web service call itself works fine and I get a response.

Now I want to store this PDF file in an attachment folder of the Outbound Delivery. Getting the attachment folder, creating the file and all that stuff works fine as well.

But when I try to get the PDF file from ws_result and put it into the BinaryObject part of the file in the attachment folder, it seems that something breaks in the Cloud Studio.

For some reason I only get a blank PDF file.

 

Here's my coding:

 

var ScenarioName = "Scenario";

var ServiceName = "Service";

var HttpMethod = "GET";

var HttpResource = "";

var ContentType = "application/pdf";

var Body = "";

var HeaderParameter : collectionof NameAndValue;

var URLParameter : collectionof NameAndValue;

var URLParameterEntry : NameAndValue;

  1. URLParameterEntry.Name = "code";
  2. URLParameterEntry.Value = code;
  3. URLParameter.Add(URLParameterEntry);

 

var ws_result = WebServiceUtilities.ExecuteRESTService(ScenarioName, ServiceName, HttpMethod, HttpResource, URLParameter, HeaderParameter, ContentType, Body);

 

var attachmentFolder = this.ToRoot.AttachmentFolder;

if (attachmentFolder.IsSet())

{

var stdDoc : DocumentTypeCode;

stdDoc.content = "10001";

 

var binObj : BinaryObject;

binObj.mimeCode = "application/pdf";

binObj.content = Binary.ParseFromString(ws_result.Content); //ParseFromBase64String(ws_result.Content);

 

var desc : Description;

desc.content = "Label";

 

attachmentFolder.CreateFile(stdDoc, "Label.pdf", "label_to_print", desc, binObj);

}

 

I also tried Binary.ParseFromBase64String(ws_result.Content) instead ot ParseFromString, resulting in a file that can't be read at all. With ParseFromString at least the PDF file can be read, but since it's empty, I cannot make any use of it.

Also I checked the URL and the WebServer. The URL I'm using for the web service call works fine and it'll return the correct label as PDF in the browser as well as in SOAP UI.

Also I receive some content in the Cloud Studio, it just seems that either this content is already corrupted, or putting it into the binary object does some harm to it.

 

Is there anything I'm missing or doing wrong here?

Any help would be really appreciated.

 

 

Thanks a lot in advance,

Christine

 

PS: Just in case you wanna have a look at the URL or the PDF, or maybe even want to try it on your own, here's the URL I'm using: http://test-intraship2.dhl.com:80/cartridge.61_TZA/WSPrint?code=22B2158E295CC514791E78FB4E938A4A0BCF27D711096DBF. Since this is a test label, it may be invalidated in the next couple days.


Viewing all articles
Browse latest Browse all 1333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>