snichol 2003/06/12 23:23:02
Modified: java/src/org/apache/soap/encoding/soapenc
MimePartSerializer.java
java/src/org/apache/soap/rpc RPCMessage.java
SOAPContext.java
java/src/org/apache/soap/util/mime MimeUtils.java
Log:
Two changes unfortunately committed together.
1. Split from "doc/lit serialization" whether to qualify elements by
namespace, since this is a separate concern in WSDL.
2. Isolate URL encoding and decoding of attachment cids. These *should* be
done using UTF8 encoding, but JDK 1.4 is required to do this without
rolling our own. Problems arise only when a host name has non-ASCII
characters: perhaps munging the host name is the best short term
solution.
Revision Changes Path
1.6 +3 -2 xml-soap/java/src/org/apache/soap/encoding/soapenc/MimePartSerializer.java
Index: MimePartSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/MimePartSerializer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- MimePartSerializer.java 6 Jan 2003 17:57:14 -0000 1.5
+++ MimePartSerializer.java 13 Jun 2003 06:23:02 -0000 1.6
@@ -161,7 +161,7 @@
// Write the URLEncoded reference.
sink.write(' ' + Constants.ATTR_REFERENCE + " =\"cid:"
- + java.net.URLEncoder.encode(cid) + '"');
+ + MimeUtils.encode(cid) + '"');
sink.write("/>");
}
@@ -191,7 +191,8 @@
throw new IllegalArgumentException(
"Attachment tag \"" + paramEl.getTagName()
+ "\" refers to a Mime attachment with label \""
- + uri + "\" which could not be found.");
+ + uri + "\" (" + MimeUtils.decode(uri)
+ + ") which could not be found.");
} else
dh = bp.getDataHandler();
} catch(MessagingException me) {
1.23 +5 -4 xml-soap/java/src/org/apache/soap/rpc/RPCMessage.java
Index: RPCMessage.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/rpc/RPCMessage.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- RPCMessage.java 18 Nov 2002 21:52:06 -0000 1.22
+++ RPCMessage.java 13 Jun 2003 06:23:02 -0000 1.23
@@ -261,20 +261,21 @@
if (!resp.generatedFault()) {
// Get the prefix for the targetObjectURI.
StringWriter nsDeclSW = new StringWriter();
- // TODO: is there a way to specify the URI is now the default namespace?
String targetObjectNSPrefix = nsStack.getPrefixFromURI(
targetObjectURI, nsDeclSW);
sink.write('<');
- if (!ctx.getDocLitSerialization ()) {
+ if (!ctx.getQualifyElements()) {
sink.write(targetObjectNSPrefix);
sink.write(':');
}
sink.write(methodName);
sink.write(suffix);
- if (!ctx.getDocLitSerialization ()) {
+ if (!ctx.getQualifyElements()) {
sink.write(nsDeclSW.toString ());
} else {
+ // Qualify elements by way of a default namespace
+ // TODO: is there a way to specify internally the URI is now the default namespace?
sink.write(" xmlns=\"");
sink.write(targetObjectURI);
sink.write('\"');
@@ -317,7 +318,7 @@
serializeParams(params, actualMsgEncStyle, sink, nsStack, xjmr, ctx);
sink.write("</");
- if (!ctx.getDocLitSerialization ()) {
+ if (!ctx.getQualifyElements()) {
sink.write(targetObjectNSPrefix);
sink.write(':');
}
1.17 +23 -2 xml-soap/java/src/org/apache/soap/rpc/SOAPContext.java
Index: SOAPContext.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/rpc/SOAPContext.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- SOAPContext.java 20 Nov 2002 21:34:42 -0000 1.16
+++ SOAPContext.java 13 Jun 2003 06:23:02 -0000 1.17
@@ -90,6 +90,7 @@
protected boolean docLitSerialization = false;
protected Boolean gzip = null;
protected Boolean acceptGzip = null;
+ protected boolean qualifyElements = false;
protected boolean isRootPartEnvelope = false;
protected String rootPartString = null;
@@ -691,7 +692,8 @@
}
/**
- * Gets whether document/literal style is used in serialization.
+ * Gets whether document/literal style is used in serialization. This
+ * supresses xsi:type and SOAP-ENV:encodingStyle attributes.
*
* @return Whether document/literal style is used in serialization.
*/
@@ -700,7 +702,8 @@
}
/**
- * Sets whether document/literal style is used in serialization.
+ * Sets whether document/literal style is used in serialization. This
+ * supresses xsi:type and SOAP-ENV:encodingStyle attributes.
*
* @param docLitSerialization Whether document/literal style is used in serialization.
*/
@@ -853,6 +856,24 @@
*/
public void setOneWay(boolean oneWay) {
this.oneWay = oneWay;
+ }
+
+ /**
+ * Gets whether elements are qualified in serialization.
+ *
+ * @return Whether elements are qualified in serialization.
+ */
+ public boolean getQualifyElements() {
+ return qualifyElements;
+ }
+
+ /**
+ * Sets whether elements are qualified in serialization.
+ *
+ * @param docLitSerialization Whether elements are qualified in serialization.
+ */
+ public void setQualifyElements(boolean qualifyElements) {
+ this.qualifyElements = qualifyElements;
}
/**
1.7 +10 -18 xml-soap/java/src/org/apache/soap/util/mime/MimeUtils.java
Index: MimeUtils.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/mime/MimeUtils.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MimeUtils.java 14 Nov 2002 16:22:09 -0000 1.6
+++ MimeUtils.java 13 Jun 2003 06:23:02 -0000 1.7
@@ -113,27 +113,19 @@
}
/**
+ * URLEncode string.
+ */
+ public static String encode(String s) {
+ // TODO: for JDK 1.4, use java.net.URLEncoder.encode(s, "UTF8")
+ return java.net.URLEncoder.encode(s);
+ }
+
+ /**
* URLDecode string.
*/
- private static final String hexmap = "0123456789ABCDEF";
public static String decode(String s) {
- StringBuffer ret = new StringBuffer(s.length());
- char c;
- for (int i = 0; i < s.length(); i++) {
- c = s.charAt(i);
- switch(c) {
- case '+':
- ret.append(' ');
- break;
- case '%':
- ret.append((char)((hexmap.indexOf(s.charAt(++i)) << 4)
- + hexmap.indexOf(s.charAt(++i))));
- break;
- default:
- ret.append(c);
- }
- }
- return ret.toString();
+ // TODO: for JDK 1.4, use java.net.URLDecoder.decode(s, "UTF8")
+ return java.net.URLDecoder.decode(s);
}
/**
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.