In SOAP Client application. I am using javax.xml.soap api. I am getting the soap response. A part of it, shown below.
<ns5:XXX type="Full" format="HTML">
<ns5:EmbeddedFile MIMEType="text/html"
fileExtension="html"
fileName="ZZZ.html">
<ns5:Document>...</ns5:Document>
</ns5:EmbeddedFile>
</ns5:XXX>
The value between the Document tag is in the Base64 format.
I need to know two things, as in the above code you will see that, the fileName is zzz.html.
where this zzz.html file will stored or exits. I search for in my local machine i do not find.
Another thing i would like to know that the between the Document tags it show long text messages in the Base64 format. Is this is the document that exists in the zzz.html. If it is so how to read that document.
Thanks
This appears to be a custom way of embedding file content to a SOAP message being used by the service you are calling - a standard way of doing this would have been using Soap Attachments.
In this specific case, it does look like the file content is being embedded as Base64 data between the Document tags, and the meta information of the file is the attributes of EmbeddedFile tag. You will basically have to decode the Base64 encoded content - see here
and here on how to, move the contents to a file with the name in the meta information tag.
Related
I am trying to read the HTML contents of a Document object(mail) as a part of my plug in development in Lotus Notes 9.
With this HTML content, we would like to create a file and send it as an attachment file in our query, so we can preserve the formatting, images, etc.
Even after session.setConvertMIME(false); I still do not get the Mime entity when I call doc.getMIMEEntity().
I have made preferences setting in Preferences>Mail>Internet
Internet mail format to "HTML and plain text".
I have tried doc.createMIMEEntity and then tried to retrieve it
mimePart = doc.getMIMEEntity("Body");
When i right clicked on Incoming mails from outlook I was able to see multiple Body items, one of which contained the HTML part.However I was still not able to access it via getMIMEEntity.
The mails I created from lotus notes, do not have multiple Body items. When I receive the mails from Lotus Notes > Outlook and I inspect source in Outlook, I see it as HTML. So I assume there is a place where this conversion takes place.
ShelfSession.getInstance().localSession.setConvertMime(false);
MIMEEntity nMime = (MIMEEntity) doc.getMIMEEntity("Body");
I want the Mime part to be set to this variable so I can retrieve the content to form the HTML file.
Please help with any code suggestions or is there some Lotus notes setting that I have missed out on that is making the Mime variable always null?
You said, "The mails I created from lotus notes, do not have multiple Body items." This almost certainly means the Body item is stored as rich text instead of MIME. You can confirm this by looking at the document properties in Notes.
You can use document.convertToMIME() to convert a Body item from Notes rich text to MIME. Here's an example:
MIMEEntity mimeEntity = null;
Item item = document.getFirstItem("Body");
if (item != null) {
if (item.getType() == Item.RICHTEXT) {
// Convert Notes rich text to MIME
document.convertToMIME(Document.CVT_RT_TO_PLAINTEXT_AND_HTML, 0);
}
mimeEntity = document.getMIMEEntity();
}
I've adapted this example from some code in MimeEntityHelper from the XPages Extension Library. I'd encourage you to take a look at that code for more context. For example, you still need to call session.setConvertMIME(false) to avoid converting a document that is already MIME to rich text. The MimeEntityHelper class uses both session.setConvertMIME() and document.convertToMIME() to control document conversions.
Eurostat data can be downloaded via a REST API. The response format of the API is a XML file formatted according to the SDMX-ML standard. With SAS, very conveniently, one can access XML files with the libname statement and the XML or XMLv2 engine.
Currently, I am using the xmlv2 engine together with the automap= option to generate an xmlmap to access the data. It works. But the resulting SAS data sets are very unstructured, and for another data set to be downloaded the data structure might change. Also the request might depend on the DSD-file that Eurostat provides for each database item within a different XML file.
Here comes the code:
%let path = /your/working/directory/;
filename map "&path.map.txt";
filename resp "&path.resp.txt";
proc http
URL="http://ec.europa.eu/eurostat/SDMX/diss-web/rest/data/cdh_e_fos/..PC.FOS1.BE/?startperiod=2005&endPeriod=2011"
METHOD="GET"
OUT=resp;
run;quit;
libname resp XMLv2 automap=REPLACE xmlmap=map;
proc datasets;
copy out=WORK in=resp;
run;quit;
With the code above, you can view all downloaded data in your WORK library. Its a mess.
To download another time series change parameters of the URL according to Eurostat's description.
So here is my question
Is there a way to easily generate a xmlmap from a call to the DSD file so that the data are stored in a well structured way?
As the SDMX-ML standard is widely used in public institutions such as the ECB, Eurostat, OECD... I am wondering if somebody has implemented requests to the databases, already. I know about the tool from Banca Italia which uses a javaObject. However, I was wondering if there might be a solution without the javaObject.
At the main page of the Jodd email library http://jodd.org/doc/email.html
there is a very specific example on how to use the library to embed an image (and not just simply attach it as a file) to an email you are about to send.
Unfortunately the resulting Content-Type of the part of the email that contains the image is:
Content-Type: application/octet-stream
But in order to display it correctly we need this Content-Type:
Content-Type: image/png
if you have a png image for instance.
But I cannot seem to find how to configure this inside the Jodd email library..
This is what I am seeking for. Thank you :)
If you followed the example from Jodd site then you embedded your files using method embedFile(). This method is a 'shortcut' method for:
attach(new FileAttachment(file));
where attach() is the central, generic method for attaching content. FileAttachment rely on javax.mail for setting the content type, probably based on extension.
Therefore, to set content type manually, use generic attach() method. For example, embedding file like this:
.embedFile("d:\\c.xxx")
would set content type to "application/octet-stream" as it is not recognized for xxx extension. Instead, you can use the following:
.attach(new ByteArrayAttachment(
FileUtil.readBytes("d:\\c.xxx"), "image/png", "c.png", "c.png"))
where you can manually set the content type regardless the file name. If you don't want to load file bytes, you can pass InputStream instead etc.
Another solution (if you want to keep using embedFile) is to check your mime type settings.
Note: since there are many combinations how to attach content (bytes, input stream, file, inline...), attach methods will be refactored in Jodd 3.4.1. in order to provide more developer friendly api. Stay tuned ;)
In my Scala code, I am fetching a response from a server using the getInputStream method of HttpUrlConnection class. The response is XML data. However the data contains HTML entities like & and '.
Is there a way I can replace these characters with their text equivalent so that I can parse the XML properly?
It's necessary to encode those entities in xml so they don't interfere with its syntax. The <(<) and > (>) entities make this more obvious. It would be impossible to parse XML whose content was littered with < and > symbols.
Scala's scala.xml package should give you the tools you need to parse your xml. Here's some guidance from the library's author.
Currently, I have a servlet act as web service.
When I pass in parameters using POST, it will return me an executable binary file (application/octet-stream). However, beside binary file, I would also like to get additional information (in text format) about this binary file.
Is it possible to achieve this by using only single POST request? But, how is it possible, to switch from application/octet-stream to text/plain within single POST response?
It is not possible to change the MIME type within a single response.
However, i think t is possible to put your additional information into the response header using the HttpServletResponse.addHeader method.
You could return a multipart MIME response (multipart/mixed; boundary=XXX instead of application/octet-stream) with the binary part encoded in Base64.
I'm not sure if the JavaMail API can be used to construct the content, but it's worth a look.
Within a single POST it isn't possible. But two ideas:
Show your text file as another web page that starts the download of your executable
Bundle both files into a zip archive