Webmethods - Retrieve PDF file from SFTP and encode - pdf

I am new to webmethods and need some guidance. I am tasked to read the PDF document from SFTP server and base64 encode it. I have managed to GET the file from SFTP location and now struggling to encode it. Below is the code snippet to read the file:
INVOKE pub.client.sftp:login
INVOKE pub.client.sftp:cd
INVOKE pub.client.sftp:ls
INVOKE pub.client.sftp:get
MAP
I later modified the code to include base64 encoding, no output is produced. Code is shown below:
INVOKE pub.client.sftp:login
INVOKE pub.client.sftp:cd
INVOKE pub.client.sftp:ls
INVOKE pub.client.sftp:get
INVOKE pub.string:base64Encode
MAP
when i debug the code, it executes SFTP GET and stops. No information about encoding.
Please guide me to achieve this requirement. Thank you for your help in advance.

Try something like this,
after sftp:get, invoke the pub.io:streamToBytes and then invoke pub.string:base64Encode
Don't forget to map field in pipeline.

The pub.string:base64Encode expect a byte[] Input, you can try to convert the stream to byte[] with pub.io:streamToBytes

Related

Blue Prism webservice call and csv download

I am trying to configure Blue Prism to make an API call, and then response of this API is a csv file.
Currently I have configured the webservice with "GET" command on the base URL.
But I am not sure what needs to be done in order to download / save the csv file that the API sends. I am assuming that it needs to be explicitly told.
Please help!
In your process, make the HTTP request to the API using the Utility - HTTP VBO's HTTP Request action. Store the Result output parameter in a Text-typed Data Item.
If you need to process the data in a tabular format...
Once the CSV data is there, you can use the Get CSV As Collection action in the Utility - Strings VBO to parse the CSV content into a collection:
If you need to simply save the file...
... use the Utility - File Management VBO's Write Text File action and point it to the location you need to save the CSV to:

Reading Xml from an absolute path

I need to access a remote Xml document from a WCF service. Right now I have:
XmlReader reader = XmlReader.Create("path");
But since the Xml doc is elsewhere on our network I need to give the XmlReader an absolute path, as opposed to having it look deeper in the project folder. How do I do this? I've found surprisingly little information about this. It seems like this should be a simple thing to do. Any help is appreciated!
Thanks
You can use overload that accepts Stream parameters as follows:
using (FileStream fileStream = new FileStream(#"\\computername\shared path"))
using (XmlReader reader = XmlReader.Create(fileStream))
{
// perform your custom code with XmlReader
}
Please note that you need appropriate permission to open remote stream. In WCF service context you may need to use impersonation.

Sending a file from a java client to a server using wcf method?

I want to build a wcf web service so that the client and the server would be able to transfer files between each other. Do you know how I can achieve this? I think I should turn it into a byte array but I have no idea how to do that. The file is also quite big so I must turn on streamed response.
It sounds like you're on the right track. A quick search of the interwebz yielded this link: http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP
Your question indicates that you want to send a file from a java client to a WCFd endpoint, but the contents of your question indicate that this should be a bidirectional capability. If this is the case, then you'll need to implement a service endpoint on your client as well. As far as that is concerned, I cannot be of much help, but there are resources out there like this SO question: In-process SOAP service server for Java
As far as practical implementation, I would think that using these two links you should be able to produce some code for your server and client.
As far as reading all bytes of a file, in C# you can use: File.ReadAllBytes It should work as in the following code:
//Read The contents of the file indicated
string fileName = "/path/to/some/file";
//store the binary in a byte array
byte[] buffer = File.ReadAllBytes(fileName);
//do something with those bytes!
Be sure to use the search function in the future:

How to parse WCF binary response manually (xml)

I need to parse WCF binary response. The reason is that I have no contract nor metadata I can just call wcf service with parameters using WebClient. What I'm getting now is binary response with xml inside but when I want to deserialize it with BinaryFormatter and load xml document, it gives me an error because of leading data. Is there some class which can do this for me?
Thanks.
I was also looking for something similar and I came across https://github.com/waf/WCF-Binary-Message-Inspector
It may help you out.
thank you for responses. Actually I ended up following this blog post (Fiddler plugin):
http://blog.functionalfun.net/2009/11/fiddler-plug-in-for-inspecting-wcf.html
there is also a link to source code:
http://archive.msdn.microsoft.com/wcfbinaryinspector
hope it will help

How to send image through axis2

My Service class designed through Axis2, I am able to send any data type of resords like
(premetive datatypes). I don't know how to send Image file.
Have a read of the documentation - its very good for Axis2 -> http://axis.apache.org/axis2/java/core/docs/mtom-guide.html
There are some code examples in there too on how to transfer images using Axis2
Use soap with attachment option or MTOM..Following posts are helpful
http://www.ibm.com/developerworks/webservices/library/ws-soapatt/
http://www.keith-chapman.org/2008/09/attachments-mtom-swa-and-base64binary.html