To print the contents present in SOAP header in the console - jboss

I want to print the contents present in the soap-header in my jboss-esb console but I'm not able to do so.
I'm only able to print the body of the soap content but not the contents present in the header part.
Can any one help me to print the contents present in the soupui header in my jboss console?

Related

Using cookies in Perl without CGI

I am trying to create a standard forum style website using Perl but not using CGI, or any other framework for that matter. I've seen before use of a script simply titled "cookies.pl," but can't find any sort of documentation on it. Is there a way to set/read cookies with just core modules?
First, I am assuming that when you say you don't want to use "CGI", you mean the Perl module CGI.pm rather than the Common Gateway Interface (CGI) method of communicating with the web server, which is implemented by the CGI.pm module.
Second, this answer is for information and entertainment purposes only. Attempting to implement your own CGI handler for use in a production environment is not advisable. It's a Really, Really Bad Idea unless you know exactly what you're doing. And probably still a Bad Idea even if you do. And if you did know exactly what you're doing, you wouldn't have to ask questions about basic parts of the interface like how to implement cookie handling.
With all that out of the way, cookies are pretty simple to handle directly.
To set a cookie, send a Set-Cookie HTTP header to the client. In the most basic form, this looks like Set-Cookie: CookieName=CookieValue. There are many other options which can be added to this basic format, which are documented in various places around the web.
If you're now wondering "How do I send an HTTP header?", every line of text that you send to the client (i.e., print to STDOUT) prior to the first empty line is an HTTP header:
print "Content-Type: text/html\n"; # Content-Type header is mandatory!
print "Set-Cookie: CookieName=CookieValue\n"; # Header to set a cookie
print "\n"; # Blank line = end of headers
# continue on with sending the response body now that headers are done
To read a cookie, look at the environment variable HTTP_COOKIE, which is provided by the web server as a part of its CGI implementation and will contain a semicolon-delimited list of all cookies received with the client's HTTP request. This is accessed in Perl as $ENV{HTTP_COOKIE}.

Sending a cookie value with file download in perl

I've got a submit button on a webpage which performs a file download when clicked.
I'm trying to disable the submit after click (to prevent resubmit while the file is created server-side) then re=enable the submit button when the file is downloaded.
I've almost got it working by following the tutorial below, in short:
When download is clicked get current timestamp and store it in a
hidden field
Send the timestamp with the download request to the server
Server does the file processing
Server creates a cookie with the timestamp value sent from the client
in the original request
Server sends the cookie to the client along with the file to download
On the client if the cookie value matches the hidden field timestamp
the submit is re-enabled
Detecting file download in browser
The problem is that I can't seem to find a way to send the cookie value back to the client with the file download header, if I include set-cookie in the header it breaks the file download process.
Here's my current header, which works:
Content-disposition: attachment; filename=$file; Content-type: $type\n\n$content
If I do this it breaks:
Set-Cookie:$cookie; Content-disposition: attachment; filename=$file; Content-type: $type\n\n$content
I'm creating a cookie on the server with the timestamp value from the client using:
$cookie = CGI::Cookie->new(-name=>'fileDownloadToken',-value=>"$token_value");
Does anyone know how I should go about doing this, coding in Perl?
Ok, I think I've fixed it. Just in case anyone else comes up against this it appeared to be the format of the header, instead of using a single string:
print qq(Content-disposition: attachment; filename=$file; Content-type: $type\n\n$content)
I used this:
print $page->header(
-'cookie' => "$cookie",
-'Content-disposition' => "attachment; filename=\"$file\"",
-'Content-type' => $content
);

Sending a URL/filePath in Resteasy request

I want to send path of a file alongwith some Strings.
After spending some time I was unable to find anything that can help. Could anyone suggest any link on how to do this on server side
You can use any of the following methods to submit a file path and some strings to the server:
Submit a Form with the file path and strings.
Encode the file path and send it as a query parameter in the URL along with the strings.
Create a message body containing the file path and other strings you want to send and submit it via a POST call.
Send the file path and strings in custom http headers.
Take a look at the Resteasy documentation here: http://docs.jboss.org/resteasy/docs/3.0.4.Final/userguide/html_single/
Pay special attention to the sections that talk about using the #Form, #FormParam, #QueryParam, and #POST annotations.

soapUI: multipart/form-data REST request with file attachments

I am using soapUI for testing a REST web service. Is there a way to attach a file with the other parameters in a multipart request? I see the attachment tab in the panel but I cannot give that attachment a parameter name so that server can identify. It's not helping.
I found it but forgot to post it here. It was not so intuitive.
In your REST Request if you can see an attachment tab, open it and add and attachment with + button. The Name of that file would show full path. e.g. C:\temp\my-file.csv
In you parameters tab, add a parameter and give it a name. The value of that parameter will be file:C:\temp\my-file.csv
In SoapUI 5.x and greater, you must select the "Post QueryString" checkbox. Without this, the file will not be send along with the request.
That should be it. When attaching a file if you select Yes when it asks to Cache the file, you won't have to specify full path in step 2 above. The value of file parameter should be file:my-file.csv
select mediatype as application/json and then add the json string to that. It will go to server as payload. Usually this request is of POST or PUT type

Perl, Unix Email: download csv in browser issue

I have this:
open(MAIL,"|/usr/sbin/sendmail -t");
## Mail Header
print MAIL "To: $GLOB_OPT{email}\n";
print MAIL "From: $GLOB_OPT{from}\n";
print MAIL "Subject: $GLOB_OPT{sub}\n";
print MAIL qq|Content-Type: text/html; charset=us-ascii\n|;
print MAIL qq|Content-Transfer-Encoding: 7bit\n|;
print MAIL qq|MIME-Version: 1.0\n\n|;
print MAIL qq|<h3>Download File :</h3><br>|;
print MAIL qq|Click Here|;
close(MAIL);
I want to send the hyperlink to user so they can download the csv file in the $GLOB_OPT{html} path.
When I open the link in my email, it opens the csv in the browser. I want instead the browser to download the file. What can i do?
Try using content-disposition in http headers on the webserver's side. This even works with .htaccess.
As far as I understand, the way you send the e-mail has little to do with the save/display choice in the browser.
Don't use the system sendmail command. Instead use the MIME::Lite module.
They have a coding example that pretty much does exactly what you want to do.
This way, you're not depending upon an external command that may or may not work (depending upon the system and its configuration).
You could output the CSV via a script which sends to the browser first mime-header "application/octet-stream" instead of the default
MIME type sent by apache(or the used server). You can also configure the server to send the header it self by associating the .csv extension with "application/octet-stream" mime type.
see also The apache docs