You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by su...@apache.org on 2007/06/05 07:57:55 UTC
svn commit: r544393 - in /webservices/axis2/trunk/java/modules/saaj:
src/org/apache/axis2/saaj/SOAPPartImpl.java
test-resources/soap-part-iso-8859-1.xml
test/org/apache/axis2/saaj/integration/IntegrationTest.java
Author: sumedha
Date: Mon Jun 4 22:57:54 2007
New Revision: 544393
URL: http://svn.apache.org/viewvc?view=rev&rev=544393
Log:
Fix for AXIS2-2505, honouring character set encoding of the message
Added:
webservices/axis2/trunk/java/modules/saaj/test-resources/soap-part-iso-8859-1.xml
Modified:
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java
webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java?view=diff&rev=544393&r1=544392&r2=544393
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java Mon Jun 4 22:57:54 2007
@@ -119,6 +119,10 @@
}
soapMessage = parentSoapMsg;
+ String knownEncoding = (String) soapMessage.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
+ XMLStreamReader xmlReader = null;
+
+
InputStream modifiedInputStream = null;
StAXSOAPModelBuilder builder = null;
InputStreamReader isReader = null;
@@ -129,7 +133,8 @@
Attachments attachments =
new Attachments(inputStream, fullContentTypeStr, false, "", "");
modifiedInputStream = attachments.getSOAPPartInputStream();
- isReader = new InputStreamReader(modifiedInputStream);
+ isReader = new InputStreamReader(modifiedInputStream);
+
String soapEnvelopeNamespaceURI =
BuilderUtil.getEnvelopeNamespace(fullContentTypeStr);
@@ -173,23 +178,30 @@
modifiedInputStream = inputStream;
try {
isReader = new InputStreamReader(modifiedInputStream);
+ XMLStreamReader streamReader = null;
+
+ if(knownEncoding != null){
+ streamReader = StAXUtils.createXMLStreamReader(modifiedInputStream, knownEncoding);
+ }else{
+ streamReader = StAXUtils.createXMLStreamReader(modifiedInputStream);
+ }
if (HTTPConstants.MEDIA_TYPE_TEXT_XML.equals(contentType)) {
- builder = new StAXSOAPModelBuilder(StAXUtils.createXMLStreamReader(isReader),
+ builder = new StAXSOAPModelBuilder(streamReader,
new SOAP11Factory(),
SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
} else if (HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML.equals(contentType)) {
- builder = new StAXSOAPModelBuilder(StAXUtils.createXMLStreamReader(isReader),
+ builder = new StAXSOAPModelBuilder(streamReader,
new SOAP12Factory(),
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
} else if (HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED.equals(contentType)) {
- builder = new StAXSOAPModelBuilder(StAXUtils.createXMLStreamReader(isReader),
+ builder = new StAXSOAPModelBuilder(streamReader,
new SOAP11Factory(),
null);
} else {
- builder = new StAXSOAPModelBuilder(StAXUtils.createXMLStreamReader(isReader),
+ builder = new StAXSOAPModelBuilder(streamReader,
new SOAP11Factory(),
null);
}
@@ -204,7 +216,7 @@
envelope.element.build();
this.document = envelope.getOwnerDocument();
javax.xml.transform.Source xmlSource =
- new javax.xml.transform.stream.StreamSource(isReader);
+ new javax.xml.transform.stream.StreamSource( isReader);
this.source = xmlSource;
} catch (Exception e) {
throw new SOAPException(e);
Added: webservices/axis2/trunk/java/modules/saaj/test-resources/soap-part-iso-8859-1.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test-resources/soap-part-iso-8859-1.xml?view=auto&rev=544393
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test-resources/soap-part-iso-8859-1.xml (added)
+++ webservices/axis2/trunk/java/modules/saaj/test-resources/soap-part-iso-8859-1.xml Mon Jun 4 22:57:54 2007
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <soapenv:Header>
+ <pref:Header1 xmlns:pref="http://test.apach.org/test">This is header1</pref:Header1>
+ </soapenv:Header>
+ <soapenv:Body>
+ <swa2:echo xmlns:swa2="http://fakeNamespace2.org">
+ <something>This is some text.Here are some special chars : öÆÚ®¤</something>
+ </swa2:echo>
+ </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file
Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java?view=diff&rev=544393&r1=544392&r2=544393
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java Mon Jun 4 22:57:54 2007
@@ -28,6 +28,7 @@
import javax.xml.namespace.QName;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.MessageFactory;
+import javax.xml.soap.MimeHeaders;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
@@ -43,6 +44,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Iterator;
@@ -312,4 +314,33 @@
final SOAPElement ele2 = bodyElement2.addChildElement(ns4);
ele2.addTextNode("This is another text");
}
+
+
+ public void testSendReceive_ISO88591_EncodedSOAPMessage() {
+ try{
+ MimeHeaders mimeHeaders = new MimeHeaders();
+ mimeHeaders.addHeader("Content-Type", "text/xml; charset=iso-8859-1");
+
+ FileInputStream fileInputStream = new FileInputStream(System.getProperty("basedir", ".") +
+ "/test-resources" + File.separator + "soap-part-iso-8859-1.xml");
+ SOAPMessage requestMessage = MessageFactory.newInstance().createMessage(mimeHeaders,fileInputStream);
+
+
+ SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
+ SOAPMessage response = sCon.call(requestMessage, getAddress());
+ assertFalse(response.getAttachments().hasNext());
+ assertEquals(0, response.countAttachments());
+
+ printSOAPMessage(requestMessage);
+ String responseStr = printSOAPMessage(response);
+ assertTrue(responseStr.indexOf("This is some text.Here are some special chars : öÃî¤") != -1);
+ assertTrue(responseStr.indexOf("echo") != -1);
+ sCon.close();
+ } catch (SOAPException e) {
+ e.printStackTrace();
+ fail("Unexpected Exception while running test: " + e);
+ } catch (IOException e) {
+ fail("Unexpected Exception while running test: " + e);
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org