Return-Path: Delivered-To: apmail-synapse-user-archive@www.apache.org Received: (qmail 98095 invoked from network); 16 Dec 2008 11:21:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Dec 2008 11:21:42 -0000 Received: (qmail 37483 invoked by uid 500); 16 Dec 2008 11:21:54 -0000 Delivered-To: apmail-synapse-user-archive@synapse.apache.org Received: (qmail 37429 invoked by uid 500); 16 Dec 2008 11:21:54 -0000 Mailing-List: contact user-help@synapse.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@synapse.apache.org Delivered-To: mailing list user@synapse.apache.org Received: (qmail 37417 invoked by uid 99); 16 Dec 2008 11:21:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Dec 2008 03:21:54 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of razuprogramista@gmail.com designates 209.85.218.20 as permitted sender) Received: from [209.85.218.20] (HELO mail-bw0-f20.google.com) (209.85.218.20) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Dec 2008 11:21:39 +0000 Received: by bwz13 with SMTP id 13so10373248bwz.3 for ; Tue, 16 Dec 2008 03:21:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=1X3HoT7PRhyAwUg4gDDQhDcrAPMDCJ0z52G8JhAOl7w=; b=Bwvb50QhEz2TETE9JL84UPwlmdwmGGRxmpwTjsel4LoIlxo6XJD8WWOXXDlYdvbmXN pgjtkG/EklW2uZeFHsnoMbfSf6cMXGsLQWELocGf2/mZ4I/pCeOj1KdrY6ZSK7cXVKvV 7j6RNq2I6BxOtVav7S/ewqawV6uuFSNR6XJd8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=YJOA3vblEEWi5XqT0YTE7p0CfeKleclmpKdzV3pElHAo6LWv0PA3jOna2CxKHikyyw L3uN6Mm3Ma1Z3yn/DMCsn2vL524ww+lgUPKt9ZkpZOroGxsP77/1EiJ/xp6oCRGcH/tl Dq1BslsuIQL8EME2JNARsBPb1vBcPcBRIHX1g= Received: by 10.181.37.6 with SMTP id p6mr2917897bkj.29.1229426478607; Tue, 16 Dec 2008 03:21:18 -0800 (PST) Received: by 10.181.235.6 with HTTP; Tue, 16 Dec 2008 03:21:18 -0800 (PST) Message-ID: <2cf11e620812160321s518296c6u7eea1c2516b6f7a2@mail.gmail.com> Date: Tue, 16 Dec 2008 12:21:18 +0100 From: "zimny rado" To: user@synapse.apache.org Subject: Re: REST needs XML header In-Reply-To: <49471A7F.7030204@apache.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_35208_2489678.1229426478603" References: <2cf11e620812150256l5f8c7aackd4333c132412a1ef@mail.gmail.com> <49471A7F.7030204@apache.org> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_35208_2489678.1229426478603 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello Asankha, I have done your proposed solution, but another problem arrived, this is my ApplicationXMLFormatter class: package razu.synapse; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMOutputFormat; import org.apache.axiom.soap.SOAP11Constants; import org.apache.axiom.soap.SOAP12Constants; import org.apache.axiom.soap.SOAPFault; import org.apache.axiom.soap.SOAPFaultDetail; import org.apache.axis2.AxisFault; import org.apache.axis2.Constants; import org.apache.axis2.context.MessageContext; import org.apache.axis2.transport.MessageFormatter; import org.apache.axis2.transport.http.util.URLTemplatingUtil; import org.apache.axis2.util.JavaUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.xml.stream.XMLStreamException; import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.URL; public class ApplicationXMLFormatter extends org.apache.axis2.transport.http.ApplicationXMLFormatter { private static final Log log = LogFactory.getLog(ApplicationXMLFormatter.class); @Override public void writeTo(MessageContext messageContext, OMOutputFormat format, OutputStream outputStream, boolean preserve) throws AxisFault { if (log.isDebugEnabled()) { log.debug("start writeTo()"); } try { OMElement omElement = null; if (messageContext.getFLOW() == MessageContext.OUT_FAULT_FLOW) { SOAPFault fault = messageContext.getEnvelope().getBody() .getFault(); SOAPFaultDetail soapFaultDetail = fault.getDetail(); if (soapFaultDetail != null) { omElement = soapFaultDetail.getFirstElement(); } if (omElement == null) { omElement = fault.getReason(); } } else { omElement = messageContext.getEnvelope().getBody() .getFirstElement(); } if (omElement != null) { try { PrintWriter out = new PrintWriter(new OutputStreamWriter(outputStream)); out.println(""); if (preserve) { omElement.serialize(outputStream, format); } else { omElement.serializeAndConsume(outputStream, format); } } catch (XMLStreamException e) { throw AxisFault.makeFault(e); } catch (FileNotFoundException ex) { ex.printStackTrace(); } } try { outputStream.flush(); } catch (IOException e) { throw AxisFault.makeFault(e); } } finally { if (log.isDebugEnabled()) { log.debug("end writeTo()"); } } } } This is rewrited method from original ApplicationXMLFormatter, I only added PrintWriter out = new PrintWriter(new OutputStreamWriter(outputStream)); out.println(""); I created JAR with this class and copy it to /lib directory Another thing to do was change axis2.xml : ... ... My class is used by Apache Synapse, but output XML is still without XML header. Have you any idea what I done wrong? 2008/12/16 Asankha C. Perera > Hi Zimny > >> ... >> >> RAZU >> >> ... >> >> and only RAZU is send to extenal service, but I need to send: >> >> >> RAZU >> >> What is your suggestions? >> >> > Usually the XML declaration is not sent, nor expected.. One solution is to > extend the message formatter to include the declaration.. > > cheers > asankha > > -- > Asankha C. Perera > http://adroitlogic.org > > http://esbmagic.blogspot.com > > ------=_Part_35208_2489678.1229426478603--