glyn 02/04/11 08:50:40
Modified: java/samples/echo echoHeaderStringHandler.java
echoHeaderStructHandler.java
java/samples/encoding TestSer.java
java/src/org/apache/axis SOAPPart.java
java/src/org/apache/axis/client Call.java
java/src/org/apache/axis/encoding
DeserializationContextImpl.java
java/src/org/apache/axis/handlers SimpleSessionHandler.java
java/src/org/apache/axis/handlers/soap SOAPService.java
java/src/org/apache/axis/message EnvelopeBuilder.java
HeaderBuilder.java SOAPEnvelope.java
SOAPHeader.java
java/test/RPCDispatch TestRPC.java
java/test/outparams ServiceHandler.java
Log:
Support JAXM technique of using detachNode to remove an empty SOAPHeader from
a SOAPEnvelope. This requires a SOAPHeader to be a *child* of its SOAPEnvelope
resulting in some extra SOAPException propagation on creation of SOAPHeader
and consequent try/catching.
Revision Changes Path
1.4 +5 -1 xml-axis/java/samples/echo/echoHeaderStringHandler.java
Index: echoHeaderStringHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/echo/echoHeaderStringHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- echoHeaderStringHandler.java 26 Mar 2002 16:40:34 -0000 1.3
+++ echoHeaderStringHandler.java 11 Apr 2002 15:50:39 -0000 1.4
@@ -103,7 +103,11 @@
SOAPHeaderElement header = new SOAPHeaderElement(HEADER_NS,
HEADER_RESNAME,
strVal);
- env.addHeader(header);
+ try {
+ env.addHeader(header);
+ } catch (Exception ex) {
+ throw AxisFault.makeFault(ex);
+ }
} else {
// Request. look for the header
Message msg = context.getRequestMessage();
1.4 +5 -1 xml-axis/java/samples/echo/echoHeaderStructHandler.java
Index: echoHeaderStructHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/echo/echoHeaderStructHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- echoHeaderStructHandler.java 26 Mar 2002 16:40:34 -0000 1.3
+++ echoHeaderStructHandler.java 11 Apr 2002 15:50:39 -0000 1.4
@@ -107,7 +107,11 @@
SOAPHeaderElement header = new SOAPHeaderElement(HEADER_NS,
HEADER_RESNAME,
hdrVal);
- env.addHeader(header);
+ try {
+ env.addHeader(header);
+ } catch (Exception ex) {
+ throw AxisFault.makeFault(ex);
+ }
} else {
// Request. look for the header
Message msg = context.getRequestMessage();
1.21 +23 -19 xml-axis/java/samples/encoding/TestSer.java
Index: TestSer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/encoding/TestSer.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- TestSer.java 1 Feb 2002 22:08:25 -0000 1.20
+++ TestSer.java 11 Apr 2002 15:50:39 -0000 1.21
@@ -28,26 +28,30 @@
public static final String myNS = "urn:myNS";
public static void main(String args[]) {
- MessageContext msgContext = new MessageContext(new AxisServer());
- SOAPEnvelope msg = new SOAPEnvelope();
- RPCParam arg1 = new RPCParam("urn:myNamespace", "testParam", "this is a
string");
- QName dataQName = new QName("typeNS", "Data");
-
- Data data = new Data();
- Data data2 = new Data();
- data.stringMember = "String member";
- data.floatMember = new Float("1.23");
- data.dataMember = data2;
-
- data2.stringMember = "another str member";
- data2.floatMember = new Float("4.56");
- data2.dataMember = null; // "data;" for loop-test of multi-refs
-
- RPCParam arg2 = new RPCParam("", "struct", data);
- RPCElement body = new RPCElement("urn:myNamespace", "method1", new
Object[]{ arg1, arg2 });
- msg.addBodyElement(body);
-
try {
+ MessageContext msgContext = new MessageContext(new AxisServer());
+ SOAPEnvelope msg = new SOAPEnvelope();
+ RPCParam arg1 = new RPCParam("urn:myNamespace",
+ "testParam",
+ "this is a string");
+ QName dataQName = new QName("typeNS", "Data");
+
+ Data data = new Data();
+ Data data2 = new Data();
+ data.stringMember = "String member";
+ data.floatMember = new Float("1.23");
+ data.dataMember = data2;
+
+ data2.stringMember = "another str member";
+ data2.floatMember = new Float("4.56");
+ data2.dataMember = null; // "data;" for loop-test of multi-refs
+
+ RPCParam arg2 = new RPCParam("", "struct", data);
+ RPCElement body = new RPCElement("urn:myNamespace",
+ "method1",
+ new Object[]{ arg1, arg2 });
+ msg.addBodyElement(body);
+
Reader reader = null;
if (args.length == 0) {
1.18 +19 -3 xml-axis/java/src/org/apache/axis/SOAPPart.java
Index: SOAPPart.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/SOAPPart.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- SOAPPart.java 24 Mar 2002 18:51:28 -0000 1.17
+++ SOAPPart.java 11 Apr 2002 15:50:39 -0000 1.18
@@ -66,6 +66,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.xml.soap.SOAPException;
+
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -407,7 +409,12 @@
if (currentForm == FORM_BODYINSTREAM) {
InputStreamBody bodyEl =
new InputStreamBody((InputStream)currentMessage);
- SOAPEnvelope env = new SOAPEnvelope();
+ SOAPEnvelope env;
+ try {
+ env = new SOAPEnvelope();
+ } catch (SOAPException ex) {
+ throw new AxisFault(ex);
+ }
env.addBodyElement(bodyEl);
setCurrentMessage(env, FORM_SOAPENVELOPE);
return env;
@@ -420,8 +427,17 @@
} else {
is = new InputSource(new StringReader(getAsString()));
}
- DeserializationContext dser =
- new DeserializationContextImpl(is, getMessage().getMessageContext(),
getMessage().getMessageType());
+
+ DeserializationContext dser;
+ try {
+ dser = new DeserializationContextImpl(is,
+ getMessage().
+ getMessageContext(),
+ getMessage().
+ getMessageType());
+ } catch (Exception ex) {
+ throw AxisFault.makeFault(ex);
+ }
// This may throw a SAXException
try {
1.113 +31 -24 xml-axis/java/src/org/apache/axis/client/Call.java
Index: Call.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Call.java,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -r1.112 -r1.113
--- Call.java 5 Apr 2002 16:15:37 -0000 1.112
+++ Call.java 11 Apr 2002 15:50:39 -0000 1.113
@@ -1144,16 +1144,20 @@
if ( !(params[i] instanceof SOAPBodyElement) ) break ;
if ( params != null && params.length > 0 && i == params.length ) {
- /* ok, we're doing Messaging, so build up the message */
- /******************************************************/
- env = new SOAPEnvelope();
-
- for ( i = 0 ; myHeaders != null && i < myHeaders.size() ; i++ )
- env.addHeader((SOAPHeaderElement)myHeaders.get(i));
-
- if ( !(params[0] instanceof SOAPEnvelope) )
- for ( i = 0 ; i < params.length ; i++ )
- env.addBodyElement( (SOAPBodyElement) params[i] );
+ try {
+ /* ok, we're doing Messaging, so build up the message */
+ /******************************************************/
+ env = new SOAPEnvelope();
+
+ for ( i = 0 ; myHeaders != null && i < myHeaders.size() ; i++ )
+ env.addHeader((SOAPHeaderElement)myHeaders.get(i));
+
+ if ( !(params[0] instanceof SOAPEnvelope) )
+ for ( i = 0 ; i < params.length ; i++ )
+ env.addBodyElement( (SOAPBodyElement) params[i] );
+ } catch (Exception ex) {
+ throw AxisFault.makeFault(ex);
+ }
Message msg = new Message( env );
setRequestMessage(msg);
@@ -1654,26 +1658,29 @@
throw new AxisFault(JavaUtils.getMessage("mustSpecifyReturnType"));
}
- SOAPEnvelope reqEnv = new SOAPEnvelope();
+ SOAPEnvelope reqEnv;
SOAPEnvelope resEnv = null ;
- Message reqMsg = new Message( reqEnv );
+ Message reqMsg;
Message resMsg = null ;
Vector resArgs = null ;
Object result = null ;
- // Clear the output params
- outParams = new HashMap();
- outParamsList = new ArrayList();
-
- // If we have headers to insert, do so now.
- if (myHeaders != null) {
- for (int i = 0; i < myHeaders.size(); i++) {
- reqEnv.addHeader((SOAPHeaderElement)myHeaders.get(i));
- }
- }
-
- // Set both the envelope and the RPCElement encoding styles
try {
+ reqEnv = new SOAPEnvelope();
+ reqMsg = new Message( reqEnv );
+
+ // Clear the output params
+ outParams = new HashMap();
+ outParamsList = new ArrayList();
+
+ // If we have headers to insert, do so now.
+ if (myHeaders != null) {
+ for (int i = 0; i < myHeaders.size(); i++) {
+ reqEnv.addHeader((SOAPHeaderElement)myHeaders.get(i));
+ }
+ }
+
+ // Set both the envelope and the RPCElement encoding styles
body.setEncodingStyle(encodingStyle);
reqEnv.setEncodingStyle(encodingStyle);
1.22 +2 -1
xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java
Index: DeserializationContextImpl.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- DeserializationContextImpl.java 27 Mar 2002 20:16:25 -0000 1.21
+++ DeserializationContextImpl.java 11 Apr 2002 15:50:40 -0000 1.22
@@ -85,6 +85,7 @@
import javax.xml.parsers.SAXParser;
import javax.xml.rpc.namespace.QName;
import javax.xml.rpc.JAXRPCException;
+import javax.xml.soap.SOAPException;
import java.io.IOException;
import java.util.ArrayList;
@@ -154,7 +155,7 @@
* @param messageType is the MessageType to construct an EnvelopeBuilder
*/
public DeserializationContextImpl(InputSource is, MessageContext ctx,
- String messageType)
+ String messageType) throws SOAPException
{
EnvelopeBuilder builder = new EnvelopeBuilder(messageType,
ctx.getSOAPConstants());
1.18 +10 -2
xml-axis/java/src/org/apache/axis/handlers/SimpleSessionHandler.java
Index: SimpleSessionHandler.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/handlers/SimpleSessionHandler.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- SimpleSessionHandler.java 9 Apr 2002 15:41:30 -0000 1.17
+++ SimpleSessionHandler.java 11 Apr 2002 15:50:40 -0000 1.18
@@ -224,7 +224,11 @@
SOAPHeaderElement header = new SOAPHeaderElement(SESSION_NS,
SESSION_LOCALPART,
id);
- env.addHeader(header);
+ try {
+ env.addHeader(header);
+ } catch (Exception ex) {
+ throw AxisFault.makeFault(ex);
+ }
}
}
@@ -247,7 +251,11 @@
SOAPHeaderElement header = new SOAPHeaderElement(SESSION_NS,
SESSION_LOCALPART,
id);
- env.addHeader(header);
+ try {
+ env.addHeader(header);
+ } catch (Exception ex) {
+ throw AxisFault.makeFault(ex);
+ }
} else {
// Request. Set up the session if we find the header.
Message msg = context.getRequestMessage();
1.55 +10 -3 xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java
Index: SOAPService.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- SOAPService.java 26 Mar 2002 16:40:35 -0000 1.54
+++ SOAPService.java 11 Apr 2002 15:50:40 -0000 1.55
@@ -163,7 +163,11 @@
if (doMisunderstoodHeaders) {
Message respMsg = msgContext.getResponseMessage();
if (respMsg == null) {
- respMsg = new Message(new SOAPEnvelope());
+ try {
+ respMsg = new Message(new SOAPEnvelope());
+ } catch (Exception ex) {
+ throw AxisFault.makeFault(ex);
+ }
msgContext.setResponseMessage(respMsg);
}
env = respMsg.getSOAPEnvelope();
@@ -179,8 +183,11 @@
newHeader.addAttribute(null,
Constants.ATTR_QNAME,
badQName);
-
- env.addHeader(newHeader);
+ try {
+ env.addHeader(newHeader);
+ } catch (Exception ex) {
+ throw AxisFault.makeFault(ex);
+ }
}
}
1.16 +2 -0 xml-axis/java/src/org/apache/axis/message/EnvelopeBuilder.java
Index: EnvelopeBuilder.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/EnvelopeBuilder.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- EnvelopeBuilder.java 9 Apr 2002 23:45:24 -0000 1.15
+++ EnvelopeBuilder.java 11 Apr 2002 15:50:40 -0000 1.16
@@ -62,6 +62,7 @@
import org.xml.sax.SAXException;
import javax.xml.rpc.namespace.QName;
+import javax.xml.soap.SOAPException;
/**
* The EnvelopeBuilder is responsible for parsing the top-level
@@ -79,6 +80,7 @@
private boolean gotBody = false;
public EnvelopeBuilder(String messageType, SOAPConstants soapConstants)
+ throws SOAPException
{
envelope = new SOAPEnvelope(false, soapConstants);
envelope.setMessageType(messageType);
1.8 +6 -1 xml-axis/java/src/org/apache/axis/message/HeaderBuilder.java
Index: HeaderBuilder.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/HeaderBuilder.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- HeaderBuilder.java 26 Mar 2002 16:40:35 -0000 1.7
+++ HeaderBuilder.java 11 Apr 2002 15:50:40 -0000 1.8
@@ -92,7 +92,12 @@
public void onEndChild(String namespace, String localName,
DeserializationContext context)
+ throws SAXException
{
- envelope.addHeader(header);
+ try {
+ envelope.addHeader(header);
+ } catch (Exception ex) {
+ throw new SAXException(ex);
+ }
}
}
1.63 +14 -7 xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java
Index: SOAPEnvelope.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- SOAPEnvelope.java 10 Apr 2002 15:23:58 -0000 1.62
+++ SOAPEnvelope.java 11 Apr 2002 15:50:40 -0000 1.63
@@ -75,6 +75,8 @@
import org.xml.sax.helpers.AttributesImpl;
import javax.xml.rpc.namespace.QName;
+import javax.xml.soap.SOAPException;
+
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Enumeration;
@@ -100,20 +102,21 @@
// deserialization
public String messageType;
- public SOAPEnvelope()
+ public SOAPEnvelope() throws SOAPException
{
this(true, SOAPConstants.SOAP11_CONSTANTS);
}
- public SOAPEnvelope(SOAPConstants soapConstants)
+ public SOAPEnvelope(SOAPConstants soapConstants) throws SOAPException
{
this(true, soapConstants);
}
public SOAPEnvelope(boolean registerPrefixes, SOAPConstants soapConstants)
+ throws SOAPException
{
this.soapConstants = soapConstants;
- header = new SOAPHeader(soapConstants);
+ header = new SOAPHeader(this, soapConstants);
if (registerPrefixes) {
if (namespaces == null)
@@ -130,9 +133,9 @@
setDirty(true);
}
- public SOAPEnvelope(InputStream input) throws SAXException {
+ public SOAPEnvelope(InputStream input) throws SAXException, SOAPException {
InputSource is = new InputSource(input);
- header = new SOAPHeader(soapConstants); // soapConstants = null!
+ header = new SOAPHeader(this, soapConstants); // soapConstants = null!
DeserializationContext dser = null ;
AxisClient tmpEngine = new AxisClient(new NullProvider());
MessageContext msgContext = new MessageContext(tmpEngine);
@@ -190,10 +193,10 @@
}
}
- public void addHeader(SOAPHeaderElement hdr)
+ public void addHeader(SOAPHeaderElement hdr) throws SOAPException
{
if (header == null) {
- header = new SOAPHeader(soapConstants);
+ header = new SOAPHeader(this, soapConstants);
}
hdr.setEnvelope(this);
header.addHeader(hdr);
@@ -208,6 +211,10 @@
bodyElements.addElement(element);
_isDirty = true;
+ }
+
+ public void removeHeaders() {
+ header = null;
}
public void removeHeader(SOAPHeaderElement hdr)
1.39 +18 -1 xml-axis/java/src/org/apache/axis/message/SOAPHeader.java
Index: SOAPHeader.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPHeader.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- SOAPHeader.java 10 Apr 2002 15:23:58 -0000 1.38
+++ SOAPHeader.java 11 Apr 2002 15:50:40 -0000 1.39
@@ -65,6 +65,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.xml.soap.SOAPElement;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPException;
import javax.xml.rpc.namespace.QName;
@@ -88,8 +89,24 @@
private SOAPConstants soapConstants;
- SOAPHeader(SOAPConstants soapConsts) {
+ SOAPHeader(SOAPEnvelope env, SOAPConstants soapConsts)
+ throws SOAPException {
soapConstants = soapConsts;
+ setParentElement(env);
+ }
+
+ public void setParentElement(SOAPElement parent) throws SOAPException {
+ try {
+ // cast to force exception if wrong type
+ super.setParentElement((SOAPEnvelope)parent);
+ } catch (Throwable t) {
+ throw new SOAPException(t);
+ }
+ }
+
+ public void detachNode() {
+ ((SOAPEnvelope)parent).removeHeaders();
+ super.detachNode();
}
public javax.xml.soap.SOAPHeaderElement addHeaderElement(Name name)
1.35 +2 -1 xml-axis/java/test/RPCDispatch/TestRPC.java
Index: TestRPC.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/RPCDispatch/TestRPC.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- TestRPC.java 27 Mar 2002 17:53:07 -0000 1.34
+++ TestRPC.java 11 Apr 2002 15:50:40 -0000 1.35
@@ -22,6 +22,7 @@
import org.w3c.dom.Text;
import javax.xml.rpc.namespace.QName;
+import javax.xml.soap.SOAPException;
import java.util.Vector;
/**
@@ -61,7 +62,7 @@
* @return Deserialized result
*/
private final Object rpc(String method, Object[] parms)
- throws AxisFault, SAXException
+ throws AxisFault, SAXException, SOAPException
{
// Create the message context
1.8 +6 -1 xml-axis/java/test/outparams/ServiceHandler.java
Index: ServiceHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/outparams/ServiceHandler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ServiceHandler.java 10 Jan 2002 20:01:01 -0000 1.7
+++ ServiceHandler.java 11 Apr 2002 15:50:40 -0000 1.8
@@ -69,7 +69,12 @@
public static final Integer RESPONSE = new Integer(5);
public void invoke(MessageContext msgContext) throws AxisFault {
- SOAPEnvelope env = new SOAPEnvelope();
+ SOAPEnvelope env;
+ try {
+ env = new SOAPEnvelope();
+ } catch (Exception ex) {
+ throw AxisFault.makeFault(ex);
+ }
RPCParam retVal = new RPCParam("return", RESPONSE);
RPCParam outParam1 = new RPCParam("out1", OUTPARAM1);