ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MIME and HTTPRequest node

Post new topic  Reply to topic
 MIME and HTTPRequest node « View previous topic :: View next topic » 
Author Message
PankajS
PostPosted: Thu Jun 18, 2009 9:30 pm    Post subject: MIME and HTTPRequest node Reply with quote

Voyager

Joined: 27 Dec 2004
Posts: 82

Hi Guys,

I need to send some parametes to along with a file to the server side code.(servlet) . I have gone through follwoing link from this forum but still not able to get the required results.

http://www.mqseries.net/phpBB2/viewtopic.php?t=38268&postdays=0&postorder=asc&highlight=mime+esql&start=30

My Problem is : servlet not able to get the field values and file sent from Message Broker. Servlet can understand that the incomming message is a MIME message . It can detect the field values if passes as a URL.

I am using following ESQL code:

------Start of ESQL----

SET OutputRoot.HTTPRequestHeader.POST = '/examples/servlets/servlet/DefaultFileItemHari?';
SET OutputRoot.HTTPRequestHeader."Content-Type" = 'multipart/form-data; boundary=' || boundary;
SET OutputLocalEnvironment.Destination.HTTP.RequestURL = 'http://localhost:8080/examples/servlets/servlet/DefaultFileItemHari';
-- SET OutputLocalEnvironment.Destination.HTTP.RequestURL ='http://localhost:8080/examples/servlets/servlet/DefaultFileItemHari?firstname=Pankaj&lastname=Shahane';

SET OutputRoot.HTTPRequestHeader.Host = 'localhost';

SET OutputRoot.Properties.ContentType = 'multipart/form-data; boundary=' || boundary;

--CREATE FIELD OutputRoot.MIME.Parts;
CREATE LASTCHILD OF OutputRoot DOMAIN('MIME') NAME('Parts');
CREATE LASTCHILD OF OutputRoot.MIME.Parts TYPE Name NAME 'Part';
-- SET OutputRoot.MIME."Parts"."Part"[1]."Content-Disposition" = 'form-data';
DECLARE P1 REFERENCE TO OutputRoot.MIME.Parts.Part[1];
-- SET P1."Content-Type" = 'text/plain';
SET P1."Content-Disposition" = 'form-data';
SET P1."name" = 'firstname';
CREATE LASTCHILD OF P1 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P1.Data DOMAIN('BLOB') value(abc);


CREATE LASTCHILD OF OutputRoot.MIME.Parts TYPE Name NAME 'Part';
DECLARE P2 REFERENCE TO OutputRoot.MIME.Parts.Part[2];
SET P2."Content-Type" = 'text/plain';
SET P2."Content-Disposition" = 'form-data';
SET P2."name" = 'lastname';
CREATE LASTCHILD OF P2 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P2.Data DOMAIN('BLOB') PARSE(blastname);

-- Note blastname is a blob variable..

DECLARE part1Data BLOB ASBITSTREAM(InputRoot.XMLNSC, InputProperties.Encoding, InputProperties.CodedCharSetId);
CREATE LASTCHILD OF OutputRoot.MIME.Parts TYPE Name NAME 'Part';
DECLARE P3 REFERENCE TO OutputRoot.MIME.Parts.Part[3];
SET P3."Content-Type" = 'text/xml';
SET P3."Content-Disposition" = 'form-data';
--SET P3."Content-Disposition" ='application/x-www-form-urlencoded';
SET P3."name" = 'uploadMe';
SET P3."filename"='HelpMe.txt';
CREATE LASTCHILD OF P3 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P3.Data DOMAIN('BLOB') PARSE(part1Data);

-----End of ESQL


Serverside code excerpt : System.out.println("Code is working");

-- Java code starts -------------------

String firstName = request.getParameter("firstname");
String lastName = request.getParameter("lastname");
System.out.println("First Name is :"+firstName+" and Last Name : "+lastName);

if (firstName != null || lastName != null) {

out.println("First Name:"+firstName+" Last Name:"+lastName);

} else {
out.println(rb.getString("requestparams.no-params"));
}


/////////////////////////////////////


DiskFileUpload upload = new DiskFileUpload();
System.out.println("Upload object....."+upload.toString());
List formItems = null;
try {
formItems = upload.parseRequest(request, 5000, 5000, "C:\\Pankaj\\dummy.txt");
System.out.println("formItems object....."+formItems.toString());
} catch (FileUploadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Iterator iterator = formItems.iterator();
System.out.println("Iterator ............"+iterator.toString());
while (iterator.hasNext()) {

FileItem item = (FileItem) iterator.next();

if (item.isFormField()) { //this is a parameter passed on the request
String parmName = item.getFieldName(); //this is your meta data
String parmVal = item.getString();
System.out.println("Param Name :"+parmName+" and param Value : "+parmVal);
}
else { java.io.InputStream uploadedStream = item.getInputStream(); //get the content

System.out.println("UploadStream...."+uploadedStream.toString());
object is populated here.
along with meta data.
}
}
System.out.println("Iterator DO NOT HAVE VALUE.");

------Java Code Ends------------------------------------------------------------


Java code Result

Code is working
First Name is :null and Last Name : null
Upload object.....org.apache.commons.fileupload.DiskFileUpload@633e5e
formItems object.....[]
Iterator ............java.util.AbstractList$Itr@193c0cf
Iterator DO NOT HAVE VALUE.



Guys desparately need help on this ..
Back to top
View user's profile Send private message
PankajS
PostPosted: Thu Jun 18, 2009 9:34 pm    Post subject: Reply with quote

Voyager

Joined: 27 Dec 2004
Posts: 82

By the way ..
my flow looks like ..

MQInput > Compute > HTTPRequest > MQOutput
Back to top
View user's profile Send private message
PankajS
PostPosted: Fri Jun 19, 2009 10:11 am    Post subject: Reply with quote

Voyager

Joined: 27 Dec 2004
Posts: 82

Any suggestion guys ..
I am still to figure out how to do that ...
Back to top
View user's profile Send private message
PankajS
PostPosted: Tue Jun 23, 2009 5:34 am    Post subject: Reply with quote

Voyager

Joined: 27 Dec 2004
Posts: 82

Hi Guys .. I fixed my problem using JCN. I used java code to call the servlet with some parameters and upload the file.

But still querious about how can we do that through ESQL.

Please share , if any one have already done that.

Thanks.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Tue Jun 23, 2009 5:28 pm    Post subject: Re: MIME and HTTPRequest node Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

PankajS wrote:
Hi Guys .. I fixed my problem using JCN. I used java code to call the servlet with some parameters and upload the file.

The JCN is best reserved for whatever can't be done in ESQL.

PankajS wrote:
But still querious about how can we do that through ESQL.

To examine the serialized http request, insert some sort of monitoring/debugging tool between the HTTPRequest node and the servlet, or temporarily redirect the URL, or use some combination of ASBITSTREAM, CAST, and usertrace. Compare the actual http request with the expected http request, and adjust the ESQL as needed.

There is at least one problem with the given ESQL: it does not construct the Content-Disposition header correctly. Replace code like this:
Code:
SET P1."Content-Disposition" = 'form-data';
SET P1."name" = 'firstname';

...with code like this:
Code:
SET P1."Content-Disposition" = 'form-data; name="firstname"';
Back to top
View user's profile Send private message
g3_wmb
PostPosted: Mon Feb 14, 2011 3:33 am    Post subject: Need to send a MIME message using HTTP Request node Reply with quote

Newbie

Joined: 14 Feb 2011
Posts: 1

We need to send two parts as a MIME message. The first part is an xml and the second part is a image file.We have used Compute node to create a MIME message and have done a servlet call using HTTP request node.

In the Java code, the incoming message is identified as a multipart message ,but, parseRequest returns no items.


Below is the code snippet. Please help..

SET FileName = InputLocalEnvironment.File.Name;
SET StringPart = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Order Id="111"><LineItem Id="1"/></Order>';

CREATE FIELD OutputRoot.MIME TYPE Name;
DECLARE M REFERENCE TO OutputRoot.MIME;
CREATE FIELD M TYPE Name;

-- Create the Content-Type child of MIME explicitly to ensure the correct order. If we set
-- the ContentType property instead, the field could appear as the last child of MIME.
CREATE FIELD M."MIME-Version" TYPE NameValue VALUE '1.0';
CREATE FIELD M."Content-Type" TYPE NameValue VALUE 'multipart/form-data; boundary=myBoundary';
CREATE LASTCHILD OF M TYPE Name NAME 'Parts';
CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P1 REFERENCE TO M.Parts.Part;

-- First part:
CREATE FIELD P1."Content-Type" TYPE NameValue VALUE 'application/xml; charset=UTF-8';
CREATE FIELD P1."Content-Transfer-Encoding" TYPE NameValue VALUE '8-bit';
CREATE LASTCHILD OF P1 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P1.Data DOMAIN('BLOB') PARSE(CAST(StringPart AS BLOB CCSID 1208));

CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P2 REFERENCE TO M.Parts.Part[2];
CREATE FIELD P2."Content-Type" TYPE NameValue VALUE 'image/tiff; charset=UTF-8; name='||FileName;
CREATE FIELD P2."Content-Transfer-Encoding" TYPE NameValue VALUE '8-bit';
CREATE LASTCHILD OF P2 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P2.Data DOMAIN('BLOB') PARSE(InputRoot.BLOB.BLOB,InputProperties.Encoding,InputProperties.CodedCharSetId);
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MIME and HTTPRequest node
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.