Return-Path: Delivered-To: apmail-xml-axis-dev-archive@xml.apache.org Received: (qmail 70209 invoked by uid 500); 22 Feb 2002 16:15:56 -0000 Mailing-List: contact axis-dev-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-dev@xml.apache.org Received: (qmail 70193 invoked by uid 500); 22 Feb 2002 16:15:56 -0000 Delivered-To: apmail-xml-axis-cvs@apache.org Date: 22 Feb 2002 16:15:55 -0000 Message-ID: <20020222161555.5535.qmail@icarus.apache.org> From: gdaniels@apache.org To: xml-axis-cvs@apache.org Subject: cvs commit: xml-axis/java/src/org/apache/axis/providers/java RPCProvider.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N gdaniels 02/02/22 08:15:55 Modified: java/src/org/apache/axis/client Call.java java/src/org/apache/axis/encoding DeserializationContextImpl.java java/src/org/apache/axis/message BodyBuilder.java MessageElement.java RPCElement.java SOAPEnvelope.java java/src/org/apache/axis/providers/java RPCProvider.java Log: Clean up encodingStyle code. 1) MessageElement now has an encodingStyle field, which replaces the one that was formerly in the SOAPEnvelope and the RPCElement. 2) Getting the encodingStyle via elem.getEncodingStyle() will return the currently IN-SCOPE encoding style. This means if one is explicitly set on this element, we return it, otherwise we walk up the tree and return the first one we find. (if we get to the top, we return "") 3) RPCElements default the encodingStyle to SOAP-ENC, but this can be overriden for literal (no encoding) or other encoding styles. Revision Changes Path 1.77 +2 -4 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.76 retrieving revision 1.77 diff -u -r1.76 -r1.77 --- Call.java 21 Feb 2002 22:16:17 -0000 1.76 +++ Call.java 22 Feb 2002 16:15:55 -0000 1.77 @@ -1450,11 +1450,9 @@ } } - // We want the body encoding style to be what the user set + // Set both the envelope and the RPCElement encoding styles body.setEncodingStyle(encodingStyle); - // Do we really want to set the envelope? - if (encodingStyle != null) - reqEnv.setEncodingStyleURI(encodingStyle); + reqEnv.setEncodingStyle(encodingStyle); setRequestMessage(reqMsg); 1.9 +1 -2 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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- DeserializationContextImpl.java 22 Feb 2002 15:37:47 -0000 1.8 +++ DeserializationContextImpl.java 22 Feb 2002 16:15:55 -0000 1.9 @@ -131,8 +131,7 @@ private MessageElement curElement; protected int startOfMappingsPos = -1; - - + /** * Construct Deserializer using MessageContext and EnvelopeBuilder handler * @param ctx is the MessageContext 1.18 +0 -1 xml-axis/java/src/org/apache/axis/message/BodyBuilder.java Index: BodyBuilder.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/BodyBuilder.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- BodyBuilder.java 20 Feb 2002 18:59:21 -0000 1.17 +++ BodyBuilder.java 22 Feb 2002 16:15:55 -0000 1.18 @@ -152,7 +152,6 @@ gotRPCElement = true; element = new RPCElement(namespace, localName, prefix, attributes, context); - //handler = new RPCHandler((RPCElement)element); } else { element = new SOAPBodyElement(namespace, localName, prefix, attributes, context); 1.77 +48 -0 xml-axis/java/src/org/apache/axis/message/MessageElement.java Index: MessageElement.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v retrieving revision 1.76 retrieving revision 1.77 diff -u -r1.76 -r1.77 --- MessageElement.java 21 Feb 2002 04:28:26 -0000 1.76 +++ MessageElement.java 22 Feb 2002 16:15:55 -0000 1.77 @@ -115,6 +115,9 @@ // Do we need links to our children too? public ArrayList namespaces = null; + + /** Our encoding style, if any */ + protected String encodingStyle = null; /** No-arg constructor for building messages? */ @@ -177,6 +180,12 @@ // If there's an arrayType attribute, we can pretty well guess that we're an Array??? if (attributes.getValue(Constants.URI_CURRENT_SOAP_ENC, Constants.ATTR_ARRAY_TYPE) != null) typeQName = Constants.SOAP_ARRAY; + + // Set the encoding style to the attribute value. If null, + // we just automatically use our parent's (see getEncodingStyle) + encodingStyle = + attributes.getValue(Constants.URI_CURRENT_SOAP_ENC, + Constants.ATTR_ENCODING_STYLE); } } @@ -225,6 +234,32 @@ public SAX2EventRecorder getRecorder() { return recorder; } public void setRecorder(SAX2EventRecorder rec) { recorder = rec; } + /** + * Get the encoding style. If ours is null, walk up the hierarchy + * and use our parent's. Default if we're the root is "". + * + * @return the currently in-scope encoding style + */ + public String getEncodingStyle() { + if (encodingStyle == null) { + if (parent == null) + return ""; + return parent.getEncodingStyle(); + } + return encodingStyle; + } + + /** + * Set the encoding style. Calling this means you are absolutely + * setting it to SOMETHING valid. The semantics of a null value, + * as above in getEncodingStyle() are to just use the parent's value, + * but null here means set to "". + */ + public void setEncodingStyle(String encodingStyle) { + if (encodingStyle == null) encodingStyle = ""; + this.encodingStyle = encodingStyle; + } + public MessageElement getParent() { return parent; } public void setParent(MessageElement parent) { @@ -484,6 +519,19 @@ context.qName2String(attr.value)); } qNameAttrs = null; + } + + /** + * Write the encoding style attribute IF it's different from + * whatever encoding style is in scope.... + */ + if (encodingStyle != null) { + if ((parent == null) || + (!encodingStyle.equals(parent.getEncodingStyle()))) { + setAttribute(Constants.URI_CURRENT_SOAP_ENC, + Constants.ATTR_ENCODING_STYLE, + encodingStyle); + } } outputImpl(context); 1.35 +8 -39 xml-axis/java/src/org/apache/axis/message/RPCElement.java Index: RPCElement.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCElement.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- RPCElement.java 21 Feb 2002 04:28:27 -0000 1.34 +++ RPCElement.java 22 Feb 2002 16:15:55 -0000 1.35 @@ -76,14 +76,13 @@ protected Vector params = new Vector(); protected boolean needDeser = false; - // encoding style to put in soap body element - protected String encodingStyle = Constants.URI_CURRENT_SOAP_ENC; - public RPCElement(String namespace, String localName, String prefix, Attributes attributes, DeserializationContext context) { super(namespace, localName, prefix, attributes, context); + encodingStyle = Constants.URI_CURRENT_SOAP_ENC; + // This came from parsing XML, so we need to deserialize it sometime needDeser = true; } @@ -93,6 +92,8 @@ this.setNamespaceURI(namespace); this.name = methodName; + encodingStyle = Constants.URI_CURRENT_SOAP_ENC; + for (int i = 0; args != null && i < args.length; i++) { if (args[i] instanceof RPCParam) { addParam((RPCParam)args[i]); @@ -106,6 +107,8 @@ public RPCElement(String methodName) { + encodingStyle = Constants.URI_CURRENT_SOAP_ENC; + this.name = methodName; } @@ -209,45 +212,11 @@ params.addElement(param); } - public void setEncodingStyle(String encodingStyle) { - this.encodingStyle = encodingStyle; - } - - public String getEncodingStyle() { - if (encodingStyle == null) { - return getEnvelope().getEncodingStyleURI(); - } - - return encodingStyle; - } - protected void outputImpl(SerializationContext context) throws Exception { -/* - if (encodingStyle != null) { - QName qn = new QName(Constants.URI_CURRENT_SOAP_ENC, - Constants.ATTR_ENCODING_STYLE); - - if (attributes == null) - attributes = new AttributesImpl(); - attributes.addAttribute(Constants.URI_CURRENT_SOAP_ENC, - Constants.ATTR_ENCODING_STYLE, - context.qName2String(qn), - "CDATA", - encodingStyle); - } -*/ - if (encodingStyle != null) { - setAttribute(Constants.URI_CURRENT_SOAP_ENC, - Constants.ATTR_ENCODING_STYLE, - encodingStyle); - } - // Set default namespace if appropriate (to avoid prefix mappings - // in literal style). Do this only if there is no encodingStyle - // on EITHER the RPCElement or its parent envelope. - String realEncStyle = getEncodingStyle(); - if (realEncStyle == null || realEncStyle.equals("")) { + // in literal style). Do this only if there is no encodingStyle. + if (encodingStyle.equals("")) { context.registerPrefixForURI("", getNamespaceURI()); } 1.56 +0 -13 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.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- SOAPEnvelope.java 19 Feb 2002 17:38:21 -0000 1.55 +++ SOAPEnvelope.java 22 Feb 2002 16:15:55 -0000 1.56 @@ -85,7 +85,6 @@ public Vector headers = new Vector(); public Vector bodyElements = new Vector(); public Vector trailers = new Vector(); - public String encodingStyleURI = null; // This is a hint to any service description to tell it what // "type" of message we are. This might be "request", "response", @@ -143,18 +142,6 @@ this.messageType = messageType; } - public void setEncodingStyleURI(String uri) - { - encodingStyleURI = uri; - setAttribute(Constants.URI_SOAP_ENV, - Constants.ATTR_ENCODING_STYLE, - encodingStyleURI); - } - - public String getEncodingStyleURI() { - return encodingStyleURI; - } - public Vector getBodyElements() throws AxisFault { return bodyElements; 1.40 +1 -1 xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java Index: RPCProvider.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- RPCProvider.java 20 Feb 2002 18:59:21 -0000 1.39 +++ RPCProvider.java 22 Feb 2002 16:15:55 -0000 1.40 @@ -289,6 +289,7 @@ RPCElement resBody = new RPCElement(mName + "Response"); resBody.setPrefix( body.getPrefix() ); resBody.setNamespaceURI( body.getNamespaceURI() ); + resBody.setEncodingStyle(body.getEncodingStyle()); if ( objRes != null ) { // In the old skeleton a param list was returned, which // contained the RPC params. Preserve this for now. @@ -332,7 +333,6 @@ } resEnv.addBodyElement( resBody ); - resEnv.setEncodingStyleURI(Constants.URI_CURRENT_SOAP_ENC); } }