You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by sa...@locus.apache.org on 2000/07/08 06:05:07 UTC
cvs commit: xml-soap/java/src/org/apache/soap/encoding/soapenc Base64Serializer.java
sanjiva 00/07/07 21:05:07
Modified: java/src/org/apache/soap/encoding SOAPMappingRegistry.java
Added: java/src/org/apache/soap/encoding/soapenc
Base64Serializer.java
Log:
Matt fixed the byte[] encoding to go into a SOAPEnc:binary type
(base64 encoded binary value) instead of the dumb way it was doing
it earlier. Also, SOAPEnc:binary values now decode into byte[].
Matt did all the work; his cvs stuff aint working yet.
Note that this commit forces the use of Xerces 1.1.2 because
the Base64 encoder utility is only in that and not in any previous
version of Xerces.
Submitted by: Matthew Duftler
Reviewed by: Matthew Duftler
Revision Changes Path
1.4 +7 -1 xml-soap/java/src/org/apache/soap/encoding/SOAPMappingRegistry.java
Index: SOAPMappingRegistry.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/SOAPMappingRegistry.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SOAPMappingRegistry.java 2000/07/06 18:19:03 1.3
+++ SOAPMappingRegistry.java 2000/07/08 04:05:06 1.4
@@ -240,7 +240,13 @@
mapTypes(soapEncURI, byteQName, Byte.class, ser, null);
mapTypes(soapEncURI, byteQName, byte.class, ser, deser);
- mapTypes(soapEncURI, null, Vector.class, vectorSer, null);
+ mapTypes(soapEncURI, null, Vector.class, vectorSer, null);
+
+ /*
+ Map a Java byte array to the SOAP-ENC:base64 subtype.
+ */
+ Base64Serializer base64Ser = new Base64Serializer();
+ QName base64QName = new QName(soapEncURI, "base64");
}
/**
1.1 xml-soap/java/src/org/apache/soap/encoding/soapenc/Base64Serializer.java
Index: Base64Serializer.java
===================================================================
package org.apache.soap.encoding.soapenc;
import java.io.*;
import org.w3c.dom.*;
import org.apache.xerces.utils.Base64;
import org.apache.soap.util.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
/**
* A <code>Base64Serializer</code> is used to serialize and deserialize
* byte arrays using the <code>SOAP-ENC</code> encoding style. The byte
* arrays are encoded using the SOAP-ENC:base64 subtype.
*
* @author Matthew J. Duftler (duftler@us.ibm.com)
*/
public class Base64Serializer implements Serializer, Deserializer
{
Base64 b64 = new Base64 ();
public void marshall(String inScopeEncStyle, Class javaType, Object src,
Object context, Writer sink, NSStack nsStack,
XMLJavaMappingRegistry xjmr)
throws IllegalArgumentException, IOException
{
nsStack.pushScope();
byte[] bytes = (byte[])src;
SoapEncUtils.generateStructureHeader(inScopeEncStyle,
javaType,
context,
sink,
nsStack,
xjmr);
sink.write(b64.encode(bytes) + "</" + context + '>');
nsStack.popScope();
}
public Bean unmarshall(String inScopeEncStyle, QName elementType, Node src,
XMLJavaMappingRegistry xjmr)
throws IllegalArgumentException
{
Element root = (Element)src;
String value = DOMUtils.getChildCharacterData(root);
return new Bean(byte[].class, b64.decode(value.getBytes()));
}
}