I got one requirement in which we want to attach one PDF file with response in VSI (Virtual Service Image). After that when we will test that service with SOAP ui, we want that stubbed response with attachment.
Please help me in this on urgent basis as it is impacting our work.
Thanks in advance.
It is very simple, you just need to convert your PDF to binary format and copy and past the binary content to virtual response.
To convert the pdf file to binary content, follow the steps for work around.
1. Create a new response on SI and change the response type to Graphical Image.
2. Upload the pdf file to the virtual response by click "Load from File" button from the response panel.
3. After you select you will get the screen as shown below, meaning you have uploaded the wrong file type but you are still fine with the message
4. Now change the response format to Graphic Image to Binary.
5. Once you change to binary format the virtual response will be as shown below.
6. Change the character encoding to ISO-8859-9
7. Save the service image.
Now change the response content type PDF. To do that change the Content-Type attribute on the response meta-data.
I have tested it from the Postman I can see the binary response.
If the test the same request from the browser I can see the PDF.
Hope this helps,
Vamsi Kurukuri | CA Technologies | Service Architect
thanks for your response. It was very helpful. But Now one more issue, I have configured binary code with response and testing using SOAP UI, I am getting response with attachment. I am able to download attachment from SOAP UI but I am not able to see content inside it while original pdf is having content.
Can you please help in this also?
Hi. I had the same issue. You need to save the pdf as a fdf file. Then it will work. Example: "filename._pdf_.fdf". Adobe reader reads fdf as well.
Thank you so much for your reply.
But still it is not working. I have renamed it with .fdf extension but still not able to see content of pdf. I am giving name like ****.fdf. Is it correct?
Please give me any other solution. It is very urgent.
Let me look into the virtual service I created and get back to you.
------=_Part_3_30345399.1413353227843Content-Type: text/xml; charset=utf-8Content-Transfer-Encoding: 8bitContent-ID: <email@example.com>
------=_Part_3_30345399.1413353227843Content-Type: application/pdfContent-Transfer-Encoding: binaryContent-ID: <CA303B5BB1B9090AFBE6A5D3CFEDAC45>
and in response meta data, I am using below.
Content-Type: multipart/related; type="text/xml"; start="<firstname.lastname@example.org>"; boundary="----=_Part_3_30345399.1413353227843"
please check if I am doing any mistake here. Also provide me screen shot of how we can test same thing in CA Lisa test case. I will be thankful to you if you will come to me asap and will resolve this issue. I am doing lot of searching round this from last 3 days but not getting any luck.
Thanks in advance
Make sure you have the response meta data set to :
Make sure you imported the pdf with the file extension “.fdf” and follow the exact instructions as outlined in the proposed solution.
I just did that again and my virtual service works fine. I suggest opening up a ticket, with CA Support, and they will help you. They are very good and within a short period of time you will be up and running.
Also see attached screen shots as that might be helpful.
thanks for your reply. I will do that what you suggested.
I raised ticket to CA support but they are saying the version I am using is out of support. So they can not help.
I would suggest if you can put some screen shot from your end , screen shots of steps, that will be helpful.
Thanks for screen shot it sorted out issue to maximum extent. But it is not solving exact requirement. Requirement is that , we want this attachment with soap response and I am using below code in response body. and it is giving attachment in SOAP UI tool. But I am facing two problems:
1. When I am testing using SOAP UI tool, I am getting response with attachment , but when I am opening attachment I am not able to see content of pdf file. It is showing as blank.
2. When I am testing same service using CA Lisa test case then I am getting binary code only not pdf attachment in response.
Your help is must. Please reply. Waiting for your reply.
I am on vacation so my response are little late, can you please send me your sample SOAP response.
Thanks you so much for your reply.
Oh so sorry I am disturbing you on vacation. Please get sample request and response XMLs. PDF attachment you can use any one from your system.
<soapenv:Envelope xmlns:soap="http://www.lloydstsb.com/Schema/Infrastructure/SOAP" xmlns:ifw="http://www.lloydstsb.com/Schema/CommunicationDispatch/IFW" xmlns:commn="http://www.lloydstsb.com/Schema/Enterprise/IFWXML_Communication" xmlns:ri="http://www.lloydstsb.com/Schema/Enterprise/IFWXML_ResourceItem" xmlns:com="http://www.lloydstsb.com/Schema/Enterprise/IFWXML_Common" xmlns:typ="http://g1.com/service/doc1gen/types" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/> <soapenv:Body> <typ:CompositionRequest> <typ:key>ATTACHMENT</typ:key> <typ:publicationName>LBGDOCUMENTATIONSUMMARY</typ:publicationName> <typ:data dataRef="cid:printXML"/> </typ:CompositionRequest> </soapenv:Body></soapenv:Envelope>
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <ns1:CompositionResult xmlns:ns1="http://g1.com/service/doc1gen/types"> <ns1:key>ATTACHMENT</ns1:key> <ns1:elapsedTime>1671</ns1:elapsedTime> <ns1:attachmentType> <ns1:alias>output1</ns1:alias> <ns1:data dataRef="cid:CA303B5BB1B9090AFBE6A5D3CFEDAC45"/> <ns1:content>document</ns1:content> </ns1:attachmentType> </ns1:CompositionResult> </soapenv:Body></soapenv:Envelope>
I am pasting binary code in with this response with line of codes as mentioned in previous post. Please sort out this problem and suggest around two issues I mentioned in previous post.
Hope you have enjoyed your Xmas holiday. Have you got time to look into this?
I am just back from my vacation , I will look into this issue and get back to you by today evening.
Hope you enjoyed your vacations. Thanks for looking into this. I will wait for your response and timely help.
You have to create the virtual service response as multi-part response. The first part will be the SOAP response and second part will be PDF attachment.
See the below sample response content, the key part is 'Content-Transfer-Encoding' , there are three types of encoding you can use base64, binary, and 8bit. If you encode your pdf into binary the specify 'Content-Transfer-Encoding' as 'binary' or the pdf is encoded with base64 then specify' Content-Transfer-Encoding' as 'base64'. I
I have tested it and it is working file
--MIME_boundaryContent-Type: text/xml; charset=UTF-8Content-Transfer-Encoding: 8bitContent-ID: <email@example.com>
<?xml version='1.0' ?><SOAP-ENV:Envelopexmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><theSignedForm href="cid:firstname.lastname@example.org"/></SOAP-ENV:Body></SOAP-ENV:Envelope>
--MIME_boundaryContent-Type: application/pdfContent-Transfer-Encoding: base64Content-ID: <email@example.com>
//Add PDF as base64 bit encoded string.
Add the following paraments to response meta data.
Content-Type : Multipart/Related; boundary=MIME_boundary; type="text/xml"; start="<firstname.lastname@example.org>"
Content-Description : [Add some desctiption]
MIME-Version : 1.0
On SOAP-UI , I get the SOAP response with attachment and I can open it successfully.
hope this helps,
Thanks Vamsi. That is really helpful.
I will try with same thing with Binary encoding. can you tell me how to encode it with base 64, please?
It is pretty simple, on the DevTest workstation , create a new test.
1. Add Base64 Encoder Step
2. Load the pdf file and click on load button to generate the Base64 encoded string, then copy and past it to virtual response.
Hi, Can anyone share the sample project which downloads pdf ?
Hi Vamsi, I have tried as per your comments above and getting below error when tested. Could you please help me out. Thanks in Advance.
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <soapenv:Fault> <faultcode>soapenv:Server.userException</faultcode> <faultstring>java.io.IOException: End of stream encountered before final boundary marker.</faultstring> <detail> <ns1:stackTrace xmlns:ns1="http://xml.apache.org/axis/">java.io.IOException: End of stream encountered before final boundary marker. at org.apache.axis.attachments.BoundaryDelimitedStream.read(BoundaryDelimitedStream.java:308) at org.apache.axis.attachments.BoundaryDelimitedStream.read(BoundaryDelimitedStream.java:358) at com.sun.mail.util.BASE64DecoderStream.getByte(BASE64DecoderStream.java:358) at com.sun.mail.util.BASE64DecoderStream.decode(BASE64DecoderStream.java:249) at com.sun.mail.util.BASE64DecoderStream.read(BASE64DecoderStream.java:144) at java.io.FilterInputStream.read(Unknown Source) at org.apache.axis.attachments.ManagedMemoryDataSource.<init>(ManagedMemoryDataSource.java:146) at org.apache.axis.attachments.MultiPartRelatedInputStream.readTillFound(MultiPartRelatedInputStream.java:557) at org.apache.axis.attachments.MultiPartRelatedInputStream.readAll(MultiPartRelatedInputStream.java:433) at org.apache.axis.attachments.MultiPartRelatedInputStream.getAttachments(MultiPartRelatedInputStream.java:439) at org.apache.axis.attachments.AttachmentsImpl.mergeinAttachments(AttachmentsImpl.java:174) at org.apache.axis.attachments.AttachmentsImpl.getContentLength(AttachmentsImpl.java:455) at org.apache.axis.Message.getAttachmentSize(Message.java:684) at com.itko.lisa.ws.axis.LisaHTTPSender.doInvoke(LisaHTTPSender.java:650) at com.itko.lisa.ws.axis.LisaHTTPSender.invoke(LisaHTTPSender.java:274) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) at org.apache.axis.client.Call.invokeEngine(Call.java:2837) at org.apache.axis.client.Call.invoke(Call.java:2820) at com.itko.lisa.ws.nx.NxWSStep.executeCall(NxWSStep.java:383) at com.itko.lisa.ws.nx.NxWSStep.execute(NxWSStep.java:287) at com.itko.lisa.ws.nx.ui.NxWSStepEditor$6.run(NxWSStepEditor.java:599)</ns1:stackTrace> <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">VPCAUMWHW70320</ns2:hostname> </detail> </soapenv:Fault> </soapenv:Body></soapenv:Envelope>
I have a similar requirement. First of all I want to know how to create the virtual service response as multi-part response.
I have SOAP response along with Binary data, which should load as attachment at UI.