You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ch...@apache.org on 2005/06/20 19:59:00 UTC
svn commit: r191524 [2/4] - in /webservices/axis/trunk/java/modules:
core/src/org/apache/axis/clientapi/ core/src/org/apache/axis/engine/
core/src/org/apache/axis/transport/http/ core/test/org/apache/axis/engine/
core/test/org/apache/axis/handlers/addr...
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultImpl.java?rev=191524&r1=191523&r2=191524&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultImpl.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultImpl.java Mon Jun 20 10:58:56 2005
@@ -20,7 +20,9 @@
import org.apache.axis.om.impl.llom.OMNamespaceImpl;
import org.apache.axis.om.impl.llom.OMTextImpl;
import org.apache.axis.soap.*;
-import org.apache.axis.soap.impl.llom.soap11.SOAP11Constants;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12Constants;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12FaultCodeImpl;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12FaultReasonImpl;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLOutputFactory;
@@ -33,32 +35,16 @@
/**
* Class SOAPFaultImpl
*/
-public class SOAPFaultImpl extends OMElementImpl
+public abstract class SOAPFaultImpl extends SOAPElement
implements SOAPFault, OMConstants {
- /**
- * Field e
- */
- private Exception e;
-
- /**
- * Field faultCodeElement
- */
- private OMElement faultCodeElement;
- /**
- * Field faultActorElement
- */
- private OMElement faultActorElement;
-
- /**
- * Field faultStringElement
- */
- private OMElement faultStringElement;
+ protected SOAPFaultCode faultCode;
+ protected SOAPFaultReason faultReason;
+ protected SOAPFaultNode faultNode;
+ protected SOAPFaultRoleImpl faultRole;
+ protected SOAPFaultDetail faultDetail;
- /**
- * Field detailElement
- */
- private OMElement detailElement;
+ protected Exception e;
/**
* Constructor SOAPFaultImpl
@@ -66,15 +52,14 @@
* @param parent
* @param e
*/
- public SOAPFaultImpl(OMElement parent, Exception e) {
- super(SOAPConstants.SOAPFAULT_LOCAL_NAME,
- new OMNamespaceImpl(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
- SOAPConstants.SOAPFAULT_NAMESPACE_PREFIX));
- this.parent = (OMElementImpl) parent;
+ public SOAPFaultImpl(SOAPBody parent, Exception e) throws SOAPProcessingException {
+ super(parent, SOAPConstants.SOAPFAULT_LOCAL_NAME, true);
this.e = e;
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- this.setDetailInformation(OMAbstractFactory.getSOAP11Factory().createText(sw.getBuffer().toString()));
+ putExceptionToSOAPFault(e);
+ }
+
+ public SOAPFaultImpl(SOAPBody parent) throws SOAPProcessingException {
+ super(parent, SOAPConstants.SOAPFAULT_LOCAL_NAME, true);
}
/**
@@ -84,254 +69,113 @@
* @param parent
* @param builder
*/
- public SOAPFaultImpl(OMNamespace ns, OMElement parent,
- OMXMLParserWrapper builder) {
- super(SOAPConstants.SOAPFAULT_LOCAL_NAME, ns, parent, builder);
+ public SOAPFaultImpl(SOAPBody parent, OMXMLParserWrapper builder) {
+ super(parent, SOAPConstants.SOAPFAULT_LOCAL_NAME,builder);
}
- /**
- * Method setCode
- *
- * @param faultCode
- * @throws OMException
- */
- public void setCode(SOAPFaultCode faultCode) throws OMException {
- if (faultCodeElement != null) {
- faultCodeElement.detach();
- }
- faultCodeElement =
- new OMElementImpl(SOAPConstants.SOAPFAULT_CODE_LOCAL_NAME, this.ns);
- this.addChild(faultCodeElement);
- faultCodeElement.addChild(new OMTextImpl(faultCodeElement,
- faultCode.getNamespace().getPrefix() + ':'
- + faultCode.getLocalName()));
+
+ protected abstract SOAPFaultDetail getNewSOAPFaultDetail(SOAPFault fault) throws SOAPProcessingException;
+
+ // --------------- Getters and Settors --------------------------- //
+
+ public void setCode(SOAPFaultCode soapFaultCode) throws SOAPProcessingException {
+ setNewElement(faultCode, soapFaultCode);
}
- /**
- * Method getCode
- *
- * @return
- */
public SOAPFaultCode getCode() {
-// if (faultCodeElement != null) {
-// Iterator childrenIter = faultCodeElement.getChildren();
-// while (childrenIter.hasNext()) {
-// Object o = childrenIter.next();
-// if ((o instanceof OMText)
-// && !((OMText) o).getText().trim().equals("")) {
-// String[] strings = ((OMText) o).getText().split(":");
-// return new QName("", strings[1], strings[0]);
-// }
-// }
-// } else {
-// faultCodeElement = this.getFirstChildWithName(
-// new QName(
-// this.ns.getName(), SOAPConstants.SOAPFAULT_CODE_LOCAL_NAME,
-// this.ns.getPrefix()));
-// if (faultCodeElement != null) {
-// return this.getCode();
-// }
-// }
- return null;
+ if (faultCode == null) {
+ faultCode = (SOAPFaultCode) this.getChildWithName(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME);
+ }
+
+ return faultCode;
}
- public void setReason(SOAPFaultReason reason) {
- //To change body of implemented methods use File | Settings | File Templates.
+ public void setReason(SOAPFaultReason reason) throws SOAPProcessingException {
+ setNewElement(faultReason, reason);
}
public SOAPFaultReason getReason() {
-
-
- SOAPFaultReason faultReason = new SOAPFaulReasonImpl(this);
- SOAPText soapText = new SOAPTextImpl(faultReason);
- soapText.setText(this.getFaultString());
-
- faultReason.setSOAPText(soapText);
- return faultReason; //To change body of implemented methods use File | Settings | File Templates.
+ if (faultReason == null) {
+ faultReason = (SOAPFaultReason) this.getChildWithName(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME);
+ }
+ return faultReason;
}
- public void setNode(SOAPFaultNode node) {
- //To change body of implemented methods use File | Settings | File Templates.
+ public void setNode(SOAPFaultNode node) throws SOAPProcessingException {
+ setNewElement(faultNode, node);
}
public SOAPFaultNode getNode() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ if (faultNode == null) {
+ faultNode = (SOAPFaultNode) this.getChildWithName(SOAP12Constants.SOAP_FAULT_NODE_LOCAL_NAME);
+ }
+ return faultNode;
}
- public void setRole(SOAPFaultRole role) {
- //To change body of implemented methods use File | Settings | File Templates.
+ public void setRole(SOAPFaultRole role) throws SOAPProcessingException {
+ setNewElement(faultRole, role);
}
public SOAPFaultRole getRole() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ if (faultRole == null) {
+ faultRole = (SOAPFaultRoleImpl) this.getChildWithName(SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME);
+ }
+ return faultRole;
}
- public void setDetail(SOAPFaultDetail detail) {
- //To change body of implemented methods use File | Settings | File Templates.
+ public void setDetail(SOAPFaultDetail detail) throws SOAPProcessingException {
+ setNewElement(faultDetail, detail);
}
- public SOAPFaultDetail getDetail() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
+ public abstract SOAPFaultDetail getDetail();
- /**
- * Method setFaultActor
- *
- * @param faultActor
- * @throws OMException
- */
- public void setFaultActor(String faultActor) throws OMException {
- if (faultActorElement != null) {
- faultActorElement.detach();
- }
- faultActorElement =
- new OMElementImpl(SOAPConstants.SOAPFAULT_ACTOR_LOCAL_NAME, this.ns);
- this.addChild(faultActorElement);
- faultActorElement.addChild(new OMTextImpl(faultActorElement,
- faultActor));
- }
- /**
- * Method getFaultActor
- *
- * @return
- */
- public String getFaultActor() {
- if (faultActorElement != null) {
- Iterator childrenIter = faultActorElement.getChildren();
- while (childrenIter.hasNext()) {
- Object o = childrenIter.next();
- if ((o instanceof OMText)
- && !"".equals(((OMText) o).getText())) {
- return ((OMText) o).getText();
- }
- }
- } else {
- faultActorElement = this.getFirstChildWithName(
- new QName(
- this.ns.getName(), SOAPConstants.SOAPFAULT_ACTOR_LOCAL_NAME,
- this.ns.getPrefix()));
- if (faultActorElement != null) {
- return this.getFaultString();
- }
- }
- return null;
- }
+ // ---------------------------------------------------------------------------------------------//
- /**
- * Method setFaultString
- *
- * @param faultString
- * @throws OMException
- */
- public void setFaultString(String faultString) throws OMException {
- if (faultStringElement != null) {
- faultStringElement.detach();
+ public Exception getException() throws OMException {
+ getDetail();
+ if (faultDetail == null) {
+ return new Exception("No Exception element found in the SOAP Detail element");
}
- faultStringElement =
- new OMElementImpl(SOAPConstants.SOAPFAULT_STRING_LOCAL_NAME, this.ns);
- this.addChild(faultStringElement);
- faultStringElement.addChild(new OMTextImpl(faultStringElement,
- faultString));
- }
- /**
- * Method getFaultString
- *
- * @return
- */
- public String getFaultString() {
- if (faultStringElement != null) {
- Iterator childrenIter = faultStringElement.getChildren();
- while (childrenIter.hasNext()) {
- Object o = childrenIter.next();
- if ((o instanceof OMText)
- && !"".equals(((OMText) o).getText())) {
- return ((OMText) o).getText();
- }
- }
- } else {
- faultStringElement = this.getFirstChildWithName(
- new QName(
- this.ns.getName(), SOAPConstants.SOAPFAULT_STRING_LOCAL_NAME,
- this.ns.getPrefix()));
- if (faultStringElement != null) {
- return this.getFaultString();
- }
+ OMElement exceptionElement = faultDetail.getFirstChildWithName(new QName(SOAPConstants.SOAP_FAULT_DETAIL_EXCEPTION_ENTRY));
+ if (exceptionElement != null) {
+ return new Exception(exceptionElement.getText());
}
- return null;
+ return new Exception("No Exception element found in the SOAP Detail element");
}
- /**
- * Method setDetailInformation
- *
- * @param detailInformation
- */
- public void setDetailInformation(OMNode detailInformation) {
- if (detailElement != null) {
- detailElement.detach();
+ protected void putExceptionToSOAPFault(Exception e) throws SOAPProcessingException {
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+
+ getDetail();
+ if (faultDetail == null) {
+ faultDetail = getNewSOAPFaultDetail(this);
+
}
- detailElement =
- new OMElementImpl(SOAPConstants.SOAPFAULT_DETAIL_LOCAL_NAME, this.ns);
- this.addChild(detailElement);
- detailElement.addChild(detailInformation);
+ OMElement faultDetailEnty = new OMElementImpl(SOAPConstants.SOAP_FAULT_DETAIL_EXCEPTION_ENTRY, this.getNamespace());
+ faultDetailEnty.setText(sw.getBuffer().toString());
+ faultDetail.addChild(faultDetailEnty);
}
- /**
- * Method getDetailInformation
- *
- * @return
- */
- public OMNode getDetailInformation() {
- if (detailElement != null) {
- Iterator childrenIter = detailElement.getChildren();
- while (childrenIter.hasNext()) {
- Object o = childrenIter.next();
- if (!((o instanceof OMText)
- && "".equals(((OMText) o).getText()))) {
- return (OMNode) o;
- }
- }
- } else {
- detailElement = this.getFirstChildWithName(
- new QName(
- this.ns.getName(), SOAPConstants.SOAPFAULT_DETAIL_LOCAL_NAME,
- this.ns.getPrefix()));
- if (detailElement != null) {
- return detailElement;
- }
+ protected void setNewElement(OMElement myElement, OMElement newElement) {
+ if (myElement != null) {
+ myElement.discard();
}
- return null;
+ this.addChild(newElement);
+ myElement = newElement;
}
- /**
- * Method getException
- *
- * @return
- * @throws OMException
- */
- public Exception getException() throws OMException {
- if (e == null) {
- OMNode detailsInformationNode = this.getDetailInformation();
- if (detailsInformationNode instanceof OMElement) {
- try {
- StringWriter sw = new StringWriter();
- XMLStreamWriter writer =
- XMLOutputFactory.newInstance().createXMLStreamWriter(
- sw);
- ((OMElement) detailsInformationNode).serializeWithCache(writer);
- writer.flush();
- return new Exception(sw.toString());
- } catch (XMLStreamException e1) {
- throw new OMException("Exception in StAX Writer", e1);
- }
- } else if (detailsInformationNode instanceof OMText) {
- return new Exception(
- ((OMText) detailsInformationNode).getText());
+ protected OMElement getChildWithName(String childName) {
+ Iterator childrenIter = getChildren();
+ while (childrenIter.hasNext()) {
+ OMNode node = (OMNode) childrenIter.next();
+ if (node.getType() == OMNode.ELEMENT_NODE && childName.equals(((OMElement) node).getLocalName())) {
+ return (OMElement) node;
}
- } else {
- return e;
}
return null;
}
+
}
Added: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultNodeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultNodeImpl.java?rev=191524&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultNodeImpl.java (added)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultNodeImpl.java Mon Jun 20 10:58:56 2005
@@ -0,0 +1,49 @@
+package org.apache.axis.soap.impl.llom;
+
+import org.apache.axis.om.impl.llom.OMElementImpl;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.om.OMException;
+import org.apache.axis.soap.SOAPFaultNode;
+import org.apache.axis.soap.SOAPFault;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12Constants;
+
+import javax.xml.namespace.QName;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public abstract class SOAPFaultNodeImpl extends SOAPElement implements SOAPFaultNode{
+
+ public SOAPFaultNodeImpl(SOAPFault parent) throws SOAPProcessingException {
+ super(parent, SOAP12Constants.SOAP_FAULT_NODE_LOCAL_NAME, true);
+ }
+
+ public SOAPFaultNodeImpl(SOAPFault parent, OMXMLParserWrapper builder) {
+ super(parent, SOAP12Constants.SOAP_FAULT_NODE_LOCAL_NAME, builder);
+ }
+
+ public void setNodeValue(String uri) {
+ this.setText(uri);
+ }
+
+ public String getNodeValue() {
+ return this.getText();
+ }
+}
Added: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultReasonImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultReasonImpl.java?rev=191524&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultReasonImpl.java (added)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultReasonImpl.java Mon Jun 20 10:58:56 2005
@@ -0,0 +1,65 @@
+package org.apache.axis.soap.impl.llom;
+
+import org.apache.axis.om.impl.llom.OMElementImpl;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.om.OMException;
+import org.apache.axis.soap.SOAPFaultReason;
+import org.apache.axis.soap.SOAPFaultText;
+import org.apache.axis.soap.SOAPFault;
+import org.apache.axis.soap.impl.llom.util.UtilProvider;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12Constants;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ */
+public abstract class SOAPFaultReasonImpl extends SOAPElement implements SOAPFaultReason{
+ protected SOAPFaultText text;
+
+ /**
+ * Constructor OMElementImpl
+ *
+ * @param parent
+ * @param builder
+ */
+ public SOAPFaultReasonImpl(SOAPFault parent, OMXMLParserWrapper builder) {
+ super(parent, SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME, builder);
+ }
+
+ /**
+ * @param parent
+ */
+ public SOAPFaultReasonImpl(OMElement parent, boolean extractNamespaceFromParent) throws SOAPProcessingException {
+ super(parent, SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME, extractNamespaceFromParent);
+ }
+
+ /**
+ * Eran Chinthaka (chinthaka@apache.org)
+ */
+ public void setSOAPText(SOAPFaultText soapFaultText) throws SOAPProcessingException {
+ UtilProvider.setNewElement(this, text, soapFaultText);
+ }
+
+ public SOAPFaultText getSOAPText() {
+ if (text == null) {
+ text = (SOAPFaultText) UtilProvider.getChildWithName(this, SOAP12Constants.SOAP_FAULT_TEXT_LOCAL_NAME);
+ }
+ return text;
+ }
+}
Added: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultRoleImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultRoleImpl.java?rev=191524&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultRoleImpl.java (added)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultRoleImpl.java Mon Jun 20 10:58:56 2005
@@ -0,0 +1,49 @@
+package org.apache.axis.soap.impl.llom;
+
+import org.apache.axis.om.impl.llom.OMElementImpl;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.soap.*;
+import org.apache.axis.soap.SOAPFaultRole;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12Constants;
+
+import javax.xml.namespace.QName;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public abstract class SOAPFaultRoleImpl extends SOAPElement implements org.apache.axis.soap.SOAPFaultRole{
+
+ public SOAPFaultRoleImpl(SOAPFault parent, boolean extractNamespaceFromParent) throws SOAPProcessingException {
+ super(parent, SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME, extractNamespaceFromParent);
+ }
+
+ public SOAPFaultRoleImpl(SOAPFault parent, OMXMLParserWrapper builder) {
+ super(parent, SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME, builder);
+ }
+
+ public void setRoleValue(String uri) {
+ this.setText(uri);
+ }
+
+ public String getRoleValue() {
+ return this.getText();
+ }
+}
Added: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultSubCodeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultSubCodeImpl.java?rev=191524&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultSubCodeImpl.java (added)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultSubCodeImpl.java Mon Jun 20 10:58:56 2005
@@ -0,0 +1,70 @@
+package org.apache.axis.soap.impl.llom;
+
+import org.apache.axis.om.impl.llom.OMElementImpl;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.om.OMException;
+import org.apache.axis.soap.SOAPFaultSubCode;
+import org.apache.axis.soap.SOAPFaultValue;
+import org.apache.axis.soap.SOAPFaultValue;
+import org.apache.axis.soap.impl.llom.util.UtilProvider;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12Constants;
+
+import javax.xml.namespace.QName;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public abstract class SOAPFaultSubCodeImpl extends SOAPElement implements SOAPFaultSubCode {
+
+ protected SOAPFaultValue value;
+ protected SOAPFaultSubCode subCode;
+
+
+ protected SOAPFaultSubCodeImpl(OMElement parent, String localName) throws SOAPProcessingException {
+ super(parent, localName, true);
+ }
+
+ protected SOAPFaultSubCodeImpl(OMElement parent, String localName, OMXMLParserWrapper builder) {
+ super(parent, localName, builder);
+ }
+
+ public void setValue(SOAPFaultValue soapFaultSubCodeValue) throws SOAPProcessingException {
+ UtilProvider.setNewElement(this, value, soapFaultSubCodeValue);
+ }
+
+ public SOAPFaultValue getValue() {
+ if (value == null) {
+ value = (SOAPFaultValue) UtilProvider.getChildWithName(this, SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME);
+ }
+ return value;
+ }
+
+ public void setSubCode(SOAPFaultSubCode subCode) throws SOAPProcessingException {
+ UtilProvider.setNewElement(this, this.subCode, subCode);
+
+ }
+
+ public SOAPFaultSubCode getSubCode() {
+ if (subCode == null) {
+ subCode = (SOAPFaultSubCode) UtilProvider.getChildWithName(this, SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME);
+ }
+ return subCode;
+ }
+}
Added: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultTextImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultTextImpl.java?rev=191524&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultTextImpl.java (added)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultTextImpl.java Mon Jun 20 10:58:56 2005
@@ -0,0 +1,54 @@
+package org.apache.axis.soap.impl.llom;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMAttribute;
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.om.impl.llom.OMElementImpl;
+import org.apache.axis.om.impl.llom.OMAttributeImpl;
+import org.apache.axis.soap.SOAPFaultText;
+import org.apache.axis.soap.SOAPFaultReason;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12Constants;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ */
+public abstract class SOAPFaultTextImpl extends SOAPElement implements SOAPFaultText {
+ protected OMAttribute langAttr;
+
+ protected SOAPFaultTextImpl(SOAPFaultReason parent) throws SOAPProcessingException {
+ super(parent, SOAP12Constants.SOAP_FAULT_TEXT_LOCAL_NAME, true);
+ }
+
+ protected SOAPFaultTextImpl(SOAPFaultReason parent, OMXMLParserWrapper builder) {
+ super(parent, SOAP12Constants.SOAP_FAULT_TEXT_LOCAL_NAME, builder);
+ }
+
+
+ public void setLang(String lang) {
+ langAttr = new OMAttributeImpl(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME, parent.getNamespace(), lang);
+ this.addAttribute(langAttr);
+ }
+
+ public String getLang() {
+ if (langAttr == null) {
+ langAttr = this.getFirstAttribute(new QName(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME, parent.getNamespace().getName()));
+ }
+
+ return langAttr.getValue();
+ }
+}
Added: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultValueImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultValueImpl.java?rev=191524&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultValueImpl.java (added)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultValueImpl.java Mon Jun 20 10:58:56 2005
@@ -0,0 +1,41 @@
+package org.apache.axis.soap.impl.llom;
+
+import org.apache.axis.om.impl.llom.OMElementImpl;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.om.OMException;
+import org.apache.axis.soap.SOAPFaultValue;
+import org.apache.axis.soap.SOAPFaultValue;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12Constants;
+
+import javax.xml.namespace.QName;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public abstract class SOAPFaultValueImpl extends SOAPElement implements SOAPFaultValue{
+
+ protected SOAPFaultValueImpl(OMElement parent) throws SOAPProcessingException {
+ super(parent, SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME, true);
+ }
+
+ protected SOAPFaultValueImpl(OMElement parent, OMXMLParserWrapper builder) {
+ super(parent, SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME, builder);
+ }
+}
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPHeaderBlockImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPHeaderBlockImpl.java?rev=191524&r1=191523&r2=191524&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPHeaderBlockImpl.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPHeaderBlockImpl.java Mon Jun 20 10:58:56 2005
@@ -23,6 +23,7 @@
import org.apache.axis.om.impl.llom.OMElementImpl;
import org.apache.axis.om.impl.llom.OMNamespaceImpl;
import org.apache.axis.soap.SOAPHeaderBlock;
+import org.apache.axis.soap.SOAPHeader;
import org.apache.axis.soap.impl.llom.soap11.SOAP11Constants;
import javax.xml.namespace.QName;
@@ -30,7 +31,7 @@
/**
* Class SOAPHeaderBlockImpl
*/
-public class SOAPHeaderBlockImpl extends OMElementImpl
+public abstract class SOAPHeaderBlockImpl extends OMElementImpl
implements SOAPHeaderBlock {
private boolean processed = false;
@@ -38,8 +39,9 @@
* @param localName
* @param ns
*/
- public SOAPHeaderBlockImpl(String localName, OMNamespace ns) {
- super(localName, ns);
+ public SOAPHeaderBlockImpl(String localName, OMNamespace ns, SOAPHeader parent) throws SOAPProcessingException {
+ super(localName, ns, parent);
+ this.setNamespace(ns);
}
/**
@@ -53,106 +55,40 @@
public SOAPHeaderBlockImpl(String localName, OMNamespace ns,
OMElement parent, OMXMLParserWrapper builder) {
super(localName, ns, parent, builder);
- }
-
- /**
- * Sets the actor associated with this <CODE>
- * SOAPHeaderBlock</CODE> object to the specified actor. The
- * default value of an actor is: <CODE>
- * OMConstants.URI_SOAP_ACTOR_NEXT</CODE>
- *
- * @param actorURI a <CODE>String</CODE> giving
- * the URI of the actor to set
- * @throws IllegalArgumentException if
- * there is a problem in setting the actor.
- * @see #getRole() getRole()
- */
- public void setRole(String actorURI) {
- setAttribute(SOAPConstants.ATTR_ACTOR, actorURI);
+ this.setNamespace(ns);
}
/**
* @param attributeName
* @param attrValue
*/
- private void setAttribute(String attributeName, String attrValue) {
+ protected void setAttribute(String attributeName, String attrValue, String soapEnvelopeNamespaceURI) {
OMAttribute omAttribute = this.getFirstAttribute(
- new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI, attributeName));
+ new QName(soapEnvelopeNamespaceURI, attributeName));
if (omAttribute != null) {
omAttribute.setValue(attrValue);
} else {
OMAttribute attribute = new OMAttributeImpl(
attributeName,
new OMNamespaceImpl(
- SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
+ soapEnvelopeNamespaceURI,
SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX), attrValue);
this.addAttribute(attribute);
}
}
/**
- * Returns the uri of the actor associated with this <CODE>
- * SOAPHeaderBlock</CODE> object.
- *
- * @return a <CODE>String</CODE> giving the URI of the
- * actor
- * @see #setRole(String) setRole(java.lang.String)
- */
- public String getRole() {
- return getAttribute(SOAPConstants.ATTR_ACTOR);
- }
-
- /**
* Method getAttribute
*
* @param attrName
* @return
*/
- private String getAttribute(String attrName) {
+ protected String getAttribute(String attrName, String soapEnvelopeNamespaceURI) {
OMAttribute omAttribute = this.getFirstAttribute(
- new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI, attrName));
+ new QName(soapEnvelopeNamespaceURI, attrName));
return (omAttribute != null)
? omAttribute.getValue()
: null;
- }
-
- /**
- * Sets the mustUnderstand attribute for this <CODE>
- * SOAPHeaderBlock</CODE> object to be on or off.
- * <P>If the mustUnderstand attribute is on, the actor who
- * receives the <CODE>SOAPHeaderBlock</CODE> must process it
- * correctly. This ensures, for example, that if the <CODE>
- * SOAPHeaderBlock</CODE> object modifies the message, that
- * the message is being modified correctly.</P>
- *
- * @param mustUnderstand <CODE>true</CODE> to
- * set the mustUnderstand attribute on; <CODE>false</CODE>
- * to turn if off
- * @throws IllegalArgumentException if
- * there is a problem in setting the actor.
- * @see #getMustUnderstand() getMustUnderstand()
- */
- public void setMustUnderstand(boolean mustUnderstand) {
- setAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND, mustUnderstand
- ? "true"
- : "false");
- }
-
- /**
- * Returns whether the mustUnderstand attribute for this
- * <CODE>SOAPHeaderBlock</CODE> object is turned on.
- *
- * @return <CODE>true</CODE> if the mustUnderstand attribute of
- * this <CODE>SOAPHeaderBlock</CODE> object is turned on;
- * <CODE>false</CODE> otherwise
- */
- public boolean getMustUnderstand() {
- String mustUnderstand = "";
- if ((mustUnderstand = getAttribute(SOAPConstants.ATTR_MUSTUNDERSTAND))
- != null) {
- return mustUnderstand.equalsIgnoreCase("true") || mustUnderstand.equalsIgnoreCase("1") ;
- }
- return false;
}
public boolean isProcessed() {
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPHeaderImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPHeaderImpl.java?rev=191524&r1=191523&r2=191524&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPHeaderImpl.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPHeaderImpl.java Mon Jun 20 10:58:56 2005
@@ -17,29 +17,23 @@
import org.apache.axis.om.*;
import org.apache.axis.om.impl.llom.OMElementImpl;
-import org.apache.axis.om.impl.llom.traverse.OMChildrenWithSpecificAttributeIterator;
import org.apache.axis.soap.SOAPEnvelope;
import org.apache.axis.soap.SOAPHeader;
import org.apache.axis.soap.SOAPHeaderBlock;
-import org.apache.axis.soap.impl.llom.soap11.SOAP11Constants;
-import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.Iterator;
/**
* Class SOAPHeaderImpl
*/
-public class SOAPHeaderImpl extends OMElementImpl implements SOAPHeader {
+public abstract class SOAPHeaderImpl extends SOAPElement implements SOAPHeader {
/**
* @param envelope
*/
- public SOAPHeaderImpl(SOAPEnvelope envelope) {
- super(envelope);
+ public SOAPHeaderImpl(SOAPEnvelope envelope) throws SOAPProcessingException {
+ super(envelope, SOAPConstants.HEADER_LOCAL_NAME, true);
- // set the namespaces
- this.ns = envelope.getNamespace();
- this.localName = SOAPConstants.HEADER_LOCAL_NAME;
}
/**
@@ -49,10 +43,7 @@
* @param builder
*/
public SOAPHeaderImpl(SOAPEnvelope envelope, OMXMLParserWrapper builder) {
- super(SOAPConstants.HEADER_LOCAL_NAME,
- (envelope == null) ? null : envelope.getNamespace(),
- envelope,
- builder);
+ super(envelope, SOAPConstants.HEADER_LOCAL_NAME, builder);
}
/**
@@ -66,17 +57,8 @@
* @throws org.apache.axis.om.OMException if a SOAP error occurs
* @throws OMException
*/
- public SOAPHeaderBlock addHeaderBlock(String localName, OMNamespace ns)
- throws OMException {
- if (ns == null || ns.getName() == null || "".equals(ns.getName())) {
- throw new OMException("All the SOAP Header blocks should be namespace qualified");
- }
- SOAPHeaderBlock soapHeaderBlock =
- new SOAPHeaderBlockImpl(localName, ns);
- this.addChild(soapHeaderBlock);
- soapHeaderBlock.setComplete(true);
- return soapHeaderBlock;
- }
+ public abstract SOAPHeaderBlock addHeaderBlock(String localName, OMNamespace ns)
+ throws OMException;
/**
* Returns a list of all the <CODE>SOAPHeaderBlock</CODE> objects in this
@@ -112,25 +94,19 @@
/**
* Returns a list of all the <CODE>SOAPHeaderBlock</CODE> objects in this
- * <CODE>SOAPHeader</CODE> object that have the the specified actor and
+ * <CODE>SOAPHeader</CODE> object that have the the specified role and
* detaches them from this <CODE> SOAPHeader</CODE> object. <P>This method
- * allows an actor to process only the parts of the <CODE>SOAPHeader</CODE>
+ * allows an role to process only the parts of the <CODE>SOAPHeader</CODE>
* object that apply to it and to remove them before passing the message on
- * to the next actor.
+ * to the next role.
*
- * @param actor a <CODE>String</CODE> giving the URI of the actor for which
- * to search
+ * @param role a <CODE>String</CODE> giving the URI of the role for which to
+ * search
* @return an <CODE>Iterator</CODE> object over all the <CODE>
- * SOAPHeaderBlock</CODE> objects that contain the specified actor
+ * SOAPHeaderBlock</CODE> objects that contain the specified role
* @see #examineHeaderBlocks(String) examineHeaderBlocks(java.lang.String)
*/
- public Iterator extractHeaderBlocks(String actor) {
- return new OMChildrenWithSpecificAttributeIterator(getFirstChild(),
- new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
- SOAPConstants.ATTR_ACTOR),
- actor,
- true);
- }
+ public abstract Iterator extractHeaderBlocks(String role);
/**
* Returns an <code>Iterator</code> over all the <code>SOAPHeaderBlock</code>
@@ -144,13 +120,7 @@
* <code>SOAPHeaderBlock</code> objects that contain the specified
* actor and are marked as MustUnderstand
*/
- public Iterator examineMustUnderstandHeaderBlocks(String actor) {
- return new OMChildrenWithSpecificAttributeIterator(getFirstChild(),
- new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
- SOAPConstants.ATTR_ACTOR),
- actor,
- false);
- }
+ public abstract Iterator examineMustUnderstandHeaderBlocks(String actor);
/**
* Returns an <code>Iterator</code> over all the <code>SOAPHeaderBlock</code>
@@ -187,9 +157,9 @@
if (header != null) {
headers = new ArrayList();
}
-
+
node = header;
-
+
while (node != null) {
if (node.getType() == OMNode.ELEMENT_NODE) {
header = (OMElement) node;
@@ -202,6 +172,12 @@
}
return headers;
+ }
+
+ protected void checkParent(OMElement parent) throws SOAPProcessingException {
+ if (!(parent instanceof SOAPEnvelopeImpl)) {
+ throw new SOAPProcessingException("Expecting an implementation of SOAP Envelope as the parent. But received some other implementation");
+ }
}
}
Added: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPProcessingException.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPProcessingException.java?rev=191524&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPProcessingException.java (added)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPProcessingException.java Mon Jun 20 10:58:56 2005
@@ -0,0 +1,32 @@
+package org.apache.axis.soap.impl.llom;
+
+import org.apache.axis.om.OMException;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ */
+public class SOAPProcessingException extends OMException {
+ /**
+ * Eran Chinthaka (chinthaka@apache.org)
+ */
+ public SOAPProcessingException(String message) {
+ super(message); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public SOAPProcessingException(Throwable cause) {
+ super(cause);
+ }
+}
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPTextImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPTextImpl.java?rev=191524&r1=191523&r2=191524&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPTextImpl.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPTextImpl.java Mon Jun 20 10:58:56 2005
@@ -1,8 +1,10 @@
package org.apache.axis.soap.impl.llom;
import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMXMLParserWrapper;
import org.apache.axis.om.impl.llom.OMElementImpl;
-import org.apache.axis.soap.SOAPText;
+import org.apache.axis.soap.SOAPFaultText;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12Constants;
/**
* Copyright 2001-2004 The Apache Software Foundation.
@@ -20,23 +22,26 @@
* the License.
* <p/>
*/
-public class SOAPTextImpl extends OMElementImpl implements SOAPText{
- /**
- * Eran Chinthaka (chinthaka@apache.org)
- */
- /**
- * @param parent
- * @param parent
- */
- public SOAPTextImpl(OMElement parent) {
- super(parent);
+public class SOAPTextImpl extends SOAPElement{
+
+ protected SOAPTextImpl(OMElement parent) throws SOAPProcessingException {
+ super(parent, SOAP12Constants.SOAP_FAULT_TEXT_LOCAL_NAME, true);
+ }
+
+ protected SOAPTextImpl(OMElement parent, OMXMLParserWrapper builder) {
+ super(parent, SOAP12Constants.SOAP_FAULT_TEXT_LOCAL_NAME, builder);
}
public void setLang(String lang) {
- //To change body of implemented methods use File | Settings | File Templates.
+ // TODO : Chinthaka fix me
}
public String getLang() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ // TODO Chinthaka fix me
+ return null;
+ }
+
+ protected void checkParent(OMElement parent) throws SOAPProcessingException {
+ // do nothing
}
}
Added: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/SOAP11BuilderHelper.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/SOAP11BuilderHelper.java?rev=191524&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/SOAP11BuilderHelper.java (added)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/SOAP11BuilderHelper.java Mon Jun 20 10:58:56 2005
@@ -0,0 +1,143 @@
+package org.apache.axis.soap.impl.llom.builder;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.OMText;
+import org.apache.axis.om.impl.llom.exception.OMBuilderException;
+import org.apache.axis.soap.impl.llom.builder.StAXSOAPModelBuilder;
+import org.apache.axis.soap.impl.llom.soap11.SOAP11Constants;
+import org.apache.axis.soap.impl.llom.SOAPProcessingException;
+import org.apache.axis.soap.*;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public class SOAP11BuilderHelper extends SOAPBuilderHelper implements SOAP11Constants {
+ private SOAPFactory factory;
+ private boolean faultcodePresent = false;
+ private boolean faultstringPresent = false;
+
+ private OMElement lastProcessedSOAPElement;
+
+ public SOAP11BuilderHelper(StAXSOAPModelBuilder builder) {
+ super(builder);
+ factory = OMAbstractFactory.getSOAP11Factory();
+ }
+
+ public OMElement handleEvent(XMLStreamReader parser, OMElement parent, int elementLevel) throws SOAPProcessingException {
+ this.parser = parser;
+
+ OMElement element = null;
+ String localName = parser.getLocalName();
+
+ if (elementLevel == 4) {
+
+ if (SOAP_FAULT_CODE_LOCAL_NAME.equals(localName)) {
+ if (faultstringPresent) {
+ builder.setBooleanProcessingMandatoryFaultElements(false);
+ }
+ SOAPFaultCode code = factory.createSOAPFaultCode((SOAPFault) parent, builder);
+ SOAPFaultValue value = factory.createSOAPFaultValue(code);
+ processNamespaceData(code, true);
+ processAttributes(code);
+
+ processText(parser, value);
+ code.setComplete(true);
+ element = code;
+ builder.elementLevel--;
+
+ faultcodePresent = true;
+ } else if (SOAP_FAULT_STRING_LOCAL_NAME.equals(localName)) {
+ if (faultcodePresent) {
+ builder.setBooleanProcessingMandatoryFaultElements(false);
+ }
+
+
+ SOAPFaultReason reason = factory.createSOAPFaultReason((SOAPFault) parent, builder);
+ SOAPFaultText faultText = factory.createSOAPFaultText(reason);
+ processNamespaceData(reason, true);
+ processAttributes(reason);
+
+ processText(parser, faultText);
+ reason.setComplete(true);
+ element = reason;
+ builder.elementLevel--;
+
+
+ faultstringPresent = true;
+ } else if (SOAP_FAULT_ACTOR_LOCAL_NAME.equals(localName)) {
+ element = factory.createSOAPFaultRole((SOAPFault) parent, builder);
+ processNamespaceData(element, true);
+ processAttributes(element);
+ } else if (SOAP_FAULT_DETAIL_LOCAL_NAME.equals(localName)) {
+ element = factory.createSOAPFaultDetail((SOAPFault) parent, builder);
+ processNamespaceData(element, true);
+ processAttributes(element);
+ } else {
+ element = OMAbstractFactory.getOMFactory().createOMElement(localName, null, parent, builder);
+ processNamespaceData(element, true);
+ processAttributes(element);
+ }
+
+ } else if (elementLevel == 5) {
+
+ if (parent.getLocalName().equals(SOAP_FAULT_CODE_LOCAL_NAME)) {
+ throw new OMBuilderException("faultcode element should not have children");
+ } else if (parent.getLocalName().equals(SOAP_FAULT_STRING_LOCAL_NAME)) {
+ throw new OMBuilderException("faultstring element should not have children");
+ } else if (parent.getLocalName().equals(SOAP_FAULT_ACTOR_LOCAL_NAME)) {
+ throw new OMBuilderException("faultactor element should not have children");
+ } else {
+ element = OMAbstractFactory.getOMFactory().createOMElement(localName, null, parent, builder);
+ processNamespaceData(element, true);
+ processAttributes(element);
+ }
+
+ } else if (elementLevel > 5) {
+ element = OMAbstractFactory.getOMFactory().createOMElement(localName, null, parent, builder);
+ processNamespaceData(element, true);
+ processAttributes(element);
+ }
+
+ return element;
+ }
+
+ private void processText(XMLStreamReader parser, OMElement value) {
+ try {
+ int token = parser.next();
+ while (token != XMLStreamReader.END_ELEMENT) {
+ if (token == XMLStreamReader.CHARACTERS) {
+ OMText text = factory.createText(value, parser.getText());
+ value.addChild(text);
+ } else {
+ throw new SOAPProcessingException("Only Characters are allowed here");
+ }
+ token = parser.next();
+ }
+
+
+ } catch (XMLStreamException e) {
+ throw new SOAPProcessingException(e);
+ }
+ }
+
+}
\ No newline at end of file
Added: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/SOAP12BuilderHelper.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/SOAP12BuilderHelper.java?rev=191524&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/SOAP12BuilderHelper.java (added)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/SOAP12BuilderHelper.java Mon Jun 20 10:58:56 2005
@@ -0,0 +1,242 @@
+package org.apache.axis.soap.impl.llom.builder;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.impl.llom.exception.OMBuilderException;
+import org.apache.axis.soap.impl.llom.builder.StAXSOAPModelBuilder;
+import org.apache.axis.soap.impl.llom.SOAPConstants;
+import org.apache.axis.soap.impl.llom.SOAPProcessingException;
+import org.apache.axis.soap.impl.llom.SOAPFaultCodeImpl;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12Constants;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12FaultCodeImpl;
+import org.apache.axis.soap.*;
+
+import javax.xml.stream.XMLStreamReader;
+import java.util.Vector;
+
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* author : Eran Chinthaka (chinthaka@apache.org)
+*/
+
+public class SOAP12BuilderHelper extends SOAPBuilderHelper {
+
+ private SOAPFactory factory;
+ private boolean codePresent = false;
+ private boolean reasonPresent = false;
+ private boolean nodePresent = false;
+ private boolean rolePresent = false;
+ private boolean detailPresent = false;
+ private boolean subcodeValuePresent = false;
+ private boolean subSubcodePresent = false;
+ private boolean valuePresent = false;
+ private boolean subcodePresent = false;
+ private boolean codeprocessing = false;
+ private boolean subCodeProcessing = false;
+ private boolean reasonProcessing = false;
+ private Vector detailElementNames;
+
+ public SOAP12BuilderHelper(StAXSOAPModelBuilder builder) {
+ super(builder);
+ factory = OMAbstractFactory.getSOAP12Factory();
+ }
+
+ public OMElement handleEvent(XMLStreamReader parser, OMElement parent, int elementLevel) throws SOAPProcessingException {
+
+ this.parser = parser;
+ OMElement element = null;
+
+ if (elementLevel == 4) {
+ if (parser.getLocalName().equals(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME)) {
+ if (codePresent) {
+ throw new OMBuilderException("Multiple Code element encountered");
+ } else {
+ element = factory.createSOAPFaultCode((SOAPFault) parent, null);
+ codePresent = true;
+ codeprocessing = true;
+ }
+ } else if (parser.getLocalName().equals(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME)) {
+ if (!codeprocessing && !subCodeProcessing) {
+ if (codePresent) {
+ if (reasonPresent) {
+ throw new OMBuilderException("Multiple Reason Element encountered");
+ } else {
+ element = factory.createSOAPFaultReason((SOAPFault) parent, null);
+ reasonPresent = true;
+ reasonProcessing = true;
+ }
+ } else {
+ throw new OMBuilderException("Wrong element order encountred at " + parser.getLocalName());
+ }
+ } else {
+ if (codeprocessing) {
+ throw new OMBuilderException("Code doesn't have a value");
+ } else {
+ throw new OMBuilderException("A subcode doesn't have a Value");
+ }
+ }
+
+ } else if (parser.getLocalName().equals(SOAP12Constants.SOAP_FAULT_NODE_LOCAL_NAME)) {
+ if (!reasonProcessing) {
+ if (reasonPresent && !rolePresent && !detailPresent) {
+ if (nodePresent) {
+ throw new OMBuilderException("Multiple Node element encountered");
+ } else {
+ element = factory.createSOAPFaultNode((SOAPFault) parent, null);
+ nodePresent = true;
+ }
+ } else {
+ throw new OMBuilderException("wrong element order encountered at " + parser.getLocalName());
+ }
+ } else {
+ throw new OMBuilderException("Reason element Should have a text");
+ }
+ } else if (parser.getLocalName().equals(SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME)) {
+ if (!reasonProcessing) {
+ if (reasonPresent && !detailPresent) {
+ if (rolePresent) {
+ throw new OMBuilderException("Multiple Role element encountered");
+ } else {
+ element = factory.createSOAPFaultRole((SOAPFault) parent, null);
+ rolePresent = true;
+ }
+ } else {
+ throw new OMBuilderException("Wrong element order encountered at " + parser.getLocalName());
+ }
+ } else {
+ throw new OMBuilderException("Reason element should have a text");
+ }
+ } else if (parser.getLocalName().equals(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)) {
+ if (!reasonProcessing) {
+ if (reasonPresent) {
+ if (detailPresent) {
+ throw new OMBuilderException("Multiple detail element encountered");
+ } else {
+ element = factory.createSOAPFaultDetail((SOAPFault) parent, null);
+ detailPresent = true;
+ }
+ } else {
+ throw new OMBuilderException("wrong element order encountered at " + parser.getLocalName());
+ }
+ } else {
+ throw new OMBuilderException("Reason element should have a text");
+ }
+ } else {
+ throw new OMBuilderException(parser.getLocalName() + " unsupported element in SOAPFault element");
+ }
+
+ } else if (elementLevel == 5) {
+ if (parent.getLocalName().equals(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME)) {
+ if (parser.getLocalName().equals(SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME)) {
+ if (!valuePresent) {
+ element = factory.createSOAPFaultValue((SOAPFaultCode) parent, null);
+ valuePresent = true;
+ codeprocessing = false;
+ } else {
+ throw new OMBuilderException("Multiple value Encountered in code element");
+ }
+
+ } else if (parser.getLocalName().equals(SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME)) {
+ if (!subcodePresent) {
+ if (valuePresent) {
+ element = factory.createSOAPFaultSubCode((SOAPFaultCode) parent, null);
+ subcodePresent = true;
+ subCodeProcessing = true;
+ } else {
+ throw new OMBuilderException("Value should present before the subcode");
+ }
+
+ } else {
+ throw new OMBuilderException("multiple subcode Encountered in code element");
+ }
+ } else {
+ throw new OMBuilderException(parser.getLocalName() + " is not supported inside the code element");
+ }
+
+ } else if (parent.getLocalName().equals(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME)) {
+ if (parser.getLocalName().equals(SOAP12Constants.SOAP_FAULT_TEXT_LOCAL_NAME)) {
+ element = factory.createSOAPFaultText((SOAPFaultReason) parent, null);
+ element.setComplete(false);
+ reasonProcessing = false;
+ builder.setBooleanProcessingMandatoryFaultElements(false);
+ } else {
+ throw new OMBuilderException(parser.getLocalName() + " is not supported inside the reason");
+ }
+ } else if (parent.getLocalName().equals(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)) {
+ element = OMAbstractFactory.getOMFactory().createOMElement(parser.getLocalName(), null, parent, null);
+ builder.setProcessingDetailElements(true);
+ detailElementNames = new Vector();
+ detailElementNames.add(parser.getLocalName());
+
+ } else {
+ throw new OMBuilderException(parent.getLocalName() + " should not have child element");
+ }
+
+
+ } else if (elementLevel > 5) {
+ if (parent.getLocalName().equals(SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME)) {
+ if (parser.getLocalName().equals(SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME)) {
+ if (subcodeValuePresent) {
+ throw new OMBuilderException("multiple subCode value encountered");
+ } else {
+ element = factory.createSOAPFaultValue((SOAPFaultSubCode) parent, null);
+ subcodeValuePresent = true;
+ subSubcodePresent = false;
+ subCodeProcessing = false;
+ }
+ } else if (parser.getLocalName().equals(SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME)) {
+ if (subcodeValuePresent) {
+ if (!subSubcodePresent) {
+ element = factory.createSOAPFaultSubCode((SOAPFaultSubCode) parent, null);
+ subcodeValuePresent = false;
+ subSubcodePresent = true;
+ subCodeProcessing = true;
+ } else {
+ throw new OMBuilderException("multiple subcode encountered");
+ }
+ } else {
+ throw new OMBuilderException("Value should present before the subcode");
+ }
+ } else {
+ throw new OMBuilderException(parser.getLocalName() + " is not supported inside the subCode element");
+ }
+ } else if (builder.isProcessingDetailElements()) {
+ int detailElementLevel = 0;
+ boolean localNameExist = false;
+ for (int i = 0; i < detailElementNames.size(); i++) {
+ if (parent.getLocalName().equals((String) detailElementNames.get(i))) {
+ localNameExist = true;
+ detailElementLevel = i + 1;
+ }
+ }
+ if (localNameExist) {
+ detailElementNames.setSize(detailElementLevel);
+ element = OMAbstractFactory.getOMFactory().createOMElement(parser.getLocalName(), null, parent, null);
+ detailElementNames.add(parser.getLocalName());
+ }
+
+ } else {
+ throw new OMBuilderException(parent.getLocalName() + " should not have child at element level " + elementLevel);
+ }
+ }
+
+ processNamespaceData(element, false);
+ processAttributes(element);
+ return element;
+ }
+}
\ No newline at end of file
Added: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/SOAPBuilderHelper.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/SOAPBuilderHelper.java?rev=191524&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/SOAPBuilderHelper.java (added)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/SOAPBuilderHelper.java Mon Jun 20 10:58:56 2005
@@ -0,0 +1,99 @@
+package org.apache.axis.soap.impl.llom.builder;
+
+import org.apache.axis.soap.impl.llom.builder.StAXSOAPModelBuilder;
+import org.apache.axis.soap.impl.llom.soap11.SOAP11Constants;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12Constants;
+import org.apache.axis.soap.impl.llom.SOAPProcessingException;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.impl.llom.exception.OMBuilderException;
+
+import javax.xml.stream.XMLStreamReader;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public abstract class SOAPBuilderHelper {
+ protected StAXSOAPModelBuilder builder;
+ protected XMLStreamReader parser;
+
+ protected SOAPBuilderHelper(StAXSOAPModelBuilder builder) {
+ this.builder = builder;
+ }
+
+ public abstract OMElement handleEvent(XMLStreamReader parser, OMElement element, int elementLevel) throws SOAPProcessingException ;
+
+ protected void processNamespaceData(OMElement node, boolean isSOAPElement) {
+ int namespaceCount = parser.getNamespaceCount();
+ for (int i = 0; i < namespaceCount; i++) {
+ node.declareNamespace(parser.getNamespaceURI(i),
+ parser.getNamespacePrefix(i));
+ }
+
+ // set the own namespace
+ String namespaceURI = parser.getNamespaceURI();
+ String prefix = parser.getPrefix();
+ OMNamespace namespace = null;
+ if (!"".equals(namespaceURI)) {
+ if (prefix == null) {
+ // this means, this elements has a default namespace or it has inherited a default namespace from its parent
+ namespace = node.findNamespace(namespaceURI, "");
+ if (namespace == null) {
+ namespace = node.declareNamespace(namespaceURI, "");
+ }
+ } else {
+ namespace = node.findNamespace(namespaceURI, prefix);
+ }
+ node.setNamespace(namespace);
+ } else {
+
+ }
+
+
+
+ // TODO we got to have this to make sure OM reject mesagess that are not name space qualified
+ // But got to comment this to interop with Axis.1.x
+ // if (namespace == null) {
+ // throw new OMException("All elements must be namespace qualified!");
+ // }
+ if (isSOAPElement) {
+ if (node.getNamespace() != null && !node.getNamespace().getName().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI) && !node.getNamespace().getName().equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
+ throw new OMBuilderException("invalid SOAP namespace URI");
+ }
+ }
+
+ }
+
+ protected void processAttributes(OMElement node) {
+ int attribCount = parser.getAttributeCount();
+ for (int i = 0; i < attribCount; i++) {
+ OMNamespace ns = null;
+ String uri = parser.getAttributeNamespace(i);
+ if (uri.hashCode() != 0) {
+ ns = node.findNamespace(uri,
+ parser.getAttributePrefix(i));
+ }
+
+ // todo if the attributes are supposed to namespace qualified all the time
+ // todo then this should throw an exception here
+ node.addAttribute(parser.getAttributeLocalName(i),
+ parser.getAttributeValue(i), ns);
+ }
+ }
+}
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/StAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/StAXSOAPModelBuilder.java?rev=191524&r1=191523&r2=191524&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/StAXSOAPModelBuilder.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/builder/StAXSOAPModelBuilder.java Mon Jun 20 10:58:56 2005
@@ -24,6 +24,7 @@
import org.apache.axis.soap.SOAPHeader;
import org.apache.axis.soap.impl.llom.SOAPConstants;
import org.apache.axis.soap.impl.llom.SOAPEnvelopeImpl;
+import org.apache.axis.soap.impl.llom.SOAPProcessingException;
import org.apache.axis.soap.impl.llom.soap11.SOAP11Constants;
import org.apache.axis.soap.impl.llom.soap12.SOAP12Constants;
import org.apache.commons.logging.Log;
@@ -63,7 +64,21 @@
* element level 1 = envelope level element level 2 = Header or Body level
* element level 3 = HeaderElement or BodyElement level
*/
- private int elementLevel = 0;
+ int elementLevel = 0;
+
+ private boolean processingFault = false;
+
+ //added
+ /*This is used to notice whether all mandatory fault elements are present
+ */
+ private boolean processingMandatoryFaultElements = false;
+
+ //added
+ /* This is used to indicate whether detail element is processing in soap 1.2 builderhelper
+ */
+ private boolean processingDetailElements = false;
+
+ private SOAPBuilderHelper builderHelper;
/**
* Constructor StAXSOAPModelBuilder
@@ -74,21 +89,20 @@
super(parser);
soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
identifySOAPVersion();
-
parseHeaders();
}
-
+
public StAXSOAPModelBuilder(XMLStreamReader parser, SOAPFactory factory) {
- super(parser);
- soapFactory = factory;
- identifySOAPVersion();
+ super(parser);
+ soapFactory = factory;
+ identifySOAPVersion();
- parseHeaders();
- }
+ parseHeaders();
+ }
private void identifySOAPVersion() {
SOAPEnvelope soapEnvelope = getSOAPEnvelope();
- if(soapEnvelope == null){
+ if (soapEnvelope == null) {
throw new OMException("No SOAPHeader present !!");
}
@@ -97,7 +111,7 @@
envelopeNamespace = getSOAPEnvelope().findNamespace(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI, "");
} else {
log.info("SOAP 1.2 message received ..");
- soapFactory = OMAbstractFactory.getSOAP12Factory();
+ soapFactory = OMAbstractFactory.getSOAP12Factory();
}
if (envelopeNamespace == null) {
@@ -111,15 +125,15 @@
}
private void parseHeaders() {
- // by the time execution comes here the nullity of SOAPEnvelope has been cheched in the
+ // by the time execution comes here the nullity of SOAPEnvelope has been cheched in the
// identifySOAPVersion() method. So not checking getSOAPEnvelope() == null here
SOAPHeader soapHeader = getSOAPEnvelope().getHeader();
- if (soapHeader != null) {
+ if (soapHeader != null) {
while (!soapHeader.isComplete()) {
next();
}
- }else{
+ } else {
log.info("No SOAPHeaders present !!");
}
}
@@ -159,10 +173,8 @@
e.setFirstChild(node);
}
- // fill in the attributes
- processAttributes(node);
- log.info("Build the OMElelment {" + node.getNamespace().getName() + '}'
- + node.getLocalName() + "By the StaxSOAPModelBuilder");
+
+ log.info("Build the OMElelment " + node.getLocalName() + "By the StaxSOAPModelBuilder");
return node;
}
@@ -175,7 +187,7 @@
* @return
*/
protected OMElement constructNode(OMElement parent, String elementName,
- boolean isEnvelope) {
+ boolean isEnvelope) {
OMElement element = null;
if (parent == null) {
if (!elementName.equalsIgnoreCase(SOAPConstants.SOAPENVELOPE_LOCAL_NAME)) {
@@ -183,10 +195,12 @@
+ SOAPConstants.SOAPENVELOPE_LOCAL_NAME);
}
envelope =
- (SOAPEnvelopeImpl) soapFactory.createSOAPEnvelope(null,
- this);
+ (SOAPEnvelopeImpl) soapFactory.createSOAPEnvelope(this);
element = envelope;
processNamespaceData(element, true);
+ // fill in the attributes
+ processAttributes(element);
+
} else if (elementLevel == 2) {
// this is either a header or a body
@@ -204,6 +218,8 @@
// envelope.setHeader((SOAPHeader)element);
processNamespaceData(element, true);
+ processAttributes(element);
+
} else if (elementName.equals(SOAPConstants.BODY_LOCAL_NAME)) {
if (bodyPresent) {
throw new OMBuilderException("Multiple body elements encountered");
@@ -215,6 +231,8 @@
// envelope.setBody((SOAPBody)element);
processNamespaceData(element, true);
+ processAttributes(element);
+
} else {
throw new OMBuilderException(elementName
+ " is not supported here. Envelope can not have elements other than Header and Body.");
@@ -223,21 +241,43 @@
&& parent.getLocalName().equalsIgnoreCase(SOAPConstants.HEADER_LOCAL_NAME)) {
// this is a headerblock
- element = soapFactory.createSOAPHeaderBlock(elementName, null,
- parent, this);
+ try {
+ element = soapFactory.createSOAPHeaderBlock(elementName, null,
+ (SOAPHeader) parent, this);
+ } catch (SOAPProcessingException e) {
+ throw new OMBuilderException(e);
+ }
processNamespaceData(element, false);
+ processAttributes(element);
+
} else if ((elementLevel == 3) && parent.getLocalName().equalsIgnoreCase(SOAPConstants.BODY_LOCAL_NAME) && elementName.equalsIgnoreCase(SOAPConstants.BODY_FAULT_LOCAL_NAME)) {
// this is a headerblock
- element = soapFactory.createSOAPFault(null, (SOAPBody) parent,
- this);
+ element = soapFactory.createSOAPFault((SOAPBody) parent, this);
processNamespaceData(element, false);
+ processAttributes(element);
+
+
+ processingFault = true;
+
+ //added
+ processingMandatoryFaultElements = true;
+ if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(envelopeNamespace.getName())) {
+ builderHelper = new SOAP12BuilderHelper(this);
+ } else if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(envelopeNamespace.getName())) {
+ builderHelper = new SOAP11BuilderHelper(this);
+ }
+
+ } else if (elementLevel > 3 && processingFault) {
+ element = builderHelper.handleEvent(parser, parent, elementLevel);
} else {
// this is neither of above. Just create an element
element = soapFactory.createOMElement(elementName, null,
parent, this);
processNamespaceData(element, false);
+ processAttributes(element);
+
}
return element;
}
@@ -260,17 +300,28 @@
switch (token) {
case XMLStreamConstants.START_ELEMENT:
elementLevel++;
- // System.out.println("Start ==> "+parser.getLocalName());
lastNode = createOMElement();
break;
case XMLStreamConstants.CHARACTERS:
lastNode = createOMText();
break;
case XMLStreamConstants.END_ELEMENT:
- //System.out.println("End ==> "+parser.getLocalName());
-
if (lastNode.isComplete()) {
OMElement parent = lastNode.getParent();
+
+// //added
+// /*check whether all mandatory fault elements are present
+// */
+// if (parent.getLocalName().equals(SOAP12Constants.SOAPFAULT_LOCAL_NAME) && processingMandatoryFaultElements) {
+// throw new OMBuilderException("Missing mandatory fault elements");
+// }
+// //added
+// /*finish processing detail element in soap 1.2 builderhelper
+// */
+// if (parser.getLocalName().equals(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)) {
+// this.setProcessingDetailElements(false);
+// }
+
parent.setComplete(true);
lastNode = parent;
} else {
@@ -339,7 +390,7 @@
- // TODO we got to have this to make sure OM reject mesagess that are not sname space qualified
+ // TODO we got to have this to make sure OM reject mesagess that are not name space qualified
// But got to comment this to interop with Axis.1.x
// if (namespace == null) {
// throw new OMException("All elements must be namespace qualified!");
@@ -352,7 +403,23 @@
}
+ //added
+ /*these three methods to set and check detail element processing or mandatory fault element are present
+ */
public OMNamespace getEnvelopeNamespace() {
return envelopeNamespace;
}
+
+ public void setBooleanProcessingMandatoryFaultElements(boolean value) {
+ this.processingMandatoryFaultElements = value;
+ }
+
+ public boolean isProcessingDetailElements() {
+ return processingDetailElements;
+ }
+
+ public void setProcessingDetailElements(boolean value) {
+ processingDetailElements = value;
+ }
+
}