
By default, the browser handles the response based on the content type set in HTTP headers.In this case, it is recommended to forcedly set the MIME type to be binary type: The method getMimeType() returns null if there is no MIME mapping for the specified file.For example, Tomcat declares MIME mapping under section “Default MIME Types Mapping” in this file: The mapping of MIME types is declared by the servlet container.Close both the FileInputStream and OutputStream.Repeat until no bytes available to read (end of file). Read arrays of bytes from the FileInputStream, then write them into the OutputStream.Obtains the OutputStream object of the response.Set content length of the response by invoking the setContentLength(int) method.That tells the browser what kind of the response is.


Import .api.StreamTransformationException

Java mapping is added for response message.īelow is the screenshot of Request and Response tested from SOAP UI.Īs you can see from the field sampleurltodownloadfile, we are retrieving download url to download pdf document.īelow is the Java Code that I have used to do this: Response : Download URL is returned as a response. Request : Request is sent to retrieve download URL. SAP PO has to download these documents using URLs in the payload and send them as attachments back to System A. System A sends a request to retrieve PDF documents, via SAP PO using a SOAP request, In response System B provides download link instead of documents. At this point, I knew that this is the correct topic where I could share my experience and insight with you. I was exploring options to do this when I decided to go with Java mapping. Okay, So this is the first time I’m writing a blog post on SAP blogs.įor a long time, I was thinking of doing this and looking for the correct topic to start my blogging and then a few days ago I received a requirement where I had to download a pdf from response payload and send it as an attachment along with the response payload.
