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 ia...@apache.org on 2004/03/05 06:28:13 UTC
cvs commit: ws-axis/java/src/org/apache/axis Message.java
ias 2004/03/04 21:28:13
Modified: java/src/org/apache/axis Message.java
Log:
Enhanced handling character encoding. In addition, getContentType now supports SOAP 1.2 HTTP binding by "application/soap+xml".
Revision Changes Path
1.109 +38 -3 ws-axis/java/src/org/apache/axis/Message.java
Index: Message.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/Message.java,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -r1.108 -r1.109
--- Message.java 25 Feb 2004 14:02:28 -0000 1.108
+++ Message.java 5 Mar 2004 05:28:13 -0000 1.109
@@ -31,6 +31,8 @@
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPMessage;
+
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
@@ -312,6 +314,18 @@
String contentLocations[] = mimeHeaders.getHeader("Content-Location");
contentLocation = (contentLocations != null)? contentLocations[0] : null;
}
+ if (contentType != null) {
+ int delimiterIndex = contentType.lastIndexOf("charset");
+ if (delimiterIndex > 0) {
+ String charsetPart = contentType.substring(delimiterIndex);
+ int charsetIndex = charsetPart.indexOf('=');
+ String charset = charsetPart.substring(charsetIndex + 1).trim();
+ try {
+ setProperty(SOAPMessage.CHARACTER_SET_ENCODING, charset);
+ } catch (SOAPException e) {
+ }
+ }
+ }
// Try to construct an AttachmentsImpl object for attachment
// functionality.
// If there is no org.apache.axis.attachments.AttachmentsImpl class,
@@ -448,7 +462,28 @@
}
}
- String ret = sc.getContentType() + "; charset="+XMLUtils.getEncoding().toLowerCase();
+ // The origional logic is very simple
+ // String ret = sc.getContentType() + "; charset="+XMLUtils.getEncoding().toLowerCase();
+ // The following logic is devised to utilize CHARACTER_SET_ENCODING property from SAAJ 1.2.
+ String encoding = null;
+ try {
+ encoding = (String) getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
+ } catch (SOAPException e) {
+ }
+ if (encoding == null) {
+ encoding = XMLUtils.getEncoding().toLowerCase();
+ }
+
+ String ret = sc.getContentType() + "; charset=" + encoding;
+
+ // Support of SOAP 1.2 HTTP binding
+ SOAPEnvelope envelope = getSOAPEnvelope();
+ if (envelope != null) {
+ if (envelope.getSOAPConstants() == SOAPConstants.SOAP12_CONSTANTS) {
+ ret = "application/soap+xml; charset=" + encoding;
+ }
+ }
+
if (mAttachments != null && 0 != mAttachments.getAttachmentCount()) {
ret = mAttachments.getContentType();
}
@@ -491,7 +526,7 @@
//Do it the old fashion way.
if (mAttachments == null || 0 == mAttachments.getAttachmentCount()) {
try {
- String charEncoding = (String)getProperty(CHARACTER_SET_ENCODING);
+ String charEncoding = (String)getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
if(charEncoding == null){
charEncoding = "UTF-8";
}
@@ -499,7 +534,7 @@
writer = new BufferedWriter(writer);
// write the xml declaration header
- String incXMLDecl = (String)getProperty(super.WRITE_XML_DECLARATION);
+ String incXMLDecl = (String)getProperty(SOAPMessage.WRITE_XML_DECLARATION);
if(incXMLDecl == null){
incXMLDecl = "false";
}