Author |
Message
|
matuwe |
Posted: Fri Mar 15, 2013 12:01 am Post subject: Http Reply response MIME text/html |
|
|
 Master
Joined: 05 Dec 2007 Posts: 296
|
Hi
I am trying to send a response to an HTTP request and the data is wrapped as one long html string, then converted to BLOB and added to OutputRoot.
But the data shows as an XML format
Code: |
<html>
<Body>
hello
</Body>
</html>
|
How can I get my response to be rendered like proper html page. I also tries building my OutputRoot.XMLNSC.HTML.Body
Still get the same
Is there any properties I need...  |
|
Back to top |
|
 |
kimbert |
Posted: Fri Mar 15, 2013 1:30 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
the data is wrapped as one long html string, then converted to BLOB and added to OutputRoot |
So why not output it using the BLOB domain? |
|
Back to top |
|
 |
McueMart |
Posted: Fri Mar 15, 2013 2:27 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
Do you have:
As the first line in the HTML document you are returning? Else the browser will render the page as an XML file (i think!). |
|
Back to top |
|
 |
matuwe |
Posted: Mon Mar 18, 2013 11:53 pm Post subject: |
|
|
 Master
Joined: 05 Dec 2007 Posts: 296
|
It didnt work. I have posted the code.
Code: |
CREATE
COMPUTE MODULE testHTML_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
SET OutputLocalEnvironment = InputLocalEnvironment;
-- CALL CopyEntireMessage();
--SET OutputRoot.XMLNSC.html.body.table.tr[1].td ='Dudu';
--SET OutputRoot.XMLNSC.html.body.table.tr[2].td ='Rose';
DECLARE sString CHARACTER '<!DOCTYPE html> <html> <HEAD><TITLE> Monitor</TITLE></HEAD><BODY bgcolor="#FFFFFF" text="#000000" marginheight="0" topmargin="0"> <form> <input type="radio" value="cluster"/></form></BODY></html>';
DECLARE contentType CHAR 'text/html';
SET OutputRoot.Properties.Domain = 'MIME';
SET OutputRoot.HTTPInputHeader."Content-Type" = contentType;
-- create MIME header
SET OutputRoot.MIME."Content-Type" = contentType;
CREATE FIELD OutputRoot.MIME TYPE Name;
DECLARE M REFERENCE TO OutputRoot.MIME;
CREATE LASTCHILD OF M TYPE Name NAME 'Data';
DECLARE newBLOB BLOB;
SET newBLOB = CAST(sString AS BLOB CCSID 1208);
CREATE LASTCHILD OF M.Data DOMAIN('BLOB') NAME 'BLOB';
CREATE LASTCHILD OF M.Data.BLOB NAME 'BLOB' VALUE newBLOB;
RETURN TRUE;
END;
CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
END
MODULE;
|
 |
|
Back to top |
|
 |
McueMart |
Posted: Tue Mar 19, 2013 1:23 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
Well firstly you didnt tell us what's still not working. Is the browser still just showing the page as if its XML?
Secondly why are you using the MIME domain? You are just trying to send back an HTML response right?
Try creating the payload under OutputRoot.BLOB.BLOB. |
|
Back to top |
|
 |
matuwe |
Posted: Tue Mar 19, 2013 4:32 am Post subject: |
|
|
 Master
Joined: 05 Dec 2007 Posts: 296
|
Sorry for the incomplete info.. I have changed the code and have just tested
Code: |
CALL CopyMessageHeaders();
SET OutputLocalEnvironment = InputLocalEnvironment;
DECLARE sString CHARACTER '<!DOCTYPE html> <html> <HEAD><TITLE> Monitor</TITLE></HEAD><BODY bgcolor="#FFFFFF" text="#000000" marginheight="0" topmargin="0"> <form> <input type="radio" value="cluster"/></form></BODY></html>';
DECLARE newBLOB BLOB;
SET newBLOB = CAST(sString AS BLOB CCSID 1208);
SET OUTputRoot.BLOB.BLOB = newBLOB ;
RETURN TRUE;
END;
|
I have also tried
Code: |
SET OutputLocalEnvironment = InputLocalEnvironment;
SET Environment.XMLNSC.html.body.table.tr[1].td ='Dudu';
SET Environment.XMLNSC.html.body.table.tr[2].td ='Rose';
DECLARE newBLOB BLOB;
SET newBLOB = ASBITSTREAM(Environment.XMLNSC BLOB CCSID 1208);
CREATE LASTCHILD OF M.Data DOMAIN('BLOB') NAME 'BLOB';
CREATE LASTCHILD OF M.Data.BLOB NAME 'BLOB' VALUE newBLOB;
RETURN TRUE;
|
I still get XML back with first line AS <DOCTYPE HTML>
Last edited by matuwe on Tue Mar 19, 2013 6:08 am; edited 1 time in total |
|
Back to top |
|
 |
McueMart |
Posted: Tue Mar 19, 2013 5:51 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
|
Back to top |
|
 |
|