Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0010236Openbravo ERPA. Platformpublic2009-08-11 12:552009-10-22 12:00
sgue0065 
iperdomo 
urgentmajoralways
closedfixed 
10XP
main 
pi 
Core
No
0010236: DalWebService.java
In the service-methods a call to

response.setHeader("Content-Encoding", "UTF-8");

is done in several places. This is wrong!

see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 [^] [^]

The setting is used to set for example a compression scheme, but not the character-enconding. Not shure, but what you probably want to do is to set a Content-Transfer-Encoding
Call the rest service not from a browser, but for example from Axis 2. You get an exception upon an unknown "Content-Encoding".

package de.his.appserver.ws.rm.fim;

import java.net.URLEncoder;
import java.util.Iterator;

import javax.xml.namespace.QName;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;

import de.his.core.util.junit.TestOwner;


/**
 * @author GUENTHER
 * @version $Id$
 * Testklasse für Rest-Webservices zwischen OpenBravo und H1
 */
@TestOwner(cvsLogin = "guenther#his.de")
public class OpenBravoRestTest extends junit.framework.TestCase {

    
    /**
     * Store the texts read by NavigationURL
     */
    private String snippet;

    public String searchOpenBravoEntities() {
        try {
            snippet = "";
            String epr = "http://localhost:8080/openbravo/ws/dal?l=Openbravo&p=openbravo"; [^] [^]
            
            ServiceClient client = new ServiceClient();
            Options options = new Options();
            options.setProperty(org.apache.axis2.Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-8");
            options.setProperty(Constants.Configuration.ENABLE_REST, Boolean.TRUE);
            options.setProperty(Constants.Configuration.HTTP_METHOD, Constants.Configuration.HTTP_METHOD_GET);
            options.setProperty(Constants.Configuration.MESSAGE_TYPE,
                org.apache.axis2.transport.http.HTTPConstants.MEDIA_TYPE_TEXT_XML);
            options.setProperty(Constants.Configuration.DISABLE_SOAP_ACTION, Constants.VALUE_TRUE);
            options.setCallTransportCleanup(true);
            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
            options.setTo(new EndpointReference(epr));

            client.setOptions(options);
            
            //if post is through GET of HTTP
            OMElement response = client.sendReceive(null);
            generateSnippet(response);
            return snippet;

        } catch (Exception e) {
            e.printStackTrace();
            snippet = e.getMessage();
        }
        return null;
    }


    private void generateSnippet(OMElement response) {
        String title = null;

        snippet="";
        
        QName qname= new QName("entityName");
        OMElement result = null;
        //get an iterator for Result elements
        Iterator itr = response.getChildElements();
        while (itr.hasNext()) {
            result = (OMElement) itr.next();
            
            
            title=result.getAttributeValue(qname);
            
            snippet += " "+title;
            System.out.println(title);
        }
    }

    
    public void testRestCall(){
        String test=searchOpenBravoEntities();
        System.out.println(snippet);
    }
    
    
}
Quick solution is delete all calls to

response.setHeader("Content-Encoding", "UTF-8");

the bug seems to be introduced after MP1 and is in MP2. it is in the current HEAD or main. I have not tried to do a direct MP3 checkout.
No tags attached.
related to defect 0008652 closed mtaal REST web service doesn't set content type of response for DELETE of specific object 
Issue History
2009-08-11 12:55sgue0065New Issue
2009-08-11 12:55sgue0065Assigned To => rafaroda
2009-08-11 15:03rafarodaAssigned Torafaroda => mtaal
2009-08-11 15:03rafarodaPrioritynormal => urgent
2009-08-11 15:03rafarodaStatusnew => scheduled
2009-08-11 15:57shuehnerRelationship addedrelated to 0008652
2009-08-11 16:59iperdomoAssigned Tomtaal => iperdomo
2009-08-11 18:24hgbotCheckin
2009-08-11 18:24hgbotNote Added: 0018915
2009-08-11 18:24hgbotStatusscheduled => resolved
2009-08-11 18:24hgbotResolutionopen => fixed
2009-08-11 18:24hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/39f9c04554194f996f1f05de8a720d9ee2b4b261 [^]
2009-08-11 18:26iperdomoNote Added: 0018916
2009-08-12 06:47hgbotCheckin
2009-08-12 06:47hgbotNote Added: 0018918
2009-08-12 06:47hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/39f9c04554194f996f1f05de8a720d9ee2b4b261 [^] => http://code.openbravo.com/erp/devel/pi/rev/6e349828535575a39bf28aace886eaf2630aac7d [^]
2009-08-18 09:14sureshbabuStatusresolved => closed
2009-08-18 09:14sureshbabuNote Added: 0018991
2009-08-18 09:14sureshbabuFixed in Version => pi
2009-08-19 00:00anonymoussf_bug_id0 => 2839902
2009-10-22 12:00hgbotCheckin
2009-10-22 12:00hgbotNote Added: 0021321
2009-10-22 12:00hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/6e349828535575a39bf28aace886eaf2630aac7d [^] => http://code.openbravo.com/erp/devel/pi/rev/233482b592541db0ded00ea94371d8f13285e6d9 [^]

Notes
(0018915)
hgbot   
2009-08-11 18:24   
Repository: erp/devel/pi
Changeset: 39f9c04554194f996f1f05de8a720d9ee2b4b261
Author: Iván Perdomo <ivan.perdomo <at> openbravo.com>
Date: Tue Aug 11 18:24:02 2009 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/39f9c04554194f996f1f05de8a720d9ee2b4b261 [^]

Fixes issue 10236: Removed Content-Enconding header, added the charset to the ContentType header

---
M src/org/openbravo/service/rest/DalWebService.java
---
(0018916)
iperdomo   
2009-08-11 18:26   
Added charset to ContentType header [1]

[1] http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletResponse.html#setContentType%28java.lang.String%29 [^]

Iván
(0018918)
hgbot   
2009-08-12 06:47   
Repository: erp/devel/pi
Changeset: 6e349828535575a39bf28aace886eaf2630aac7d
Author: Iván Perdomo <ivan.perdomo <at> openbravo.com>
Date: Wed Aug 12 06:47:02 2009 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/6e349828535575a39bf28aace886eaf2630aac7d [^]

Fixes issue 10236: Changed content type from previous changeset

---
M src/org/openbravo/service/rest/DalWebService.java
---
(0018991)
sureshbabu   
2009-08-18 09:14   
Not able to close this issue (informed to Lujan)
(0021321)
hgbot   
2009-10-22 12:00   
Repository: erp/devel/pi
Changeset: 233482b592541db0ded00ea94371d8f13285e6d9
Author: Martin Taal <martin.taal <at> openbravo.com>
Date: Thu Oct 22 12:00:05 2009 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/233482b592541db0ded00ea94371d8f13285e6d9 [^]

Removed check on contentencoding, not relevant anymore since issue 10236 was solved

---
M src-test/org/openbravo/test/webservice/BaseWSTest.java
---