Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.wsi/wsitools/org/eclipse/wst/wsi/internal/profile/validator/impl/envelope/BP1318.java')
-rw-r--r--bundles/org.eclipse.wst.wsi/wsitools/org/eclipse/wst/wsi/internal/profile/validator/impl/envelope/BP1318.java183
1 files changed, 183 insertions, 0 deletions
diff --git a/bundles/org.eclipse.wst.wsi/wsitools/org/eclipse/wst/wsi/internal/profile/validator/impl/envelope/BP1318.java b/bundles/org.eclipse.wst.wsi/wsitools/org/eclipse/wst/wsi/internal/profile/validator/impl/envelope/BP1318.java
new file mode 100644
index 000000000..a6423b7c1
--- /dev/null
+++ b/bundles/org.eclipse.wst.wsi/wsitools/org/eclipse/wst/wsi/internal/profile/validator/impl/envelope/BP1318.java
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * Copyright (c) 2002-2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.wsi.internal.profile.validator.impl.envelope;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+
+import org.eclipse.wst.wsi.internal.WSIConstants;
+import org.eclipse.wst.wsi.internal.WSIException;
+import org.eclipse.wst.wsi.internal.analyzer.AssertionFailException;
+import org.eclipse.wst.wsi.internal.analyzer.AssertionNotApplicableException;
+import org.eclipse.wst.wsi.internal.profile.TestAssertion;
+import org.eclipse.wst.wsi.internal.profile.validator.EntryContext;
+import org.eclipse.wst.wsi.internal.profile.validator.impl.AssertionProcess;
+import org.eclipse.wst.wsi.internal.profile.validator.impl.BaseMessageValidator;
+import org.eclipse.wst.wsi.internal.report.AssertionResult;
+import org.eclipse.wst.wsi.internal.util.HTTPUtils;
+import org.eclipse.wst.wsi.internal.util.OperationSignature;
+import org.eclipse.wst.wsi.internal.util.TypesRegistry;
+import org.eclipse.wst.wsi.internal.wsdl.WSDLUtils;
+import org.eclipse.wst.wsi.internal.xml.XMLUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+/**
+ * BP1318
+ *
+ * The grandchildren elements of soap:Body do not have a soap:encodingStyle attribute.
+ */
+public class BP1318 extends AssertionProcess
+{
+ private final BaseMessageValidator validator;
+
+ /**
+ * @param BaseMessageValidator
+ */
+ public BP1318(BaseMessageValidator impl)
+ {
+ super(impl);
+ this.validator = impl;
+ }
+
+ public AssertionResult validate(
+ TestAssertion testAssertion,
+ EntryContext entryContext)
+ throws WSIException
+ {
+ try
+ {
+ if (this.validator.isOneWayResponse(entryContext))
+ throw new AssertionNotApplicableException();
+
+ // Parse message
+ Document responseDoc = entryContext.getMessageEntryDocument();
+ Document requestDoc = entryContext.getRequestDocument();
+
+ // messages are empty or invalid, DOM objects are null
+ if (responseDoc == null || requestDoc == null) {
+ throw new AssertionNotApplicableException();
+ }
+
+ //if (isFault(responseDoc))
+ // throw new AssertionNotApplicableException();
+
+ // Get SOAPAction
+ String headers = entryContext.getRequest().getHTTPHeaders();
+ String action = null;
+ if (headers != null)
+ action = (String) HTTPUtils.getHttpHeaderTokens(headers, ":").get("SOAPAction".toUpperCase());
+
+ // Get the binding that is being processed
+ Binding binding = validator.analyzerContext.getCandidateInfo().getBindings()[0];
+
+ //Create the types registry
+ TypesRegistry registry =
+ new TypesRegistry(
+ this.validator.getWSDLDocument().getDefinitions(),
+ validator);
+
+ // Find an operation match
+ OperationSignature.OperationMatch match =
+ OperationSignature.matchOperation(
+ requestDoc,
+ action,
+ binding,
+ registry);
+ if (match == null)
+ throw new AssertionNotApplicableException();
+
+ // Get the binding operation based on the match
+ BindingOperation bindingOperation = match.getOperation();
+
+ // If this is not rpc-literal, then return notApplicable result
+ if (!WSDLUtils
+ .isRpcLiteral(match.getOperationStyle(), bindingOperation))
+ {
+ throw new AssertionNotApplicableException();
+ }
+ // look for <soap:Body> elements:
+ NodeList soapBodyList =
+ responseDoc.getElementsByTagNameNS(
+ WSIConstants.NS_URI_SOAP,
+ XMLUtils.SOAP_ELEM_BODY);
+ if ((soapBodyList == null) || (soapBodyList.getLength() == 0))
+ // Response does not contain any soap Body elements
+ throw new AssertionNotApplicableException();
+
+ // check that no <soap:Body> child or grandchild elements contains a soap:encodingStyle attribute
+ // For each <soap:Body>
+ boolean grandChildFound = false;
+ for (int n = 0; n < soapBodyList.getLength(); n++)
+ {
+ Element nextBodyElem = (Element) soapBodyList.item(n);
+ // REMOVE: This will get all nodes (child, grandchildren, etc.)
+ //NodeList childList = nextBodyElem.getElementsByTagName("*");
+ NodeList childList = nextBodyElem.getChildNodes();
+ if (childList != null)
+ {
+ // check all child elements
+ for (int m = 0; m < childList.getLength(); m++)
+ {
+ if (childList.item(m).getNodeType() == Node.ELEMENT_NODE)
+ {
+ Element nextChildElem = (Element) childList.item(m);
+ // check children of this child
+ // REMOVE: This will get all nodes (child, grandchildren, etc.)
+ NodeList grandChildList = nextChildElem.getChildNodes();
+ if (grandChildList != null)
+ {
+ for (int p = 0; p < grandChildList.getLength(); p++)
+ {
+ if (grandChildList.item(p).getNodeType()
+ == Node.ELEMENT_NODE)
+ {
+ grandChildFound = true;
+ Element nextGrandChildElem =
+ (Element) grandChildList.item(p);
+ if (nextGrandChildElem
+ .getAttributeNodeNS(
+ WSIConstants.NS_URI_SOAP,
+ "encodingStyle")
+ != null)
+ {
+ // Assertion failed (ADD highlight the child here ?)
+ throw new AssertionFailException(
+ entryContext.getMessageEntry().getMessage());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (!grandChildFound)
+ {
+ throw new AssertionNotApplicableException();
+ }
+ }
+ catch (AssertionFailException e)
+ {
+ result = AssertionResult.RESULT_FAILED;
+ failureDetail = this.validator.createFailureDetail(e.getMessage(), entryContext);
+ }
+ catch (AssertionNotApplicableException e)
+ {
+ result = AssertionResult.RESULT_NOT_APPLICABLE;
+ }
+ // Return assertion result
+ return validator.createAssertionResult(testAssertion, result, failureDetail);
+ }
+} \ No newline at end of file

Back to the top