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 sn...@apache.org on 2002/08/30 23:39:01 UTC
cvs commit: xml-soap/java/src/org/apache/soap/server TypeMappingSerializer.java
snichol 2002/08/30 14:39:01
Modified: java/docs changes.html
java/samples/addressbook2 AddressSerializer.java
PhoneSerializer.java
java/samples/bidbuy/shared AddressSerializer.java
LineItemSerializer.java
PurchaseOrderSerializer.java ServiceSerializer.java
java/samples/interop DataSerializer.java
java/samples/stringarray StringArray.java
java/src/org/apache/soap/encoding SOAPMappingRegistry.java
java/src/org/apache/soap/encoding/soapenc
ArraySerializer.java Base64Serializer.java
BeanSerializer.java CalendarSerializer.java
DateSerializer.java HashtableSerializer.java
MimePartSerializer.java ParameterSerializer.java
SoapEncUtils.java VectorSerializer.java
java/src/org/apache/soap/rpc Call.java RPCMessage.java
SOAPContext.java
java/src/org/apache/soap/server TypeMappingSerializer.java
Added: java/samples/doclit Add.java README
Log:
Add a document/literal serialization option. This is intended for use
by SOAP clients that need to communicate with services that use
document/literal encoding. Parameters will be serialized using document/literal
style. Return values must be mapped by parameter name (the existing
interop hack).
Revision Changes Path
1.43 +6 -1 xml-soap/java/docs/changes.html
Index: changes.html
===================================================================
RCS file: /home/cvs/xml-soap/java/docs/changes.html,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- changes.html 30 Aug 2002 03:22:54 -0000 1.42
+++ changes.html 30 Aug 2002 21:38:59 -0000 1.43
@@ -68,7 +68,12 @@
<li>Support valid XML namespace constructs in deployment descriptor
mappings for Microsoft interop, e.g. it is now legal to specify
<code>qname="inputInteger"</code> rather than the invalid construct
- <code>xmlns:x="" qname="x:inputInteger"</code>.
+ <code>xmlns:x="" qname="x:inputInteger"</code>.</li>
+ <li>Add a document/literal serialization option. This is intended for use
+ by SOAP clients that need to communicate with services that use
+ document/literal encoding. Parameters will be serialized using document/literal
+ style. Return values must be mapped by parameter name (the existing
+ interop hack).</li>
</ul>
</li>
</ul>
1.3 +1 -1 xml-soap/java/samples/addressbook2/AddressSerializer.java
Index: AddressSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/samples/addressbook2/AddressSerializer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AddressSerializer.java 17 May 2001 21:23:58 -0000 1.2
+++ AddressSerializer.java 30 Aug 2002 21:38:59 -0000 1.3
@@ -18,7 +18,7 @@
nsStack.pushScope();
SoapEncUtils.generateStructureHeader(inScopeEncStyle, javaType, context,
- sink, nsStack, xjmr);
+ sink, nsStack, xjmr, ctx);
sink.write(StringUtils.lineSeparator);
1.3 +1 -1 xml-soap/java/samples/addressbook2/PhoneSerializer.java
Index: PhoneSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/samples/addressbook2/PhoneSerializer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PhoneSerializer.java 17 May 2001 21:23:59 -0000 1.2
+++ PhoneSerializer.java 30 Aug 2002 21:38:59 -0000 1.3
@@ -18,7 +18,7 @@
nsStack.pushScope();
SoapEncUtils.generateStructureHeader(inScopeEncStyle, javaType, context,
- sink, nsStack, xjmr);
+ sink, nsStack, xjmr, ctx);
sink.write(StringUtils.lineSeparator);
1.2 +2 -1 xml-soap/java/samples/bidbuy/shared/AddressSerializer.java
Index: AddressSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/samples/bidbuy/shared/AddressSerializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddressSerializer.java 25 May 2001 19:04:35 -0000 1.1
+++ AddressSerializer.java 30 Aug 2002 21:38:59 -0000 1.2
@@ -26,7 +26,8 @@
context,
sink,
nsStack,
- xjmr);
+ xjmr,
+ ctx);
sink.write(StringUtils.lineSeparator);
1.2 +2 -1 xml-soap/java/samples/bidbuy/shared/LineItemSerializer.java
Index: LineItemSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/samples/bidbuy/shared/LineItemSerializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LineItemSerializer.java 25 May 2001 19:04:35 -0000 1.1
+++ LineItemSerializer.java 30 Aug 2002 21:38:59 -0000 1.2
@@ -27,7 +27,8 @@
context,
sink,
nsStack,
- xjmr);
+ xjmr,
+ ctx);
sink.write(StringUtils.lineSeparator);
1.2 +2 -1 xml-soap/java/samples/bidbuy/shared/PurchaseOrderSerializer.java
Index: PurchaseOrderSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/samples/bidbuy/shared/PurchaseOrderSerializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PurchaseOrderSerializer.java 25 May 2001 19:04:35 -0000 1.1
+++ PurchaseOrderSerializer.java 30 Aug 2002 21:38:59 -0000 1.2
@@ -27,7 +27,8 @@
context,
sink,
nsStack,
- xjmr);
+ xjmr,
+ ctx);
sink.write(StringUtils.lineSeparator);
1.2 +2 -1 xml-soap/java/samples/bidbuy/shared/ServiceSerializer.java
Index: ServiceSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/samples/bidbuy/shared/ServiceSerializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServiceSerializer.java 25 May 2001 19:04:35 -0000 1.1
+++ ServiceSerializer.java 30 Aug 2002 21:38:59 -0000 1.2
@@ -26,7 +26,8 @@
context,
sink,
nsStack,
- xjmr);
+ xjmr,
+ ctx);
sink.write(StringUtils.lineSeparator);
1.1 xml-soap/java/samples/doclit/Add.java
Index: Add.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "SOAP" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2000, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package samples.doclit;
import java.io.*;
import java.util.*;
import java.net.*;
import org.w3c.dom.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.encoding.*;
import org.apache.soap.encoding.soapenc.*;
import org.apache.soap.rpc.*;
/**
* See \samples\doclit\readme for info.
*
* @author Scott Nichol (snichol@computer.org)
*/
public class Add {
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("Usage:");
System.err.println(" java " + Add.class.getName() +
" number1 number2");
System.exit(1);
}
// Process the arguments.
String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
Float number1 = new Float(args[0]);
Float number2 = new Float(args[1]);
// Map the types.
SOAPMappingRegistry smr = new SOAPMappingRegistry();
FloatDeserializer deser = new FloatDeserializer();
smr.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName("http://www.xml-webservices.net/services/maths", "AddResult"),
null, null, deser);
// Build the call.
Call call = new Call();
call.setSOAPMappingRegistry(smr);
call.setTargetObjectURI("http://www.xml-webservices.net/services/maths");
call.setMethodName("Add");
call.setEncodingStyleURI(encodingStyleURI);
call.setDocLitSerialization(true);
Vector params = new Vector();
params.addElement(new Parameter("a", Float.class, number1, null));
params.addElement(new Parameter("b", Float.class, number2, null));
call.setParams(params);
// Invoke the call.
URL url = new URL("http://www.xml-webservices.net/services/maths/calculator.asmx");
// For TcpTunnelGui testing.
// URL url = new URL("http://localhost:81/services/maths/calculator.asmx");
String soapAction = "http://www.xml-webservices.net/services/maths/Add";
Response resp;
try {
resp = call.invoke(url, soapAction);
} catch (SOAPException e) {
System.err.println("Caught SOAPException (" +
e.getFaultCode() + "): " +
e.getMessage());
return;
}
// Check the response.
if (!resp.generatedFault()) {
Parameter ret = resp.getReturnValue();
Object value = ret.getValue();
System.out.println(number1 + "+" + number2 + "=" + (value != null ? value : "null"));
} else {
Fault fault = resp.getFault();
System.err.println("Generated fault: " + fault);
}
}
}
1.1 xml-soap/java/samples/doclit/README
Index: README
===================================================================
Service:
-------
There is no service for this example. It is hard-coded to access a service
endpoint of http://www.xml-webservices.net/services/maths/calculator.asmx.
Client:
------
java samples.doclit.Add number1 number2
Additional Client Classpath Requirements:
----------------------------------------
../..
Explanation:
-----------
This is a sample of using document/literal encoding on the client. Setting
docLitSerialization to true for the Call object forces doc/lit serialization.
To read the return value, de-serializers must be mapped for each name being
returned.
Sample Usage:
------------
java samples.doclit.Add 5 10
1.2 +6 -2 xml-soap/java/samples/interop/DataSerializer.java
Index: DataSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/samples/interop/DataSerializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DataSerializer.java 11 May 2001 19:06:34 -0000 1.1
+++ DataSerializer.java 30 Aug 2002 21:38:59 -0000 1.2
@@ -89,7 +89,9 @@
javaType,
context,
sink,
- nsStack,xjmr);
+ nsStack,
+ xjmr,
+ ctx);
sink.write(StringUtils.lineSeparator);
@@ -111,7 +113,9 @@
javaType,
context,
sink,
- nsStack,xjmr);
+ nsStack,
+ xjmr,
+ ctx);
}
nsStack.popScope();
}
1.2 +1 -0 xml-soap/java/samples/stringarray/StringArray.java
Index: StringArray.java
===================================================================
RCS file: /home/cvs/xml-soap/java/samples/stringarray/StringArray.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StringArray.java 29 Jul 2002 17:32:21 -0000 1.1
+++ StringArray.java 30 Aug 2002 21:39:00 -0000 1.2
@@ -62,6 +62,7 @@
import org.apache.soap.util.xml.*;
/**
+ * @author Scott Nichol (snichol@computer.org)
*/
public class StringArray
{
1.30 +8 -4 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.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- SOAPMappingRegistry.java 29 Aug 2002 03:33:44 -0000 1.29
+++ SOAPMappingRegistry.java 30 Aug 2002 21:39:00 -0000 1.30
@@ -255,8 +255,9 @@
if (src == null)
{
+ // TODO: should simple types ever serialize a nil?
SoapEncUtils.generateNullStructure(inScopeEncStyle, javaType, context,
- sink, nsStack, xjmr);
+ sink, nsStack, xjmr, ctx);
}
else
{
@@ -265,7 +266,8 @@
context,
sink,
nsStack,
- xjmr);
+ xjmr,
+ ctx);
sink.write(Utils.cleanString(src.toString()) + "</" + context + '>');
}
@@ -288,8 +290,9 @@
if (src == null)
{
+ // TODO: should simple types ever serialize a nil?
SoapEncUtils.generateNullStructure(inScopeEncStyle, javaType, context,
- sink, nsStack, xjmr);
+ sink, nsStack, xjmr, ctx);
}
else
{
@@ -298,7 +301,8 @@
context,
sink,
nsStack,
- xjmr);
+ xjmr,
+ ctx);
sink.write(src + "</" + context + '>');
}
1.12 +3 -1 xml-soap/java/src/org/apache/soap/encoding/soapenc/ArraySerializer.java
Index: ArraySerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/ArraySerializer.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ArraySerializer.java 28 Aug 2002 18:13:10 -0000 1.11
+++ ArraySerializer.java 30 Aug 2002 21:39:00 -0000 1.12
@@ -97,6 +97,7 @@
sink,
nsStack,
xjmr,
+ ctx,
elementType,
lengthStr);
}
@@ -108,6 +109,7 @@
sink,
nsStack,
xjmr,
+ ctx,
elementType,
lengthStr);
@@ -124,7 +126,7 @@
if (value == null)
{
SoapEncUtils.generateNullStructure(inScopeEncStyle, componentType,
- "item", sink, nsStack, xjmr);
+ "item", sink, nsStack, xjmr, ctx);
}
else
{
1.7 +4 -2 xml-soap/java/src/org/apache/soap/encoding/soapenc/Base64Serializer.java
Index: Base64Serializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/Base64Serializer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Base64Serializer.java 6 Feb 2001 16:19:30 -0000 1.6
+++ Base64Serializer.java 30 Aug 2002 21:39:00 -0000 1.7
@@ -32,7 +32,8 @@
context,
sink,
nsStack,
- xjmr);
+ xjmr,
+ ctx);
}
else
{
@@ -41,7 +42,8 @@
context,
sink,
nsStack,
- xjmr);
+ xjmr,
+ ctx);
sink.write(Base64.encode(bytes) + "</" + context + '>');
}
1.8 +2 -1 xml-soap/java/src/org/apache/soap/encoding/soapenc/BeanSerializer.java
Index: BeanSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/BeanSerializer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- BeanSerializer.java 28 Jun 2002 02:33:16 -0000 1.7
+++ BeanSerializer.java 30 Aug 2002 21:39:00 -0000 1.8
@@ -89,7 +89,8 @@
context,
sink,
nsStack,
- xjmr);
+ xjmr,
+ ctx);
sink.write(StringUtils.lineSeparator);
1.3 +6 -2 xml-soap/java/src/org/apache/soap/encoding/soapenc/CalendarSerializer.java
Index: CalendarSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/CalendarSerializer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CalendarSerializer.java 24 Sep 2001 20:36:04 -0000 1.2
+++ CalendarSerializer.java 30 Aug 2002 21:39:00 -0000 1.3
@@ -109,7 +109,9 @@
javaType,
context,
sink,
- nsStack,xjmr);
+ nsStack,
+ xjmr,
+ ctx);
Date calDate = ((GregorianCalendar)src).getTime();
String fdate = null;
@@ -128,7 +130,9 @@
javaType,
context,
sink,
- nsStack,xjmr);
+ nsStack,
+ xjmr,
+ ctx);
}
nsStack.popScope();
}
1.5 +6 -2 xml-soap/java/src/org/apache/soap/encoding/soapenc/DateSerializer.java
Index: DateSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/DateSerializer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DateSerializer.java 24 Sep 2001 20:36:04 -0000 1.4
+++ DateSerializer.java 30 Aug 2002 21:39:00 -0000 1.5
@@ -106,7 +106,9 @@
javaType,
context,
sink,
- nsStack,xjmr);
+ nsStack,
+ xjmr,
+ ctx);
String fdate=null;
@@ -124,7 +126,9 @@
javaType,
context,
sink,
- nsStack,xjmr);
+ nsStack,
+ xjmr,
+ ctx);
}
nsStack.popScope();
}
1.3 +5 -3 xml-soap/java/src/org/apache/soap/encoding/soapenc/HashtableSerializer.java
Index: HashtableSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/HashtableSerializer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HashtableSerializer.java 6 Sep 2001 20:34:17 -0000 1.2
+++ HashtableSerializer.java 30 Aug 2002 21:39:00 -0000 1.3
@@ -94,7 +94,8 @@
context,
sink,
nsStack,
- xjmr);
+ xjmr,
+ ctx);
}
else if (src instanceof Hashtable)
{
@@ -103,7 +104,8 @@
context,
sink,
nsStack,
- xjmr);
+ xjmr,
+ ctx);
sink.write(StringUtils.lineSeparator);
@@ -126,7 +128,7 @@
{
SoapEncUtils.generateNullStructure(Constants.NS_URI_SOAP_ENC,
Object.class, STR_VALUE, sink,
- nsStack, xjmr);
+ nsStack, xjmr, ctx);
}
else
{
1.4 +1 -1 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MimePartSerializer.java 6 Sep 2001 20:47:28 -0000 1.3
+++ MimePartSerializer.java 30 Aug 2002 21:39:00 -0000 1.4
@@ -104,7 +104,7 @@
if (src == null) {
SoapEncUtils.generateNullStructure(inScopeEncStyle, Object.class,
- null, sink, nsStack, xjmr);
+ null, sink, nsStack, xjmr, ctx);
} else {
// get a MimeBodyPart out of the various possible input types
DataSource ds = null;
1.14 +3 -1 xml-soap/java/src/org/apache/soap/encoding/soapenc/ParameterSerializer.java
Index: ParameterSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/ParameterSerializer.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ParameterSerializer.java 22 Jul 2002 21:20:39 -0000 1.13
+++ ParameterSerializer.java 30 Aug 2002 21:39:00 -0000 1.14
@@ -94,8 +94,10 @@
if (value == null && !type.isArray())
{
+ // TODO: is it correct to generate nil for simple types?
+ // Should each serialization need to handle this case itself?
SoapEncUtils.generateNullStructure(inScopeEncStyle, type, context,
- sink, nsStack, xjmr);
+ sink, nsStack, xjmr, ctx);
}
else
{
1.16 +63 -9 xml-soap/java/src/org/apache/soap/encoding/soapenc/SoapEncUtils.java
Index: SoapEncUtils.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/SoapEncUtils.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- SoapEncUtils.java 28 Jun 2002 13:06:14 -0000 1.15
+++ SoapEncUtils.java 30 Aug 2002 21:39:00 -0000 1.16
@@ -61,6 +61,7 @@
import org.w3c.dom.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
+import org.apache.soap.rpc.SOAPContext;
/**
* These static methods can be used to do much of the repetitive and
@@ -75,23 +76,25 @@
public static void generateNullStructure(String inScopeEncStyle,
Class javaType, Object context,
Writer sink, NSStack nsStack,
- XMLJavaMappingRegistry xjmr)
+ XMLJavaMappingRegistry xjmr,
+ SOAPContext ctx)
throws IllegalArgumentException, IOException
{
generateStructureHeader(inScopeEncStyle, javaType, context, sink,
- nsStack, xjmr, null, null, true);
+ nsStack, xjmr, ctx, null, null, true);
}
public static void generateNullArray(String inScopeEncStyle,
Class javaType, Object context,
Writer sink, NSStack nsStack,
XMLJavaMappingRegistry xjmr,
+ SOAPContext ctx,
QName arrayElementType,
String arrayLengthStr)
throws IllegalArgumentException, IOException
{
generateStructureHeader(inScopeEncStyle, javaType, context, sink,
- nsStack, xjmr, arrayElementType, arrayLengthStr,
+ nsStack, xjmr, ctx, arrayElementType, arrayLengthStr,
true);
}
@@ -99,29 +102,32 @@
Class javaType, Object context,
Writer sink, NSStack nsStack,
XMLJavaMappingRegistry xjmr,
+ SOAPContext ctx,
QName arrayElementType,
String arrayLengthStr)
throws IllegalArgumentException, IOException
{
generateStructureHeader(inScopeEncStyle, javaType, context, sink,
- nsStack, xjmr, arrayElementType, arrayLengthStr,
+ nsStack, xjmr, ctx, arrayElementType, arrayLengthStr,
false);
}
public static void generateStructureHeader(String inScopeEncStyle,
Class javaType, Object context,
Writer sink, NSStack nsStack,
- XMLJavaMappingRegistry xjmr)
+ XMLJavaMappingRegistry xjmr,
+ SOAPContext ctx)
throws IllegalArgumentException, IOException
{
generateStructureHeader(inScopeEncStyle, javaType, context, sink,
- nsStack, xjmr, null, null, false);
+ nsStack, xjmr, ctx, null, null, false);
}
private static void generateStructureHeader(String inScopeEncStyle,
Class javaType, Object context,
Writer sink, NSStack nsStack,
XMLJavaMappingRegistry xjmr,
+ SOAPContext ctx,
QName arrayElementType,
String arrayLengthStr,
boolean isNull)
@@ -177,9 +183,11 @@
String xsiNSPrefix = nsStack.getPrefixFromURI(xsiNamespaceURI, sink);
String elementTypeNSPrefix = nsStack.getPrefixFromURI(elementTypeNS, sink);
- sink.write(' ' + xsiNSPrefix + ':' + Constants.ATTR_TYPE + "=\"" +
- elementTypeNSPrefix + ':' +
- elementType.getLocalPart() + '\"');
+ if (ctx == null || !ctx.getDocLitSerialization()) {
+ sink.write(' ' + xsiNSPrefix + ':' + Constants.ATTR_TYPE + "=\"" +
+ elementTypeNSPrefix + ':' +
+ elementType.getLocalPart() + '\"');
+ }
if (inScopeEncStyle == null
|| !inScopeEncStyle.equals(Constants.NS_URI_SOAP_ENC))
@@ -215,6 +223,52 @@
}
sink.write('>');
+ }
+
+ public static void generateNullStructure(String inScopeEncStyle,
+ Class javaType, Object context,
+ Writer sink, NSStack nsStack,
+ XMLJavaMappingRegistry xjmr)
+ throws IllegalArgumentException, IOException
+ {
+ generateStructureHeader(inScopeEncStyle, javaType, context, sink,
+ nsStack, xjmr, null, null, null, true);
+ }
+
+ public static void generateNullArray(String inScopeEncStyle,
+ Class javaType, Object context,
+ Writer sink, NSStack nsStack,
+ XMLJavaMappingRegistry xjmr,
+ QName arrayElementType,
+ String arrayLengthStr)
+ throws IllegalArgumentException, IOException
+ {
+ generateStructureHeader(inScopeEncStyle, javaType, context, sink,
+ nsStack, xjmr, null, arrayElementType, arrayLengthStr,
+ true);
+ }
+
+ public static void generateArrayHeader(String inScopeEncStyle,
+ Class javaType, Object context,
+ Writer sink, NSStack nsStack,
+ XMLJavaMappingRegistry xjmr,
+ QName arrayElementType,
+ String arrayLengthStr)
+ throws IllegalArgumentException, IOException
+ {
+ generateStructureHeader(inScopeEncStyle, javaType, context, sink,
+ nsStack, xjmr, null, arrayElementType, arrayLengthStr,
+ false);
+ }
+
+ public static void generateStructureHeader(String inScopeEncStyle,
+ Class javaType, Object context,
+ Writer sink, NSStack nsStack,
+ XMLJavaMappingRegistry xjmr)
+ throws IllegalArgumentException, IOException
+ {
+ generateStructureHeader(inScopeEncStyle, javaType, context, sink,
+ nsStack, xjmr, null, null, null, false);
}
private static String nilName(String currentSchemaXSI)
1.9 +5 -3 xml-soap/java/src/org/apache/soap/encoding/soapenc/VectorSerializer.java
Index: VectorSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/VectorSerializer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- VectorSerializer.java 21 Jan 2002 00:01:57 -0000 1.8
+++ VectorSerializer.java 30 Aug 2002 21:39:00 -0000 1.9
@@ -119,7 +119,8 @@
context,
sink,
nsStack,
- xjmr);
+ xjmr,
+ ctx);
}
else
{
@@ -128,7 +129,8 @@
context,
sink,
nsStack,
- xjmr);
+ xjmr,
+ ctx);
sink.write(StringUtils.lineSeparator);
@@ -142,7 +144,7 @@
{
SoapEncUtils.generateNullStructure(Constants.NS_URI_SOAP_ENC,
Object.class, "item", sink,
- nsStack, xjmr);
+ nsStack, xjmr, ctx);
}
else
{
1.17 +18 -0 xml-soap/java/src/org/apache/soap/rpc/Call.java
Index: Call.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/rpc/Call.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- Call.java 26 Jul 2002 04:48:29 -0000 1.16
+++ Call.java 30 Aug 2002 21:39:00 -0000 1.17
@@ -110,6 +110,24 @@
super(targetObjectURI, methodName, params, header, encodingStyleURI, ctx);
}
+ /**
+ * Gets whether document/literal style is used in serialization.
+ *
+ * @return Whether document/literal style is used in serialization.
+ */
+ public boolean getDocLitSerialization() {
+ return ctx.getDocLitSerialization();
+ }
+
+ /**
+ * Sets whether document/literal style is used in serialization.
+ *
+ * @param docLitSerialization Whether document/literal style is used in serialization.
+ */
+ public void setDocLitSerialization(boolean docLitSerialization) {
+ ctx.setDocLitSerialization(docLitSerialization);
+ }
+
public void setSOAPMappingRegistry(SOAPMappingRegistry smr)
{
this.smr = smr;
1.17 +19 -8 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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- RPCMessage.java 21 Jan 2002 00:07:24 -0000 1.16
+++ RPCMessage.java 30 Aug 2002 21:39:00 -0000 1.17
@@ -233,11 +233,15 @@
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('<' + targetObjectNSPrefix + ':' +
- methodName + suffix + nsDeclSW);
+ sink.write('<' +
+ (!ctx.getDocLitSerialization() ? targetObjectNSPrefix + ':' : "") +
+ methodName + suffix +
+ (!ctx.getDocLitSerialization() ? nsDeclSW.toString() : " xmlns=\"" + targetObjectURI + "\"")
+ );
// Determine the prefix associated with the NS_URI_SOAP_ENV
// namespace URI.
@@ -245,7 +249,8 @@
Constants.NS_URI_SOAP_ENV, sink);
if (declMsgEncStyle != null
- && !declMsgEncStyle.equals(inScopeEncStyle)) {
+ && (!declMsgEncStyle.equals(inScopeEncStyle))
+ && (!ctx.getDocLitSerialization())) {
sink.write(' ' + soapEnvNSPrefix + ':' +
Constants.ATTR_ENCODING_STYLE + "=\"" +
declMsgEncStyle + '\"');
@@ -272,7 +277,8 @@
serializeParams(params, actualMsgEncStyle, sink, nsStack, xjmr, ctx);
- sink.write("</" + targetObjectNSPrefix + ':' +
+ sink.write("</" +
+ (!ctx.getDocLitSerialization() ? targetObjectNSPrefix + ':' : "") +
methodName + suffix + '>' +
StringUtils.lineSeparator);
} else {
@@ -287,8 +293,11 @@
String targetObjectNSPrefix = nsStack.getPrefixFromURI(targetObjectURI,
nsDeclSW);
- sink.write('<' + targetObjectNSPrefix + ':' +
- methodName + suffix + nsDeclSW);
+ sink.write('<' +
+ (!ctx.getDocLitSerialization() ? targetObjectNSPrefix + ':' : "") +
+ methodName + suffix +
+ (!ctx.getDocLitSerialization() ? nsDeclSW.toString() : " xmlns=\"" + targetObjectURI + "\"")
+ );
// Determine the prefix associated with the NS_URI_SOAP_ENV
// namespace URI.
@@ -296,7 +305,8 @@
Constants.NS_URI_SOAP_ENV, sink);
if (declMsgEncStyle != null
- && !declMsgEncStyle.equals(inScopeEncStyle)) {
+ && (!declMsgEncStyle.equals(inScopeEncStyle))
+ && (!ctx.getDocLitSerialization())) {
sink.write(' ' + soapEnvNSPrefix + ':' +
Constants.ATTR_ENCODING_STYLE + "=\"" +
declMsgEncStyle + '\"');
@@ -306,7 +316,8 @@
serializeParams(params, actualMsgEncStyle, sink, nsStack, xjmr, ctx);
- sink.write("</" + targetObjectNSPrefix + ':' +
+ sink.write("</" +
+ (!ctx.getDocLitSerialization() ? targetObjectNSPrefix + ':' : "") +
methodName + suffix + '>');
}
1.10 +19 -0 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SOAPContext.java 28 Jun 2002 03:07:36 -0000 1.9
+++ SOAPContext.java 30 Aug 2002 21:39:00 -0000 1.10
@@ -86,6 +86,7 @@
protected Vector multiRef = new Vector();
protected Hashtable deserializedMultiRef = new Hashtable();
protected String currentId = null;
+ protected boolean docLitSerialization = false;
/**
* This flag indicates if setRootPart() was called, so we can distinguish
@@ -578,6 +579,24 @@
if ( loader == null )
return( Class.forName( className ) );
return( Class.forName( className, true, loader ) );
+ }
+
+ /**
+ * Gets whether document/literal style is used in serialization.
+ *
+ * @return Whether document/literal style is used in serialization.
+ */
+ public boolean getDocLitSerialization() {
+ return docLitSerialization;
+ }
+
+ /**
+ * Sets whether document/literal style is used in serialization.
+ *
+ * @param docLitSerialization Whether document/literal style is used in serialization.
+ */
+ public void setDocLitSerialization(boolean docLitSerialization) {
+ this.docLitSerialization = docLitSerialization;
}
/**
1.11 +1 -1 xml-soap/java/src/org/apache/soap/server/TypeMappingSerializer.java
Index: TypeMappingSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/TypeMappingSerializer.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TypeMappingSerializer.java 13 Nov 2001 18:28:35 -0000 1.10
+++ TypeMappingSerializer.java 30 Aug 2002 21:39:01 -0000 1.11
@@ -94,7 +94,7 @@
nsStack.pushScope ();
SoapEncUtils.generateStructureHeader (inScopeEncStyle, javaType, context,
- sink, nsStack, xjmr);
+ sink, nsStack, xjmr, ctx);
sink.write (StringUtils.lineSeparator);
// these namespaces being defined by the envelope stuff