Returning content type of application/RFC822

I have a servlet which needs to return a data stream that the browser
          shoule save as a file on the users local hard drive.
          My servlet seems to work just fine with Netscape 4.7 but IE always saves
          the original HTML Form page that called the Servlet.
          Is there a bug in WL/IE or am I doing something stupid
          here's my code - the method doing returning the data is the last one in
          this code - getResponseFromDispatch()
          Thanks
          Tom
          package com.nexterna.optiform.server.b2b;
          import javax.servlet.*;
          import javax.servlet.http.*;
          import java.io.*;
          import java.util.*;
          import javax.naming.*;
          import org.apache.log4j.Category;
          import org.apache.log4j.PropertyConfigurator;
          import org.w3c.tools.codec.Base64Encoder;
          import com.nexterna.optiform.server.ejb.dispatcher.*;
          import com.nexterna.optiform.common.*;
          import com.nexterna.ejb.usermanager.*;
          import com.nexterna.common.security.*;
          * Title: B2BInterfaces
          * Description:
          * Copyright: Copyright (c) 2001
          * Company:
          * @author
          * @version 1.0
          public class ExportResponseAsXML extends HttpServlet {
          private static final String CONTENT_TYPE = "text/html";
          /**Initialize global variables*/
          private Context jndiContext = null;
          private String poolName = "";
          private String providerURL = "";
          private String icf = "";
          private String command = null;
          private DispatcherServices dispatcher = null;
          private UserManager usermgr = null;
          private String ccode = "b2b.9284s3a41";
          private static Category cat =
          Category.getInstance(ExportResponseAsXML.class.getName());
          public void init(ServletConfig config) throws ServletException {
          super.init(config);
          try {
          InitialContext ic = new InitialContext();
          Context environment = (Context) ic.lookup("java:comp/env");
          PropertyConfigurator.configure(
          config.getInitParameter("LOG4J"));
          poolName =
          config.getInitParameter("POOLNAME");
          providerURL = config.getInitParameter("PROVIDER_URL");
          icf = config.getInitParameter("INITIAL_CONTEXT_FACTORY");
          catch (NamingException e) {
          cat.error("Exception in EJBCreate trying to lookup
          initializations");
          cat.error("Servlet Failed Initialization " + poolName + ":"
          + providerURL + ":" + icf);
          cat.error(e);
          getDispatchServices();
          getUserManager();
          if (cat.isDebugEnabled()) {
          cat.debug("Servlet Initialized " + poolName + ":" +
          providerURL + ":" + icf);
          /**Process the HTTP Get request*/
          public void doGet(HttpServletRequest request, HttpServletResponse
          response) throws ServletException, IOException {
          response.setContentType(CONTENT_TYPE);
          PrintWriter out = response.getWriter();
          out.println("<html>");
          out.println("<head><title>ExportResponseAsXML</title></head>");
          out.println("<body>");
          out.println("<p>The servlet has received a GET. This is the
          reply.</p>");
          out.println("</body></html>");
          /**Process the HTTP Post request*/
          public void doPost(HttpServletRequest request, HttpServletResponse
          response)
          throws ServletException, IOException {
          // first we need to get the user-id/password and create a user profile
          Base64Encoder b = new Base64Encoder(request.getParameter("passwd"));
          String pass = b.processString();
          if (usermgr == null)
          log("User manager is null!");
          UserProfile up = usermgr.getUserProfile(
          request.getParameter("userid").toUpperCase(), pass);
          if ((up == null) ||
          (!ccode.startsWith(request.getParameter("controlcode")))) {
          response.setContentType("text/html");
          PrintWriter out = response.getWriter();
          out.println("<html>");
          out.println("<head><title>ExportResponse</title></head>");
          out.println("<body>");
          out.println("<p>Incorrect parameters");
          out.println("</body></html>");
          cat.error("incorrect parameters: " + up + " : " +
          request.getParameter("controlcode"));
          else {
          // there are 3 ways to export responses
          // 1. via the dispath id
          // 2. via the response id
          // 3. vis the form name and last retrieved date
          // the third one allows you to get all new responses for a form
          type
          // and for a time period.
          String rid = request.getParameter("rid");
          String did = request.getParameter("did");
          String formname = request.getParameter("formname");
          String date = request.getParameter("datefrom");
          boolean failed = false;
          if (cat.isDebugEnabled()) {
          cat.debug("rid " + rid);
          cat.debug("did " + did);
          cat.debug("formname " + formname);
          cat.debug("datefrom " + date);
          if (did != null)
          failed = getResponseFromDispatch(response, did);
          else if (rid != null)
          //failed = getResponse(response, rid);
          System.out.println("temp");
          else if (formname != null && date != null)
          //failed = getAllResponses(response, formname, date);
          System.out.println("temp");
          else {
          response.setContentType(CONTENT_TYPE);
          PrintWriter out = response.getWriter();
          out.println("<html>");
          out.println("<head><title>ExportResponseAsXML</title></head>");
          out.println("<body>");
          out.println("<p>No Responses available.</p>");
          out.println("</body></html>");
          if (failed) {
          response.setContentType(CONTENT_TYPE);
          PrintWriter out = response.getWriter();
          out.println("<html>");
          out.println("<head><title>ExportResponseAsXML</title></head>");
          out.println("<body>");
          out.println("<p>No Responses available due to error.</p>");
          out.println("</body></html>");
          /**Clean up resources*/
          public void destroy() {
          protected static Context getInitialContext(String purl, String picf)
          throws javax.naming.NamingException{
          cat.debug("URL: " + purl);
          cat.debug("Initial_context_factory: " + picf);
          Properties p = new Properties();
          // ... Specify the JNDI properties specific to the vendor.
          p.put(Context.INITIAL_CONTEXT_FACTORY, picf);
          p.put(Context.PROVIDER_URL, purl);
          return new javax.naming.InitialContext(p);
          protected void getDispatchServices() {
          DispatcherServicesHome home = null;
          try {
          //if (jndiContext == null)
          cat.debug("trying to get jndi - dispatcher");
          jndiContext = getInitialContext(providerURL, icf);
          cat.debug("doing lookup - dispatcher");
          Object obj = jndiContext.lookup("nexterna.DispatcherServices");
          cat.debug("getting home ref - dispatcher");
          home = (DispatcherServicesHome)
          javax.rmi.PortableRemoteObject.narrow(
          obj, DispatcherServicesHome.class);
          catch (javax.naming.NamingException ne)
          cat.error(ne);
          catch (Exception e)
          cat.error(e);
          try {
          cat.debug("home.create - dispatcher");
          dispatcher = home.create();
          catch (javax.ejb.CreateException ce)
          cat.error(ce);
          catch (java.rmi.RemoteException re)
          cat.error(re);
          catch (Exception e)
          cat.error(e);
          protected void getUserManager() {
          UserManagerHome home = null;
          try {
          if (jndiContext == null)
          cat.debug("trying to get jndi - usermanager");
          jndiContext = getInitialContext(providerURL, icf);
          cat.debug("doing lookup - usermanager");
          Object obj = jndiContext.lookup("nexterna.UserManager");
          cat.debug("getting home ref - usermanager");
          home = (UserManagerHome) javax.rmi.PortableRemoteObject.narrow(
          obj, UserManagerHome.class);
          catch (javax.naming.NamingException ne)
          cat.error(ne);
          catch (Exception e)
          cat.error(e);
          try {
          cat.debug("home.create - usermanager");
          usermgr = home.create();
          catch (javax.ejb.CreateException ce)
          cat.error(ce);
          catch (java.rmi.RemoteException re)
          cat.error(re);
          catch (Exception e)
          cat.error(e);
          protected boolean getResponseFromDispatch(HttpServletResponse resp,
          String id) {
          String s = null;
          try {
          //before we will export responses to a dispatch, the dispatch
          must be complete
          s = dispatcher.getDispatchStatusString(id);
          catch (java.rmi.RemoteException e)
          cat.error(e);
          return true;
          if (s.compareToIgnoreCase("Completed") != 0) {
          cat.debug("Dispatch status is not COMPLETED. Cannot export
          responses");
          return true;
          resp.setContentType("application/RFC822");
          resp.setHeader("Content-Type", "application/RFC822"); // set both
          ways to be safe
          resp.setHeader("Content-disposition",
          "attachment; filename=\"" + id + ".txt\"");
          cat.debug("Setting headers");
          cat.debug("Content-disposition",
          "attachment; filename=\"" + id + ".txt\"");
          HashMap responses = null;
          try {
          responses = dispatcher.getResponses(id,
          DispatcherServices.DISPATCH_ID);
          catch (java.rmi.RemoteException e)
          cat.error(e);
          return true;
          try {
          ServletOutputStream os = resp.getOutputStream();
          Iterator i = responses.values().iterator();
          while (i.hasNext()) {
          Object o = i.next();
          os.print(o.toString());
          cat.debug("Writing XML");
          cat.debug(o.toString());
          os.flush();
          os.close();
          catch (Exception e)
          cat.error(e);
          return true;
          return false;
          

          There is also a bug in IE5.5 SP0 and 1 where saving a document using the file download
          dialogue can indeed result in the HTML of the active frame being saved instead
          of the document.
          You can get IE 5.5 SP2 fix here:
          http://www.microsoft.com/windows/ie/download/ie55sp2.htm
          "Cameron Purdy" <[email protected]> wrote:
          >Hi Tom,
          >
          >I looked over the code. I think the problem is caused by the fact that
          >you
          >are doing a POST instead of a GET. IE doesn't GET anything back (OK,
          >I'm
          >totally technically wrong, but read the early HTTP specs and you'll see
          >the
          >"intent" of what I'm saying) so it just saves the current document. That's
          >my guess. Change to GET and it should work, since IE will know to save
          >the
          >incoming document.
          >
          >FWIW - You will often get more performance using a buffer of some sort
          >between your looping/writing and the response's stream.
          >
          >Peace,
          >
          >--
          >Cameron Purdy
          >Tangosol Inc.
          ><< Tangosol Server: How Weblogic applications are customized >>
          ><< Download now from http://www.tangosol.com/download.jsp >>
          >
          >
          >"Tom Gerber" <[email protected]> wrote in message
          >news:[email protected]...
          >> I have a servlet which needs to return a data stream that the browser
          >> shoule save as a file on the users local hard drive.
          >>
          >> My servlet seems to work just fine with Netscape 4.7 but IE always
          >saves
          >> the original HTML Form page that called the Servlet.
          >>
          >> Is there a bug in WL/IE or am I doing something stupid
          >>
          >> here's my code - the method doing returning the data is the last one
          >in
          >> this code - getResponseFromDispatch()
          >>
          >> Thanks
          >>
          >> Tom
          >>
          >> package com.nexterna.optiform.server.b2b;
          >>
          >> import javax.servlet.*;
          >> import javax.servlet.http.*;
          >> import java.io.*;
          >> import java.util.*;
          >> import javax.naming.*;
          >>
          >> import org.apache.log4j.Category;
          >> import org.apache.log4j.PropertyConfigurator;
          >> import org.w3c.tools.codec.Base64Encoder;
          >>
          >> import com.nexterna.optiform.server.ejb.dispatcher.*;
          >> import com.nexterna.optiform.common.*;
          >> import com.nexterna.ejb.usermanager.*;
          >> import com.nexterna.common.security.*;
          >> /**
          >> * Title: B2BInterfaces
          >> * Description:
          >> * Copyright: Copyright (c) 2001
          >> * Company:
          >> * @author
          >> * @version 1.0
          >> */
          >>
          >> public class ExportResponseAsXML extends HttpServlet {
          >> private static final String CONTENT_TYPE = "text/html";
          >> /**Initialize global variables*/
          >> private Context jndiContext = null;
          >> private String poolName = "";
          >> private String providerURL = "";
          >> private String icf = "";
          >> private String command = null;
          >> private DispatcherServices dispatcher = null;
          >> private UserManager usermgr = null;
          >> private String ccode = "b2b.9284s3a41";
          >>
          >> private static Category cat =
          >> Category.getInstance(ExportResponseAsXML.class.getName());
          >>
          >> public void init(ServletConfig config) throws ServletException {
          >> super.init(config);
          >>
          >> try {
          >> InitialContext ic = new InitialContext();
          >> Context environment = (Context) ic.lookup("java:comp/env");
          >>
          >> PropertyConfigurator.configure(
          >> config.getInitParameter("LOG4J"));
          >> poolName =
          >> config.getInitParameter("POOLNAME");
          >> providerURL = config.getInitParameter("PROVIDER_URL");
          >> icf = config.getInitParameter("INITIAL_CONTEXT_FACTORY");
          >> }
          >> catch (NamingException e) {
          >> cat.error("Exception in EJBCreate trying to lookup
          >> initializations");
          >> cat.error("Servlet Failed Initialization " + poolName +
          >":"
          >> + providerURL + ":" + icf);
          >> cat.error(e);
          >> }
          >>
          >> getDispatchServices();
          >> getUserManager();
          >>
          >> if (cat.isDebugEnabled()) {
          >> cat.debug("Servlet Initialized " + poolName + ":" +
          >> providerURL + ":" + icf);
          >> }
          >>
          >> }
          >> /**Process the HTTP Get request*/
          >> public void doGet(HttpServletRequest request, HttpServletResponse
          >> response) throws ServletException, IOException {
          >> response.setContentType(CONTENT_TYPE);
          >> PrintWriter out = response.getWriter();
          >> out.println("<html>");
          >> out.println("<head><title>ExportResponseAsXML</title></head>");
          >> out.println("<body>");
          >> out.println("<p>The servlet has received a GET. This is the
          >> reply.</p>");
          >> out.println("</body></html>");
          >> }
          >> /**Process the HTTP Post request*/
          >> public void doPost(HttpServletRequest request, HttpServletResponse
          >> response)
          >> throws ServletException, IOException {
          >>
          >> // first we need to get the user-id/password and create a user
          >profile
          >> Base64Encoder b = new
          >Base64Encoder(request.getParameter("passwd"));
          >> String pass = b.processString();
          >>
          >> if (usermgr == null)
          >> log("User manager is null!");
          >>
          >> UserProfile up = usermgr.getUserProfile(
          >> request.getParameter("userid").toUpperCase(), pass);
          >>
          >> if ((up == null) ||
          >> (!ccode.startsWith(request.getParameter("controlcode"))))
          >{
          >> response.setContentType("text/html");
          >> PrintWriter out = response.getWriter();
          >> out.println("<html>");
          >> out.println("<head><title>ExportResponse</title></head>");
          >> out.println("<body>");
          >> out.println("<p>Incorrect parameters");
          >> out.println("</body></html>");
          >> cat.error("incorrect parameters: " + up + " : " +
          >> request.getParameter("controlcode"));
          >> }
          >> else {
          >>
          >> // there are 3 ways to export responses
          >> // 1. via the dispath id
          >> // 2. via the response id
          >> // 3. vis the form name and last retrieved date
          >> // the third one allows you to get all new responses for a
          >form
          >> type
          >> // and for a time period.
          >> String rid = request.getParameter("rid");
          >> String did = request.getParameter("did");
          >> String formname = request.getParameter("formname");
          >> String date = request.getParameter("datefrom");
          >> boolean failed = false;
          >> if (cat.isDebugEnabled()) {
          >> cat.debug("rid " + rid);
          >> cat.debug("did " + did);
          >> cat.debug("formname " + formname);
          >> cat.debug("datefrom " + date);
          >> }
          >> if (did != null)
          >> failed = getResponseFromDispatch(response, did);
          >>
          >> else if (rid != null)
          >> //failed = getResponse(response, rid);
          >> System.out.println("temp");
          >>
          >> else if (formname != null && date != null)
          >> //failed = getAllResponses(response, formname, date);
          >> System.out.println("temp");
          >>
          >> else {
          >> response.setContentType(CONTENT_TYPE);
          >> PrintWriter out = response.getWriter();
          >> out.println("<html>");
          >> out.println("<head><title>ExportResponseAsXML</title></head>");
          >> out.println("<body>");
          >> out.println("<p>No Responses available.</p>");
          >> out.println("</body></html>");
          >> }
          >>
          >> if (failed) {
          >> response.setContentType(CONTENT_TYPE);
          >> PrintWriter out = response.getWriter();
          >> out.println("<html>");
          >> out.println("<head><title>ExportResponseAsXML</title></head>");
          >> out.println("<body>");
          >> out.println("<p>No Responses available due to error.</p>");
          >> out.println("</body></html>");
          >> }
          >>
          >> }
          >> }
          >> /**Clean up resources*/
          >> public void destroy() {
          >> }
          >>
          >> protected static Context getInitialContext(String purl, String picf)
          >> throws javax.naming.NamingException{
          >>
          >> cat.debug("URL: " + purl);
          >> cat.debug("Initial_context_factory: " + picf);
          >> Properties p = new Properties();
          >> // ... Specify the JNDI properties specific to the vendor.
          >> p.put(Context.INITIAL_CONTEXT_FACTORY, picf);
          >> p.put(Context.PROVIDER_URL, purl);
          >> return new javax.naming.InitialContext(p);
          >> }
          >>
          >>
          >> protected void getDispatchServices() {
          >> DispatcherServicesHome home = null;
          >> try {
          >>
          >> //if (jndiContext == null)
          >> //{
          >> cat.debug("trying to get jndi - dispatcher");
          >> jndiContext = getInitialContext(providerURL, icf);
          >> //}
          >>
          >> cat.debug("doing lookup - dispatcher");
          >> Object obj = jndiContext.lookup("nexterna.DispatcherServices");
          >> cat.debug("getting home ref - dispatcher");
          >> home = (DispatcherServicesHome)
          >> javax.rmi.PortableRemoteObject.narrow(
          >> obj, DispatcherServicesHome.class);
          >> }
          >> catch (javax.naming.NamingException ne)
          >> {
          >> cat.error(ne);
          >> }
          >>
          >> catch (Exception e)
          >> {
          >> cat.error(e);
          >> };
          >>
          >> try {
          >> cat.debug("home.create - dispatcher");
          >> dispatcher = home.create();
          >> }
          >> catch (javax.ejb.CreateException ce)
          >> {
          >> cat.error(ce);
          >> }
          >> catch (java.rmi.RemoteException re)
          >> {
          >> cat.error(re);
          >> }
          >> catch (Exception e)
          >> {
          >> cat.error(e);
          >> };
          >> }
          >>
          >> protected void getUserManager() {
          >> UserManagerHome home = null;
          >> try {
          >>
          >> if (jndiContext == null)
          >> {
          >> cat.debug("trying to get jndi - usermanager");
          >> jndiContext = getInitialContext(providerURL, icf);
          >> }
          >>
          >> cat.debug("doing lookup - usermanager");
          >> Object obj = jndiContext.lookup("nexterna.UserManager");
          >> cat.debug("getting home ref - usermanager");
          >> home = (UserManagerHome) javax.rmi.PortableRemoteObject.narrow(
          >> obj, UserManagerHome.class);
          >> }
          >> catch (javax.naming.NamingException ne)
          >> {
          >> cat.error(ne);
          >> }
          >>
          >> catch (Exception e)
          >> {
          >> cat.error(e);
          >> };
          >>
          >> try {
          >> cat.debug("home.create - usermanager");
          >> usermgr = home.create();
          >> }
          >> catch (javax.ejb.CreateException ce)
          >> {
          >> cat.error(ce);
          >> }
          >> catch (java.rmi.RemoteException re)
          >> {
          >> cat.error(re);
          >> }
          >> catch (Exception e)
          >> {
          >> cat.error(e);
          >> };
          >> }
          >>
          >> protected boolean getResponseFromDispatch(HttpServletResponse resp,
          >> String id) {
          >>
          >> String s = null;
          >> try {
          >> //before we will export responses to a dispatch, the dispatch
          >> must be complete
          >> s = dispatcher.getDispatchStatusString(id);
          >> }
          >> catch (java.rmi.RemoteException e)
          >> {
          >> cat.error(e);
          >> return true;
          >> }
          >>
          >> if (s.compareToIgnoreCase("Completed") != 0) {
          >> cat.debug("Dispatch status is not COMPLETED. Cannot export
          >> responses");
          >> return true;
          >> }
          >>
          >> resp.setContentType("application/RFC822");
          >> resp.setHeader("Content-Type", "application/RFC822"); // set
          >both
          >> ways to be safe
          >> resp.setHeader("Content-disposition",
          >> "attachment; filename=\"" + id + ".txt\"");
          >> cat.debug("Setting headers");
          >> cat.debug("Content-disposition",
          >> "attachment; filename=\"" + id + ".txt\"");
          >>
          >> HashMap responses = null;
          >> try {
          >> responses = dispatcher.getResponses(id,
          >> DispatcherServices.DISPATCH_ID);
          >> }
          >> catch (java.rmi.RemoteException e)
          >> {
          >> cat.error(e);
          >> return true;
          >> }
          >>
          >> try {
          >> ServletOutputStream os = resp.getOutputStream();
          >> Iterator i = responses.values().iterator();
          >> while (i.hasNext()) {
          >> Object o = i.next();
          >> os.print(o.toString());
          >> cat.debug("Writing XML");
          >> cat.debug(o.toString());
          >> }
          >> os.flush();
          >> os.close();
          >> }
          >> catch (Exception e)
          >> {
          >> cat.error(e);
          >> return true;
          >> }
          >>
          >> return false;
          >> }
          >>
          >
          >
          

Similar Messages

  • URL Manipulation when content-type is application/json (with UAG 2010)

    Hey,
    I got a website published through HTTPS trunk (UAG2010) which works with "application/json" content type at some parts (AJAX objects).
    The parts which use applicaton/json content-type are loaded with a bad URL's on the client side (the internal URLs)
    How can i configure that UAG will manipulate this content-type? (so the HAT mechanism will manipulate these get requests and responses)
    Thank you, Idan.

    Hi Idan,
    We had a similar issue with internal links not being translated for a particular UAG published website. You'll need to run fiddler or httpwatch from a UAG client to identify the failing URL link extension types, eg .jsp and .RF
    Open the trunk configuration, and select the portal tab, click
    edit under Search and Replace Response Content.
    Under Servers, put the fqdn of the web server / publishing address, and under URLs, add the identified extensions.
    We also had to have a custom WhlFiltSecureRemote_HTTPS.xml file created under
    Von\Conf\Websites\%trunk_name%\conf\CustomUpdate
    which included the defined application type for the published website, and tells UAG when to use the search and replace parser.
    Hope that helps.
    http://chrisocallaghan.blogspot.com/

  • Content-type: application/xml and Application server 9

    I have a web service running on Application server 9, implemented using netbeans and JAX-WS.
    When a client sends a request to it with:
    Content-type: application/xml
    the request is rejected because the server does not recognise the mime type.
    Specifically, the response is:
    HTTP/1.1 415 Unsupported Media Type
    X-Powered-By: Servlet/2.5
    Content-Type: text/plain; charset=iso-8859-1
    Date: Fri, 01 Sep 2006 14:49:04 GMT
    Server: Sun Java System Application Server Platform Edition 9.0
    Connection: close
    Everything works fine when the request has:
    Content-type: text/xml
    Is there a way to make my web service accept content type of 'application/xml'?
    -Tony Beaumont
    Aston University
    beaumoaj

    I have fixed this for myself, i.e. decompile, replace in jar.
    My problem was that most tools define the encoding but code was simply testing
    if( contentType.equalsIgnoreCase( "text/xml" ) )
    so sending xml from other tools that send contentType
    "text/xml;encoding=UTF-8" or some such, like soap tools, would mean no XML was seen.
    Is the proper source available for XSQL?

  • Apex_web_service.make_rest_request: Passing parameters and the content type

    Not sure if I am missing something, but should this API be setting the content type (to application/x-www-url-formencoded) when there are values present for the parameters p_parm_name and p_parm_value.
    The example in the docs is to a yahoo API. I'm not sure about that particular one (see: http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_web_service.htm#BABEDJHJ), and I think it requires an appid (yahoo account), so i just went with the example here:
    http://developer.yahoo.com/yql/guide/yql-code-examples.html#yql_php
    If I run the following from a html file on my desktop it works:
    <form method="POST" action="http://query.yahooapis.com/v1/public/yql">
    <input type="hidden" name="q" value="select * from upcoming.events where location='San Francisco' and search_text='dance'"></input>
    <input type="hidden" name="format" value="json"></input>
    <input type="submit"></input>
    </form>That is, it returns a JSON result.
    The raw HTTP data is as follows:
    POST http://query.yahooapis.com/v1/public/yql HTTP/1.1
    Host: query.yahooapis.com
    Connection: keep-alive
    Content-Length: 110
    Cache-Control: max-age=0
    Origin: null
    User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Ubuntu/12.04 Chromium/20.0.1132.47 Chrome/20.0.1132.47 Safari/536.11
    Content-Type: application/x-www-form-urlencoded
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Encoding: gzip,deflate,sdch
    Accept-Language: en-AU,en;q=0.8,en-US;q=0.6
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
    q=select+fromupcoming.events+where+location%3D%27San+Francisco%27+and+search_text%3D%27dance%27&format=json>
    However, running the following returns nothing: (nothing, as in nothing that depends on the parameters passed in)
    set serveroutput on
    declare
    l_c CLOB;
    begin
      l_c := apex_web_service.make_rest_request(
        p_url => 'http://query.yahooapis.com/v1/public/yql',
        p_http_method => 'POST',
        p_parm_name => apex_util.string_to_table('q:format'),
        p_parm_value => apex_util.string_to_table('select * from upcoming.events where location=''San Francisco'' and search_text=''dance'':json'),
        p_proxy_override => 'http://192.168.1.3:8888');
      dbms_output.put_line(substr(l_c, 1, 4000));
    end;Raw HTTP data:
    POST http://query.yahooapis.com/v1/public/yql HTTP/1.1
    Host: query.yahooapis.com
    Connection: Keep-Alive
    Content-Length: 106
    Connection: close
    q=select+%2A+from+upcoming%2Eevents+where+location%3D'San+Francisco'+and+search_text%3D'dance'&format=json>
    I do note a key difference is that content type isn't being set in the web service API.
    This was just to test a public service. I do note that the above has slighty different request data (percentage encoding on some chars). However, I experienced the same behaviour on a procedure I had written (I can also provide this example test case if you like), which is where I first noticed the issue.
    Using utl_http and setting the content type to application/x-www-url-formencoded, does resolve the issue. However, just thought i'd see the possibility of using the Web service API that is made available.
    Is the example in the docs valid, or am I missing something obvious?
    This is on ApEx 4.1 on the OTN Dev Days VM.
    Thoughts?

    Hi trent,
    I too have had issues with this API , so moved forward with UTL_HTTP API.
    There is something amiss.
    If you change your code to the one below it works.
    SET SERVEROUT ON
    declare
    l_c CLOB;
    l_param varchar2(1000) ;
    begin
    l_param := 'select * from upcoming.events where location=''San Francisco'' '||
            ' and search_text=''dance'''||'&'||'format=json';
    l_c := apex_web_service.make_rest_request(
        p_url => 'http://query.yahooapis.com/v1/public/yql?q='||
            utl_url.escape(l_param)
        ,p_http_method => 'POST'
      dbms_output.put_line(substr(l_c, 1, 4000));
    end;
    /Note the use of UTL_URL.ESCAPE. The call does not work without it.
    I do not use a proxy, so that parameter does not feature in my snippet above.
    Cheers,
    PS: However, the below does not work. So, it appears that the p_parm_name and p_parm_value do not quite work.
    SET SERVEROUT ON;
    declare
    l_c CLOB;
    l_param varchar2(1000) ;
    begin
    l_param := 'select * from upcoming.events where location=''San Francisco'' and search_text=''dance''';
    l_c := apex_web_service.make_rest_request(
        p_url => 'http://query.yahooapis.com/v1/public/yql'
        ,p_http_method => 'POST'
        ,p_parm_name => apex_util.string_to_table('q:format')
        ,p_parm_value => apex_util.string_to_table(utl_url.escape(l_param)||':json')
      dbms_output.put_line(substr(l_c, 1, 4000));
    end;
    / Edited by: Prabodh on Oct 13, 2012 2:04 PM

  • Email attachments content-type

    Hi guys,
    I have one process that starts with an email agent. When I send an email with a txt file in attachment the email agent set the content-type to "text/plain" but if i send an email with a lst extension file the email agent set the content-type to "application/octet-stream". I need that the email agent set the content-type "text/plain" to the files with lst extensions.
    BPEL version 10.1.3.5.
    Any idea?
    regards
    Rodrigo Zuchetto
    Edited by: Zuchetto on Feb 11, 2010 3:45 PM

    Hi,
    we don't found the solution for this problem but a workaround that resolve - temporarily - our problem...
    - first we source in different places how to set mimtype content. Unfortunately we don't found were BPEL/SOA take the value to attribute the mimetype of a specific file (we change the mimetype content of operation system - Windows/Linux -, JVM, SOA and others).
    - we discover that MailActivationAgent convert unknown file extensions to application/octect content-type.
    - with this info, we implemented into our BPEL flow a Java Embeded to re-convert the file content (using this reference: ora:readFile returns strange string
    Now we are sourcing for a specific solution: this Java Embeded workaround don't accept setting a different charset. If we have different characters this cause a problem when file are re-converted. But, for now, this workaround resolve our problem.
    Regs,
    EduardoC

  • Weblogic Portal - Disc API bug in response content type

    Hi
    While using WLP Disc APIs in the portal for AJAX calls, the response content type returned by the weblogic portal server is:
    text/x-netuix-json-comment-filtered; charset=ISO-8859-1
    This is not getting changed to 'application/json' inspite of setting this as the content type for a JSF JSP.
    Probably, looks like a bug.
    We have a JSF portlet in which we need to make an AJAX call.
    Please refer to the weblogic whitepaper for the AJAX examples (weblogic-portal-jsf-whitepaper.pdf).
    The example works fine in the dev/build environment. When the portal server is accepting calls through Sun One webserver,
    the logs from the webserver show the response content type from the portal server as "text/x-netuix-json-comment-filtered; charset=ISO-8859-1"
    - I tried changing the content type to "application/json" in the JSF JSP (as per the example from the pdf file). Still the content type does not change.
    - The response from the portal server is suffixed with "\n\r\t". Because of the trailing space/carriage return chars in the portal server response, the sun one webserver is unable to parse (or) eliminate the "\r\n\d" chars to the browser. When the browser receives a response (with the trailing chars), the module.js (weblogic wrapper API for DISC calls) fails.
    - The module.js tries to check whether the response from portal server ends with "**/" but unfortunately, the weblogic protal server returns
    "/** %json response%**/\n\r\d"
    I found a workaround to this issue by having a filter for the JSF JSP which sets the content type as "application/json" and does a flush() before it makes a call to the JSF JSP which responsds to an ajax call. This works as the content type is set and flushed first so any attempt by the portal server to set as "text/x-netuix-json-comment-filtered" does not get reflected in the http response.
    Any support/fix from oracle regarding this will be helpful as most of the webserver integration with the portal server happens during the middle of the project build and might lead to a technical risk.
    Server details: WLPS 10.3, Sun One 7.0
    Thanks
    Ananth Krishnan

    Make sure you're using the Reverse Proxy Plugin for Web Server, not the Application Server Connector (they are VERY similar, but not the same). The RPP knows how to handle 100 Continue, the Connector does not.
    Or use Web Server 7 and its built-in reverse proxy feature.

  • Response Content type for WLP Disc API calls

    Hi
    While using WLP Disc APIs in the portal for AJAX calls, the response content type returned by the weblogic portal server is:
    text/x-netuix-json-comment-filtered; charset=ISO-8859-1
    This is not getting changed to 'application/json' inspite of setting this as the content type for a JSF JSP.
    Probably, looks like a bug.
    We have a JSF portlet in which we need to make an AJAX call.
    Please refer to the weblogic whitepaper for the AJAX examples (weblogic-portal-jsf-whitepaper.pdf).
    The example works fine in the dev/build environment. When the portal server is accepting calls through Sun One webserver,
    the logs from the webserver show the response content type from the portal server as "text/x-netuix-json-comment-filtered; charset=ISO-8859-1"
    - I tried changing the content type to "application/json" in the JSF JSP (as per the example from the pdf file). Still the content type does not change.
    - The response from the portal server is suffixed with "\n\r\t". Because of the trailing space/carriage return chars in the portal server response, the sun one webserver is unable to parse (or) eliminate the "\r\n\d" chars to the browser. When the browser receives a response (with the trailing chars), the module.js (weblogic wrapper API for DISC calls) fails.
    - The module.js tries to check whether the response from portal server ends with "**/" but unfortunately, the weblogic protal server returns
    "/** %json response%**/\n\r\d"
    I found a workaround to this issue by having a filter for the JSF JSP which sets the content type as "application/json" and does a flush() before it makes a call to the JSF JSF which responsds to an ajax call. This works as the content type is set and flushed first so any attempt by the portal server to set as "text/x-netuix-json-comment-filtered" does not get reflected in the http response.
    Any support/fix from oracle regarding this will be helpful as most of the webserver integration with the portal server happens during the middle of the project build and might lead to a technical risk.
    Server details: WLPS 10.3, Sun One 7.0
    Thanks
    Ananth Krishnan

    The problem as you can see is only related to the URL because the webservice is not expecting the URL. Have you changed the wsdl also for the new scenario? The URL can be rechecked to the one present in the wsdl at bottom of it.
    Regards,
    Prateek

  • Sun BPEL engine sets wrong Content-Type on calling an external web service

    I have a WSDL for an external web service (which as it happens is running in Websphere locally) and have implemented it as a
    partnerlink on a BPEL diagram in an SOA composite project. The binding style is Document and if you use SOAPUI to test it it
    works fine. Tracing on the web service's server shows the SOAP request coming in. It has a content-type of text/xml, as expected. If I do a JUnit test from NetBeans based on this WSDL alone it also works - same result. BUT if I do
    a full test and call my BPEL process the invocation of this service from BPEL fails.
    On the Test result you see
    BPCOR-6135:A fault was not handled in the process scope; Fault Name is http://www.sun.com/wsbpel/2.0/process/executable/SUNExtension/ErrorHandling}systemFault;
    (This happens because I did not handle the fault in the BPEL.)
    On the trace I see it now has Content-type of application/xop+xml. Why would the Sun BPEL engine change this? I just
    accepted the usual defaults when I created the PartnerLink and the Invoke. Anyway, the format of the request doesn't match what the WS server expects, so it fails.
    As far as I'm aware I'm just using SOAP1.1. This is NetBeans 6.5 with Glassfish 2.1. I tried with NetBeans 6.7 and it got worse, not better. I would certainly appreciate any advice?
    Thanks

    Perhaps when the BPEL file based process calls the WSDL file to execute,their message communication is not correct.
    the head part in the WSDL file should be manually set to "text/xml", or the IDE or Server will use the default value;
    for example as follow:
    SOAPUI tool would use the default value "text/xml" to request.(depends the tool support).
    NetBeans tool would use the default value "text/xml" to request.
    when you do a full test and you do not set the head "context-type" value ,the WSDL file use the server's default head
    value"application/xop-xml" so that return the contents under the control of the server's default value.
    I hope these will be useful for you.

  • BPEL engine sets wrong Content-Type on calling an external web service

    I have a WSDL for an external web service (which as it happens is running in Websphere locally) and have implemented it as a
    partnerlink on a BPEL diagram in an SOA composite project.
    The binding style is Document and if you use SOAPUI to test it it
    works fine. Tracing on the web service's server shows the SOAP request
    coming in. It has a content-type of text/xml, as expected. If I do a
    JUnit test from NetBeans based on this WSDL alone it also works - same result. BUT if I do
    a full test and call my BPEL process the invocation of this service
    from BPEL fails.
    On the Test result you see
    BPCOR-6135:A fault was not handled in the process scope; Fault Name is http://www.sun.com/wsbpel/2.0/process/executable/SUNExtension/ErrorHandling}systemFault;
    (This happens because I did not handle the fault in the BPEL.)
    On the trace I see it now has Content-type of
    application/xop+xml. Why would the Sun BPEL engine change this? I just
    accepted the usual defaults when I created the PartnerLink and the
    Invoke. Anyway, the format of the request doesn't match what the WS server expects, so it fails.
    As far as I'm aware I'm just using SOAP1.1. This is NetBeans 6.5 with
    Glassfish 2.1. I tried with NetBeans 6.7 and it got worse, not better.
    I would certainly appreciate any advice?
    Thanks

    Perhaps when the BPEL file based process calls the WSDL file to execute,their message communication is not correct.
    the head part in the WSDL file should be manually set to "text/xml", or the IDE or Server will use the default value;
    for example as follow:
    SOAPUI tool would use the default value "text/xml" to request.(depends the tool support).
    NetBeans tool would use the default value "text/xml" to request.
    when you do a full test and you do not set the head "context-type" value ,the WSDL file use the server's default head
    value"application/xop-xml" so that return the contents under the control of the server's default value.
    I hope these will be useful for you.

  • Using Forms that don't set the content type charset

    The Servlet API 2.3 has a new method, request.setCharacterEncoding(), to
              deal with the fact that almost no browsers set the content type. When I call
              this method passing "Shift_JIS" using weblogic 6.1, it works fine when the
              content type is not set by the browser. That is, after calling
              setCharacterEncoding when I call request.getParameter("testparam") I get the
              correct translated value. However, if the content type is
              "application/x-www-form-urlencoded; charset=Shift_JIS" and I call
              request.setCharacterEncoding("Shift_JIS"), getParameter("testparam") returns
              null.
              Can anyone shed some light on this?
              It looks like I'll have to not set the character encoding if it is already
              set. That, of course, opens the possibility that the character set used for
              translation is different than was used in the form.
              Russ Cole
              [email protected]
              

    It might not be the new 3G network. Though I've heard the major metropolitan cities can have slower responses due to congestion.
    Have you upgraded to the new operating system? Have you tried resetting your phone? You can do that by holding the "Home" and "Power" buttons down together, through the shut down screen and until the apple appears on the screen.
    You might also try this:
    http://www.roughlydrafted.com/2010/07/07/how-to-speed-up-your-iphone-3g-running- ios4/
    It's called a cold reboot.
    Sharon

  • Content type in SOAP receiver communication channel

    Hello,
    so far I thought that the SOAP receiver adapter always sets the content type to text/xml. However now I found out the following strange thing:
    If you check the option "without SOAP envelope" then the content type is application/xml. Is there any way to influence this as the receiver of the message only accepts text/xml.
    Have you had any similar experience?

    hi,
    - open SOAP receiver communication channel - module tab
    - add the module "localejbs/AF_Modules/MessageTransformBean" or AF_Modules/MessageTransformBean"  before the standard SOAP module
    - add the parameter = Transform.ContentType with value = text/xml
    I'm just not sure if you need to add value =  text/xml or "text/xml" so try the second one if the first one will not work
    does it work now?
    Regards,
    Michal Krawczyk

  • Cfhttp and setting the content-type for a request

    Hi,
    I am trying to set the content-type for a cfhttp request like this (on coldfusion 9):
    <cfhttp redirect="no" method="get" timeout="120" url="http://10.0.0.1/test2.cfm">
        <cfhttpparam type="HEADER" name="Content-Type" value="application/json; charset=utf-8">
    </cfhttp>
    // coding on test2.cfm:
    <cfset x = GetHttpRequestData()>
    <cfdump var=#x#>
    // Output on test2.cfm
    content
    [empty string]
    headers
    struct
    Accept-Encoding
    deflate, gzip, x-gzip, compress, x-compress
    Connection
    TE
    Host
    10.0.0.1:80
    Proxy-Connection
    close
    TE
    trailers, deflate, gzip, compress
    User-Agent
    ColdFusion
    X-REWRITE-URL
    http://10.0.0.1:80/test2.cfm
    method
    GET
    protocol
    HTTP/1.1
    As you can see no content-type is send through. I also tried the sniffer.exe:
    GET http://10.0.0.1:80/test2.cfm HTTP/1.1
    Host: 127.0.0.1
    Proxy-Connection: close
    Connection: TE
    TE: trailers, deflate, gzip, compress
    User-Agent: ColdFusion
    Accept-Encoding: deflate, gzip, x-gzip, compress, x-compress
    Here you can also see that no content-type was passed through. The sniffer should report back
    GET http://10.0.0.1:80/test2.cfm HTTP/1.1
    Host: 127.0.0.1
    Proxy-Connection: close
    Connection: TE
    TE: trailers, deflate, gzip, compress
    User-Agent: ColdFusion
    Accept-Encoding: deflate, gzip, x-gzip, compress, x-compress
    Content-Type: application/json; charset=utf-8
    But is does not, what do i need todo to set the content-type in a cfhttp request.
    Kind regards,
    Nebu

    12Robots - are you sure about your statement that GET method requests cannot have Content-Type headers?  I don't think that that is correct.  I've always thought that it was valid (maybe unusual, but ...) and this W3C link weems to agree, especially in the context of its comment about what Content-Type means in a HEAD method request: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
    The big problem with trying to get around the CFHTTP limitation by using the CGI scope is that the dash is illegal in a CF varname.
    There is a custom tag called CFHTTP5 that getsaround a lot of the CFHTTP limitations, including cookie preservation across multiple requests.  I haven't used it for a long time (CF5), but it is still actively developed.  Costs $50 - http://www.cftagstore.com/tags/cfxhttp5.cfm
    -reed

  • Content type of .pages file format

    Dear team ,
    please tell me the "contenttype" of the .pages file format....
    example: .doc....is having the content type as "application/ms-word"
    similarly can u tell me content type of .pages
    Regards,
    spradeepkumar

    For Numbers it is:
    kind = "Document Numbers" (localization dependent )
    type identifier = "com.apple.iwork.numbers.sffnumbers"
    For Pages it is:
    kind = "Publication Pages" (localization dependent )
    type identifier = "com.apple.iwork.pages.sffpages"
    For Keynote it is:
    kind = "Keynote Document" ( not sure of localization behavior)
    type identifier:"com.apple.keynote.key"
    grab it with this script after changing the pathname
    set pathName to (choose file) as text
    tell application "System Events"
    get properties of item pathName
    end tell
    Yvan KOENIG (from FRANCE lundi 12 janvier 2009 16:31:07)

  • Content type of .numbers files

    Dear team ,
    please tell me the "contenttype" of the .pages file format....
    example: .doc....is having the content type as "application/ms-word"
    similarly can u tell me content type of .pages
    Regards,
    spradeepkumar

    If the document is a Numbers '09 single file,
    package folder = false
    kind = "Document Numbers" (localization dependant )
    type identifier = "com.apple.iwork.numbers.sffnumbers"
    If the document is a Numbers '08 or 09 package,
    package folder = true
    kind = "Document Numbers" (localization dependant )
    type identifier = "com.apple.iwork.numbers.sffnumbers"
    Yvan KOENIG (from FRANCE lundi 12 janvier 2009 11:06:20)

  • Content type of .key files

    Dear team ,
    please tell me the "contenttype" of the .pages file format....
    example: .doc....is having the content type as "application/ms-word"
    similarly can u tell me content type of .pages
    Regards,
    spradeepkumar

    hi balusC thanks, it works very well.
    your site http://balusc.xs4all.nl/srv/dev-jep-pdf.html helped me a lot.
    But one point. There is another method : URLConnection.guessContentTypeFromStream(InputStream)but it don't work and i receive as result a null.
    Is there another classes/methods which helps getting the content type of a file? not necessarily from sun. thanks
    bye

Maybe you are looking for

  • Adobe Muse install problem April 2014 - Errors encountered during installation (7).

    ERROR: Third party payload installer InstallAdobeMuse.exe failed with exit code: 7 This is the 3rd time that I have lost my Muse installation. Yes, the app just disappeared. Uninstallers cannot find it. A search cannot locate any files. It just disap

  • How to pass an xml file as a command line argument

    hi, i would like to know how to pass xml tags (not an xml file) while running java command. i have already compiled the code and i have a .class file generated. i need to pass this argument in the java command because i am calling a web service which

  • Group and Group counter in Routing

    Hi all, what is group and group counter in routing , how these are used in routing , please explain. Regards, Joseph.

  • Dreamweaver CS5.5 Fluid Grid Layout Help!!!

    Needing help with What a fluid grid layout is, I hear that itll help my webpage be responsive and it will adjust for screen sizes depending on if your on a computer, phone or tablet. Can anyone link me to an Adobe TV tutorial for CS5.5? All I found w

  • Instalation Oracle 8i

    Is there any concern to install Oracle 8i on Windows XP?? I have to install this database version for tests. I have version to linux and windows as well, but I think that install on centos 4 won't any problems. I worry only for install so old databas