You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2006/01/04 05:29:35 UTC
svn commit: r365823 - in
/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2:
deployment/ description/ util/
Author: sanka
Date: Tue Jan 3 20:29:14 2006
New Revision: 365823
URL: http://svn.apache.org/viewcvs?rev=365823&view=rev
Log:
Fixed: If a policy is declared in axis2.xml, services.xml or service wsdl it is shown in the appropriate places in the newly created wsdl at runtime using AxisService
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisServiceBuilder.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ModuleBuilder.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ModuleDescription.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/PolicyInclude.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java?rev=365823&r1=365822&r2=365823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java Tue Jan 3 20:29:14 2006
@@ -116,7 +116,7 @@
TAG_POLICY));
if (policyElements != null) {
- processPolicyElements(policyElements, axisConfig.getPolicyInclude());
+ processPolicyElements(PolicyInclude.AXIS_POLICY, policyElements, axisConfig.getPolicyInclude());
}
// processing <wsp:PolicyReference> .. </..> elements
@@ -124,7 +124,7 @@
TAG_POLICY_REF));
if (policyRefElements != null) {
- processPolicyRefElements(policyElements, axisConfig.getPolicyInclude());
+ processPolicyRefElements(PolicyInclude.AXIS_POLICY, policyElements, axisConfig.getPolicyInclude());
}
//to process default module versions
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisServiceBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisServiceBuilder.java?rev=365823&r1=365822&r2=365823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisServiceBuilder.java Tue Jan 3 20:29:14 2006
@@ -16,14 +16,20 @@
package org.apache.axis2.deployment;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import javax.wsdl.Binding;
+import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingOutput;
import javax.wsdl.Definition;
import javax.wsdl.Input;
import javax.wsdl.Message;
@@ -31,32 +37,44 @@
import javax.wsdl.Output;
import javax.wsdl.Part;
import javax.wsdl.Port;
+import javax.wsdl.PortType;
import javax.wsdl.Service;
import javax.wsdl.Types;
import javax.wsdl.WSDLException;
import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.UnknownExtensibilityElement;
import javax.wsdl.extensions.schema.Schema;
-import javax.wsdl.extensions.soap.SOAPBinding;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLInputFactory;
import org.apache.axis2.AxisFault;
import org.apache.axis2.description.AxisMessage;
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.AxisOperationFactory;
import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.PolicyInclude;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.impl.llom.factory.OMXMLBuilderFactory;
import org.apache.axis2.util.XMLUtils;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.policy.Policy;
+import org.apache.ws.policy.PolicyConstants;
+import org.apache.ws.policy.PolicyReference;
+import org.apache.ws.policy.util.OMPolicyReader;
+import org.apache.ws.policy.util.PolicyFactory;
import org.apache.wsdl.WSDLConstants;
import org.apache.wsdl.impl.WSDLProcessingException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
+import com.ibm.wsdl.util.xml.DOM2Writer;
+
/**
* AxisServiceBuilder builds an AxisService using a WSDL document which is feed
* as a javax.wsdl.Definition or as an InputStream. If there are multiple
@@ -68,6 +86,8 @@
private static final String XMLSCHEMA_NAMESPACE_PREFIX = "xs";
+ private static final String XML_SCHEMA_LOCAL_NAME = "schema";
+
private static final String XML_SCHEMA_SEQUENCE_LOCAL_NAME = "sequence";
private static final String XML_SCHEMA_COMPLEX_TYPE_LOCAL_NAME = "complexType";
@@ -78,10 +98,20 @@
private static final String XSD_NAME = "name";
+ private static final String XSD_ELEMENT_FORM_DEFAULT = "elementFormDefault";
+
+ private static final String XSD_UNQUALIFIED = "unqualified";
+
+ private static final String XSD_TARGETNAMESPACE = "targetNamespace";
+
private static final String XSD_TYPE = "type";
private static final String XSD_REF = "ref";
+ private static final String AXIS2WRAPPED = "axis2wrapped";
+
+ private static final String XMLNS_AXIS2WRAPPED = "xmlns:axis2wrapped";
+
private int nsCount = 1;
public AxisService getAxisService(InputStream wsdlInputStream)
@@ -110,145 +140,253 @@
return getAxisService(wsdlDefinition);
}
- public AxisService getAxisService(Definition definition)
+ public AxisService getAxisService(Definition wsdl4jDefinitions)
throws WSDLProcessingException {
AxisService axisService = new AxisService();
- Map services = definition.getServices();
+ Map services = wsdl4jDefinitions.getServices();
if (services.isEmpty()) {
throw new WSDLProcessingException("no Service element is found");
}
Iterator serviceIterator = services.values().iterator();
- Service service = (Service) serviceIterator.next();
+ Service wsdl4jService = (Service) serviceIterator.next();
// setting the name
- axisService.setName(service.getQName().getLocalPart());
+ axisService.setName(wsdl4jService.getQName().getLocalPart());
+
+ /////////////////// adding Policies ////////////////////////////
+
+ PolicyInclude policyInclude = new PolicyInclude();
+
+ List wsdlPolicies = getPoliciesAsExtElements(wsdl4jDefinitions
+ .getExtensibilityElements());
+ Iterator wsdlPolicyIterator = wsdlPolicies.iterator();
+
+ while (wsdlPolicyIterator.hasNext()) {
+ Policy wsdlPolicy = (Policy) wsdlPolicyIterator.next();
+
+ if (wsdlPolicy.getPolicyURI() != null) {
+ policyInclude.registerPolicy(wsdlPolicy);
+ }
+ }
+
+ axisService.setPolicyInclude(policyInclude);
+
+ //////////////////////////////////////////////////////////////////
// setting the schema
- Types types = definition.getTypes();
- Iterator extElements = types.getExtensibilityElements().iterator();
+ Types types = wsdl4jDefinitions.getTypes();
- ExtensibilityElement extElement;
+ if (types != null) {
+ Iterator extElements = types.getExtensibilityElements().iterator();
+ ExtensibilityElement extElement;
- while (extElements.hasNext()) {
- extElement = (ExtensibilityElement) extElements.next();
+ while (extElements.hasNext()) {
+ extElement = (ExtensibilityElement) extElements.next();
- if (extElement instanceof Schema) {
- Element schemaElement = ((Schema) extElement).getElement();
- axisService.setSchema(getXMLSchema(schemaElement));
+ if (extElement instanceof Schema) {
+ Element schemaElement = ((Schema) extElement).getElement();
+ axisService.setSchema(getXMLSchema(schemaElement));
+ }
}
}
+ HashMap resolvedRPCWrapperElements = new HashMap();
+ XmlSchema xmlSchemaForWrappedElements = generateWrapperSchema(
+ wsdl4jDefinitions, resolvedRPCWrapperElements);
+
+ if (xmlSchemaForWrappedElements != null) {
+ axisService.setSchema(xmlSchemaForWrappedElements);
+ }
+
// getting the port of the service with SOAP binding
- Port port = getSOAPBindingPort(service);
+ Iterator ports = wsdl4jService.getPorts().values().iterator();
- if (port == null) {
- throw new WSDLProcessingException("no SOAPBinding Port found");
+ if (!ports.hasNext()) {
+ throw new WSDLProcessingException(
+ "atleast one Port should be specified");
}
- Binding binding = port.getBinding();
- Iterator bindingOperations = binding.getBindingOperations().iterator();
+ Port wsdl4jPort = (Port) ports.next();
+ Binding wsdl4jBinding = wsdl4jPort.getBinding();
+ PortType wsdl4jPortType = wsdl4jBinding.getPortType();
+
+ /////////////// Adding policies //////////////////////////////////
+
+ List axisServicePolicies;
+
+ // wsdl:Service
+ axisServicePolicies = getPoliciesAsExtElements(wsdl4jService
+ .getExtensibilityElements());
+ addPolicyElements(PolicyInclude.SERVICE_POLICY, axisServicePolicies,
+ policyInclude);
+
+ // wsdl:Port
+ axisServicePolicies = getPoliciesAsExtElements(wsdl4jPort
+ .getExtensibilityElements());
+ addPolicyElements(PolicyInclude.PORT_POLICY, axisServicePolicies,
+ policyInclude);
+
+ // wsdl:PortType
+ axisServicePolicies = getPoliciesAsExtAttributes(wsdl4jPortType
+ .getExtensionAttributes());
+ addPolicyElements(PolicyInclude.PORT_TYPE_POLICY, axisServicePolicies,
+ policyInclude);
+
+ // TODO wsdl:Binding
+ axisServicePolicies = getPoliciesAsExtElements(wsdl4jBinding
+ .getExtensibilityElements());
+ addPolicyElements(PolicyInclude.BINDING_POLICY, axisServicePolicies,
+ policyInclude);
+
+ //////////////////////////////////////////////////////////////////
- while (bindingOperations.hasNext()) {
- BindingOperation bindingOperation = (BindingOperation) bindingOperations
- .next();
- Operation operation = bindingOperation.getOperation();
+ Iterator wsdl4jOperations = wsdl4jPortType.getOperations().iterator();
+
+ while (wsdl4jOperations.hasNext()) {
+ Operation wsdl4jOperation = (Operation) wsdl4jOperations.next();
+ BindingOperation wsdl4jBindingOperation = wsdl4jBinding
+ .getBindingOperation(wsdl4jOperation.getName(), null, null);
+
+ AxisOperation axisOperation;
try {
- AxisOperation axisOperation = AxisOperationFactory
- .getAxisOperation(getMessageExchangePattern(bindingOperation));
+ axisOperation = AxisOperationFactory
+ .getAxisOperation(getMessageExchangePattern(wsdl4jOperation));
// setting parent
axisOperation.setParent(axisService);
// setting operation name
- axisOperation.setName(new QName(operation.getName()));
-
+ axisOperation.setName(new QName(wsdl4jOperation.getName()));
+
+ ////////////////adding Policy //////////////////////////////
+
+ PolicyInclude operationPolicyInclude = new PolicyInclude(
+ axisService.getPolicyInclude());
+
+ List operationPolicies;
+
+ // wsdl:PortType -> wsdl:Operation
+ operationPolicies = getPoliciesAsExtElements(wsdl4jOperation
+ .getExtensibilityElements());
+ addPolicyElements(PolicyInclude.OPERATION_POLICY,
+ operationPolicies, operationPolicyInclude);
+
+ // wsdl:Binding -> wsdl:Operation
+ operationPolicies = getPoliciesAsExtElements(wsdl4jBindingOperation
+ .getExtensibilityElements());
+ addPolicyElements(PolicyInclude.BINDING_OPERATOIN_POLICY,
+ operationPolicies, operationPolicyInclude);
+
+ axisOperation.setPolicyInclude(operationPolicyInclude);
+
+ ///////////////////////////////////////////////////////////////
+
// Input
- Input input = operation.getInput();
- AxisMessage inAxisMsg = axisOperation
+ Input wsdl4jInput = wsdl4jOperation.getInput();
+ BindingInput wsdl4jBindingInput = wsdl4jBindingOperation
+ .getBindingInput();
+ Message wsdl4jInputMessage = wsdl4jInput.getMessage();
+
+ AxisMessage axisInputMessage = axisOperation
.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
- Message inMsg = input.getMessage();
- if (wrapperble(inMsg)) {
- Element wrapper = getWrappedElement(definition, inMsg);
- inAxisMsg.setElementQName(new QName(wrapper
- .getNamespaceURI(), wrapper.getLocalName(), wrapper
- .getPrefix()));
+ //////////////////// adding Policies /////////////////////////
- // TODO
- // axisService.addSchema(getXmlSchema(wrapper));
+ PolicyInclude inputPolicyInclue = new PolicyInclude(
+ axisOperation.getPolicyInclude());
- } else {
- Iterator parts = inMsg.getParts().values().iterator();
- Part part = (Part) parts.next();
- QName qname = part.getElementName();
- inAxisMsg.setElementQName(qname);
-
- }
+ List inputMessagePolicies;
- // Output
- Output output = operation.getOutput();
+ // wsdl:PortType -> wsdl:Operation -> wsdl:Input
+ inputMessagePolicies = getPoliciesAsExtAttributes(wsdl4jInput
+ .getExtensionAttributes());
+ addPolicyElements(PolicyInclude.INPUT_POLICY,
+ inputMessagePolicies, inputPolicyInclue);
- if (output != null) {
+ // wsdl:Binding -> wsdl:Operation -> wsdl:Input
+ inputMessagePolicies = getPoliciesAsExtElements(wsdl4jBindingInput
+ .getExtensibilityElements());
+ addPolicyElements(PolicyInclude.BINDING_INPUT_POLICY,
+ inputMessagePolicies, inputPolicyInclue);
- AxisMessage outAxisMsg = axisOperation
- .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
- Message outMsg = output.getMessage();
+ // wsdl:Message
+ inputMessagePolicies = getPoliciesAsExtElements(wsdl4jInputMessage
+ .getExtensibilityElements());
+ addPolicyElements(PolicyInclude.MESSAGE_POLICY,
+ inputMessagePolicies, inputPolicyInclue);
- if (wrapperble(outMsg)) {
- Element wrapper = getWrappedElement(definition, outMsg);
- outAxisMsg.setElementQName(new QName(wrapper
- .getNamespaceURI(), wrapper.getLocalName(),
- wrapper.getPrefix()));
- // TODO
- // axisService.addSchema(getXmlSchema(wrapper));
+ axisInputMessage.setPolicyInclude(policyInclude);
- } else {
- Iterator parts = outMsg.getParts().values().iterator();
- Part part = (Part) parts.next();
- QName qname = part.getElementName();
- outAxisMsg.setElementQName(qname);
- }
- }
+ ///////////////////////////////////////////////////////////////
- axisService.addOperation(axisOperation);
+ // setting the element qname
+ axisInputMessage.setElementQName(generateReferenceQname(
+ new QName(wsdl4jPortType.getQName().getNamespaceURI(),
+ wsdl4jOperation.getName()), wsdl4jInputMessage,
+ findWrapppable(wsdl4jInputMessage),
+ resolvedRPCWrapperElements));
- } catch (AxisFault axisFault) {
+ Output wsdl4jOutput = wsdl4jOperation.getOutput();
+ BindingOutput wsdl4jBindingOutput = wsdl4jBindingOperation
+ .getBindingOutput();
- throw new WSDLProcessingException(axisFault.getMessage());
- }
- }
- getXmlSchemaPrefix(definition);
+ if (wsdl4jOutput != null) {
- return axisService;
- }
+ AxisMessage axisOutputMessage = axisOperation
+ .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
- private Port getSOAPBindingPort(Service service) {
- Iterator ports = service.getPorts().values().iterator();
- Port port;
- Binding binding;
- Iterator extElements;
-
- while (ports.hasNext()) {
- port = (Port) ports.next();
- binding = port.getBinding();
- extElements = binding.getExtensibilityElements().iterator();
+ Message wsdl4jOutputMessage = wsdl4jOutput.getMessage();
- while (extElements.hasNext()) {
+ /////////////// adding Policies ///////////////////////////
- if (extElements.next() instanceof SOAPBinding) {
- return port;
+ PolicyInclude outputPolicyInclude = new PolicyInclude(
+ axisService.getPolicyInclude());
+ List outputPolicies;
+
+ //wsdl:Output
+ outputPolicies = getPoliciesAsExtAttributes(wsdl4jOutput
+ .getExtensionAttributes());
+ addPolicyElements(PolicyInclude.OUTPUT_POLICY,
+ outputPolicies, outputPolicyInclude);
+
+ // BindingOutput
+ outputPolicies = getPoliciesAsExtElements(wsdl4jBindingOutput
+ .getExtensibilityElements());
+ addPolicyElements(PolicyInclude.BINDING_OUTPUT_POLICY,
+ outputPolicies, outputPolicyInclude);
+
+ //wsdl:Message
+ outputPolicies = getPoliciesAsExtElements(wsdl4jOutputMessage
+ .getExtensibilityElements());
+ addPolicyElements(PolicyInclude.MESSAGE_POLICY,
+ outputPolicies, outputPolicyInclude);
+
+ axisOutputMessage.setPolicyInclude(outputPolicyInclude);
+
+ ///////////////////////////////////////////////////////////
+
+ // setting the element qname
+ axisOutputMessage.setElementQName(generateReferenceQname(
+ new QName(wsdl4jOperation.getName()),
+ wsdl4jOutputMessage,
+ findWrapppable(wsdl4jOutputMessage),
+ resolvedRPCWrapperElements));
}
+
+ } catch (AxisFault axisFault) {
+ throw new WSDLProcessingException(axisFault.getMessage());
}
+ axisService.addOperation(axisOperation);
}
- return null;
+ return axisService;
}
- private int getMessageExchangePattern(BindingOperation bindingOperation) {
+ private int getMessageExchangePattern(Operation wsdl4jOperation) {
- if (bindingOperation.getBindingOutput() == null) {
+ if (wsdl4jOperation.getOutput() == null) {
return WSDLConstants.MEP_CONSTANT_IN_ONLY;
} else {
@@ -260,136 +398,481 @@
return (new XmlSchemaCollection()).read(element);
}
- private String getXmlSchemaPrefix(Definition definition) {
- Map namespaces = definition.getNamespaces();
+ private Document getDOMDocument() {
+ try {
+ DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
+ fac.setNamespaceAware(true);
+ return fac.newDocumentBuilder().newDocument();
+
+ } catch (ParserConfigurationException ex) {
+ throw new WSDLProcessingException(ex.getMessage());
+ }
+ }
+
+ private String getTempPrefix() {
+ return "ns" + nsCount++;
+ }
- if (namespaces.containsValue(XMLSCHEMA_NAMESPACE_URI)) {
+ private XmlSchema generateWrapperSchema(Definition wsdl4jDefinition,
+ Map resolvedRpcWrappedElementMap) {
- Iterator prefixes = namespaces.keySet().iterator();
- String prefix;
+ //TODO check me
+ Map declaredNameSpaces = wsdl4jDefinition.getNamespaces();
- while (prefixes.hasNext()) {
- prefix = (String) prefixes.next();
+ //loop through the messages. We'll populate this map with the relevant
+ // messages
+ //from the operations
+ Map messagesMap = new HashMap();
+ Map inputOperationsMap = new HashMap();
+ Map outputOperationsMap = new HashMap();
+ //this contains the required namespace imports. the key in this
+ //map would be the namaspace URI
+ Map namespaceImportsMap = new HashMap();
+ //generated complextypes. Keep in the list for writing later
+ //the key for the complexType map is the message QName
+ Map complexTypeElementsMap = new HashMap();
+ //generated Elements. Kep in the list for later writing
+ List elementElementsList = new ArrayList();
+ //list namespace prefix map. This map will include uri -> prefix
+ Map namespacePrefixMap = new HashMap();
+ ///////////////////////
+ String targetNamespaceUri = wsdl4jDefinition.getTargetNamespace();
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ // First thing is to populate the message map with the messages to
+ // process.
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ Map porttypeMap = wsdl4jDefinition.getPortTypes();
+ PortType[] porttypesArray = (PortType[]) porttypeMap.values().toArray(
+ new PortType[porttypeMap.size()]);
+ for (int j = 0; j < porttypesArray.length; j++) {
+ //we really need to do this for a single porttype!
+ List operations = porttypesArray[j].getOperations();
+ Operation op;
+ for (int k = 0; k < operations.size(); k++) {
+ op = (Operation) operations.get(k);
+ Input input = op.getInput();
+ Message message;
+ if (input != null) {
+ message = input.getMessage();
+ messagesMap.put(message.getQName(), message);
+ inputOperationsMap.put(op.getName(), message);
+
+ }
- if (XMLSCHEMA_NAMESPACE_URI.equals(namespaces.get(prefix))) {
- return prefix;
+ Output output = op.getOutput();
+ if (output != null) {
+ message = output.getMessage();
+ messagesMap.put(message.getQName(), message);
+ outputOperationsMap.put(op.getName(), message);
}
+ //todo also handle the faults here
}
+
}
- return XMLSCHEMA_NAMESPACE_PREFIX; //default prefix
- }
- private boolean wrapperble(Message message) {
- Map parts = message.getParts();
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //check whether there are messages that are wrappable. If there are no
+ // messages that are wrappable we'll
+ //just return null and endup this process
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ QName[] keys = (QName[]) messagesMap.keySet().toArray(
+ new QName[messagesMap.size()]);
+ boolean noMessagesTobeProcessed = true;
+ for (int i = 0; i < keys.length; i++) {
+ if (findWrapppable((Message) messagesMap.get(keys[i]))) {
+ noMessagesTobeProcessed = false;
+ break;
+ }
+ }
- if (parts.size() > 1) {
- return true;
+ if (noMessagesTobeProcessed) {
+ return null;
}
- Iterator iterator = parts.values().iterator();
- Part part;
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // Now we have the message list to process - Process the whole list of
+ // messages at once
+ //since
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ List resolvedMessageQNames = new ArrayList();
+ //find the xsd prefix
+ String xsdPrefix = findSchemaPrefix(declaredNameSpaces);
+ Message wsdl4jMessage;
+ //DOM document that will be the ultimate creator
+ Document document = getDOMDocument();
+ for (int i = 0; i < keys.length; i++) {
+ wsdl4jMessage = (Message) messagesMap.get(keys[i]);
+ //No need to chack the wrappable
+
+ //This message is wrappabel. However we need to see whether the
+ // message is already
+ //resolved!
+ if (!resolvedMessageQNames.contains(wsdl4jMessage.getQName())) {
+ //This message has not been touched before!. So we can go ahead
+ // now
+ Map parts = wsdl4jMessage.getParts();
+ //add the complex type
+ String name = wsdl4jMessage.getQName().getLocalPart();
+ Element newComplexType = document.createElementNS(
+ XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
+ + XML_SCHEMA_COMPLEX_TYPE_LOCAL_NAME);
+ newComplexType.setAttribute(XSD_NAME, name);
+
+ Element cmplxContentSequence = document.createElementNS(
+ XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
+ + XML_SCHEMA_SEQUENCE_LOCAL_NAME);
+ Element child;
+ Iterator iterator = parts.keySet().iterator();
+ while (iterator.hasNext()) {
+ Part part = (Part) parts.get(iterator.next());
+ //the part name
+ String elementName = part.getName();
+ boolean isTyped = true;
+ //the type name
+ QName schemaTypeName;
+ if (part.getTypeName() != null) {
+ schemaTypeName = part.getTypeName();
+ } else if (part.getElementName() != null) {
+ schemaTypeName = part.getElementName();
+ isTyped = false;
+ } else {
+ throw new RuntimeException(" Unqualified Message part!");
+ }
+
+ child = document.createElementNS(XMLSCHEMA_NAMESPACE_URI,
+ xsdPrefix + ":" + XML_SCHEMA_ELEMENT_LOCAL_NAME);
- while (iterator.hasNext()) {
- part = (Part) iterator.next();
- if (part.getTypeName() != null) {
- return true;
+ String prefix;
+ if (XMLSCHEMA_NAMESPACE_URI.equals(schemaTypeName
+ .getNamespaceURI())) {
+ prefix = xsdPrefix;
+ } else {
+ //this schema is a third party one. So we need to have
+ // an import statement in our generated schema
+ String uri = schemaTypeName.getNamespaceURI();
+ if (!namespaceImportsMap.containsKey(uri)) {
+ //create Element for namespace import
+ Element namespaceImport = document.createElementNS(
+ XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
+ + XML_SCHEMA_IMPORT_LOCAL_NAME);
+ namespaceImport.setAttribute("namespace", uri);
+ //add this to the map
+ namespaceImportsMap.put(uri, namespaceImport);
+ //we also need to associate this uri with a prefix
+ // and include that prefix
+ //in the schema's namspace declarations. So add
+ // theis particular namespace to the
+ //prefix map as well
+ prefix = getTempPrefix();
+ namespacePrefixMap.put(uri, prefix);
+ } else {
+ //this URI should be already in the namspace prefix
+ // map
+ prefix = (String) namespacePrefixMap.get(uri);
+ }
+
+ }
+ // If it's from a type the element we need to add a name and
+ // the type
+ //if not it's the element reference
+ if (isTyped) {
+ child.setAttribute(XSD_NAME, elementName);
+ child.setAttribute(XSD_TYPE, prefix + ":"
+ + schemaTypeName.getLocalPart());
+ } else {
+ child.setAttribute(XSD_REF, prefix + ":"
+ + schemaTypeName.getLocalPart());
+ }
+ cmplxContentSequence.appendChild(child);
+ }
+ newComplexType.appendChild(cmplxContentSequence);
+ //add this newly created complextype to the list
+ complexTypeElementsMap.put(wsdl4jMessage.getQName(),
+ newComplexType);
+ resolvedMessageQNames.add(wsdl4jMessage.getQName());
}
+
}
- return false;
- }
- private Document getDOMDocument() {
- try {
- DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
- fac.setNamespaceAware(true);
- return fac.newDocumentBuilder().newDocument();
+ Element elementDeclaration;
+
+ //loop through the input op map and generate the elements
+ String[] inputOperationtNames = (String[]) inputOperationsMap.keySet()
+ .toArray(new String[inputOperationsMap.size()]);
+ for (int j = 0; j < inputOperationtNames.length; j++) {
+ String inputOpName = inputOperationtNames[j];
+ elementDeclaration = document.createElementNS(
+ XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
+ + XML_SCHEMA_ELEMENT_LOCAL_NAME);
+ elementDeclaration.setAttribute(XSD_NAME, inputOpName);
+
+ String typeValue = ((Message) inputOperationsMap.get(inputOpName))
+ .getQName().getLocalPart();
+ elementDeclaration.setAttribute(XSD_TYPE, AXIS2WRAPPED + ":"
+ + typeValue);
+ elementElementsList.add(elementDeclaration);
+ resolvedRpcWrappedElementMap.put(inputOpName, new QName(
+ targetNamespaceUri, inputOpName, AXIS2WRAPPED));
+ }
+
+ //loop through the output op map and generate the elements
+ String[] outputOperationtNames = (String[]) outputOperationsMap
+ .keySet().toArray(new String[outputOperationsMap.size()]);
+ for (int j = 0; j < outputOperationtNames.length; j++) {
+
+ String baseoutputOpName = outputOperationtNames[j];
+ String outputOpName = baseoutputOpName + "Response";
+ elementDeclaration = document.createElementNS(
+ XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
+ + XML_SCHEMA_ELEMENT_LOCAL_NAME);
+ elementDeclaration.setAttribute(XSD_NAME, outputOpName);
+ String typeValue = ((Message) outputOperationsMap
+ .get(baseoutputOpName)).getQName().getLocalPart();
+ elementDeclaration.setAttribute(XSD_TYPE, AXIS2WRAPPED + ":"
+ + typeValue);
+ elementElementsList.add(elementDeclaration);
+ resolvedRpcWrappedElementMap.put(outputOpName, new QName(
+ targetNamespaceUri, outputOpName, AXIS2WRAPPED));
- } catch (ParserConfigurationException ex) {
- throw new WSDLProcessingException(ex.getMessage());
}
- }
- private Element getWrappedElement(Definition definition, Message message) {
- Document document = getDOMDocument();
- String xsdPrefix = getXmlSchemaPrefix(definition);
- Map namespaceImports = new HashMap();
- Map namespacePrefixes = new HashMap();
- Map parts = message.getParts();
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ // Now we are done with processing the messages and generating the right
+ // schema
+ // time to write out the schema
+ //////////////////////////////////////////////////////////////////////////////////////////////
- String name = message.getQName().getLocalPart();
- Element nComplexType = document.createElementNS(
+ Element schemaElement = document.createElementNS(
XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
- + XML_SCHEMA_COMPLEX_TYPE_LOCAL_NAME);
- nComplexType.setAttribute(XSD_NAME, name);
+ + XML_SCHEMA_LOCAL_NAME);
- Element contextSequence = document.createElementNS(
- XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
- + XML_SCHEMA_SEQUENCE_LOCAL_NAME);
+ //loop through the namespace declarations first
+ String[] nameSpaceDeclarationArray = (String[]) namespacePrefixMap
+ .keySet().toArray(new String[namespacePrefixMap.size()]);
+ for (int i = 0; i < nameSpaceDeclarationArray.length; i++) {
+ String s = nameSpaceDeclarationArray[i];
+ schemaElement.setAttributeNS("http://www.w3.org/2000/xmlns/",
+ "xmlns:" + namespacePrefixMap.get(s).toString(), s);
- Element childElement;
- Iterator iterator = parts.values().iterator();
+ }
+
+ //add the targetNamespace
+
+ schemaElement.setAttributeNS("http://www.w3.org/2000/xmlns/",
+ XMLNS_AXIS2WRAPPED, targetNamespaceUri);
+ schemaElement.setAttribute(XSD_TARGETNAMESPACE, targetNamespaceUri);
+ schemaElement.setAttribute(XSD_ELEMENT_FORM_DEFAULT, XSD_UNQUALIFIED);
- while (iterator.hasNext()) {
- Part part = (Part) iterator.next();
- String elementName = part.getName();
- boolean isTyped = true;
+ Element[] namespaceImports = (Element[]) namespaceImportsMap.values()
+ .toArray(new Element[namespaceImportsMap.size()]);
+ for (int i = 0; i < namespaceImports.length; i++) {
+ schemaElement.appendChild(namespaceImports[i]);
+
+ }
- QName schemaTypeName;
+ Element[] complexTypeElements = (Element[]) complexTypeElementsMap
+ .values().toArray(new Element[complexTypeElementsMap.size()]);
+ for (int i = 0; i < complexTypeElements.length; i++) {
+ schemaElement.appendChild(complexTypeElements[i]);
- if (part.getTypeName() != null) {
- schemaTypeName = part.getTypeName();
+ }
+
+ Element[] elementDeclarations = (Element[]) elementElementsList
+ .toArray(new Element[elementElementsList.size()]);
+ for (int i = 0; i < elementDeclarations.length; i++) {
+ schemaElement.appendChild(elementDeclarations[i]);
+
+ }
- } else if (part.getElementName() != null) {
- schemaTypeName = part.getElementName();
+ XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
+ Iterator prefixes = declaredNameSpaces.keySet().iterator();
- } else {
- throw new WSDLProcessingException("unqualified message part");
+ while (prefixes.hasNext()) {
+ String prefix = (String) prefixes.next();
+ String u = (String) declaredNameSpaces.get(prefix);
+ schemaCollection.mapNamespace(prefix, u);
+ }
+ return schemaCollection.read(schemaElement);
+ }
+
+ /**
+ *
+ *
+ * @return
+ */
+ private boolean findWrapppable(Message message) {
+
+ //********************************************************************************************
+ //Note
+ //We will not use the binding to set the wrappable/unwrappable state.
+ // instead we'll look at the
+ //Messages for the following features
+ //1. Messages with multiple parts -> We have no choice but to wrap
+ //2. Messages with at least one part having a type attribute -> Again
+ // we have no choice but to
+ //wrap
+
+ //********************************************************************************************
+ Map partsMap = message.getParts();
+ Iterator parts = partsMap.values().iterator();
+ boolean wrappable = partsMap.size() > 1;
+ Part part;
+ while (!wrappable && parts.hasNext()) {
+ part = (Part) parts.next();
+ wrappable = (part.getTypeName() != null) || wrappable;
+ }
+
+ return wrappable;
+ }
+
+ /**
+ * Find the XML schema prefix
+ */
+ private String findSchemaPrefix(Map declaredNameSpaces) {
+ String xsdPrefix = null;
+ if (declaredNameSpaces.containsValue(XMLSCHEMA_NAMESPACE_URI)) {
+ //loop and find the prefix
+ Iterator it = declaredNameSpaces.keySet().iterator();
+ String key;
+ while (it.hasNext()) {
+ key = (String) it.next();
+ if (XMLSCHEMA_NAMESPACE_URI.equals(declaredNameSpaces.get(key))) {
+ xsdPrefix = key;
+ break;
+ }
}
- childElement = document.createElementNS(XMLSCHEMA_NAMESPACE_URI,
- xsdPrefix + ":" + XML_SCHEMA_ELEMENT_LOCAL_NAME);
- String prefix;
+ } else {
+ xsdPrefix = XMLSCHEMA_NAMESPACE_PREFIX; //default prefix
+ }
- if (!XMLSCHEMA_NAMESPACE_URI.equals(schemaTypeName
- .getNamespaceURI())) {
- String namespace = schemaTypeName.getNamespaceURI();
+ return xsdPrefix;
+ }
- if (namespaceImports.containsKey(namespace)) {
- Element namespaceImport = document.createElementNS(
- XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
- + XML_SCHEMA_IMPORT_LOCAL_NAME);
- namespaceImport.setAttribute("namespace", namespace);
- namespaceImports.put(namespace, namespaceImport);
- prefix = getTempPrefix();
- namespacePrefixes.put(namespace, prefix);
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Generates a referenceQName
+ *
+ * @param wsdl4jMessage
+ * @return
+ */
+ private QName generateReferenceQname(QName outerName,
+ Message wsdl4jMessage, boolean isWrappable,
+ Map resolvedRpcWrappedElementMap) {
+ QName referenceQName = null;
+ if (isWrappable) {
+ //The schema for this should be already made ! Find the QName from
+ // the list
+ referenceQName = (QName) resolvedRpcWrappedElementMap.get(outerName
+ .getLocalPart());
+ } else {
+ //Only one part so copy the QName of the referenced type.
+ Iterator outputIterator = wsdl4jMessage.getParts().values()
+ .iterator();
+ if (outputIterator.hasNext()) {
+ Part outPart = ((Part) outputIterator.next());
+ QName typeName;
+ if (null != (typeName = outPart.getTypeName())) {
+ referenceQName = typeName;
} else {
- prefix = (String) namespacePrefixes.get(namespace);
+ referenceQName = outPart.getElementName();
}
-
- } else {
- prefix = xsdPrefix;
}
+ }
- if (isTyped) {
- childElement.setAttribute(XSD_NAME, elementName);
- childElement.setAttribute(XSD_TYPE, prefix + ":"
- + schemaTypeName.getLocalPart());
+ ////////////////////////////////////////////////////////////////////////////////
+ //System.out.println("final referenceQName = " + referenceQName);
+ ////////////////////////////////////////////////////////////////////////////////
+ return referenceQName;
+ }
+
+ private List getPoliciesAsExtElements(List extElementsList) {
+ ArrayList policies = new ArrayList();
- } else {
- childElement.setAttribute(XSD_REF, prefix + ":"
- + schemaTypeName.getLocalPart());
+ Iterator extElements = extElementsList.iterator();
+ OMPolicyReader reader = (OMPolicyReader) PolicyFactory
+ .getPolicyReader(PolicyFactory.OM_POLICY_READER);
+ Object extElement;
+
+ while (extElements.hasNext()) {
+ extElement = extElements.next();
+
+ if (extElement instanceof UnknownExtensibilityElement) {
+ UnknownExtensibilityElement e = (UnknownExtensibilityElement) extElement;
+ Element element = e.getElement();
+ if (PolicyConstants.WS_POLICY_NAMESPACE_URI.equals(element
+ .getNamespaceURI())
+ && PolicyConstants.WS_POLICY.equals(element
+ .getLocalName())) {
+ policies.add(reader.readPolicy(getInputStream(element)));
+
+ } else if (PolicyConstants.WS_POLICY_NAMESPACE_URI
+ .equals(element.getNamespaceURI())
+ && PolicyConstants.WS_POLICY_REFERENCE.equals(element
+ .getLocalName())) {
+
+ try {
+ policies.add(reader.readPolicyReference(
+
+ OMXMLBuilderFactory.createStAXOMBuilder(
+ OMAbstractFactory.getOMFactory(),
+ XMLInputFactory.newInstance()
+ .createXMLStreamReader(
+ getInputStream(element)))
+ .getDocumentElement()));
+
+ } catch (Exception ex) {
+ throw new WSDLProcessingException(ex.getMessage());
+ }
+ }
}
+ }
+
+ return policies;
+ }
+
+ private List getPoliciesAsExtAttributes(Map extAttributes) {
+ ArrayList policies = new ArrayList();
+
+ Object policyURIsString = extAttributes.get(new QName(
+ PolicyConstants.WS_POLICY_NAMESPACE_URI, "PolicyURIs"));
- contextSequence.appendChild(childElement);
+ if (policyURIsString != null) {
+
+ String[] policyURIs = ((QName) policyURIsString).getLocalPart()
+ .trim().split(" ");
+
+ for (int i = 0; i < policyURIs.length; i++) {
+ policies.add(new PolicyReference(policyURIs[i]));
+ }
}
- nComplexType.appendChild(contextSequence);
- return nComplexType;
+ return policies;
+ }
+ private InputStream getInputStream(Element e) {
+ StringWriter sw = new StringWriter();
+ DOM2Writer.serializeAsXML(e, sw);
+ return new ByteArrayInputStream(sw.toString().getBytes());
}
- private String getTempPrefix() {
- return "ns" + nsCount++;
+ private void addPolicyElements(int type, List policyElements,
+ PolicyInclude policyInclude) {
+ Iterator policyElementIterator = policyElements.iterator();
+ Object policyElement;
+
+ while (policyElementIterator.hasNext()) {
+ policyElement = policyElementIterator.next();
+
+ if (policyElement instanceof Policy) {
+ policyInclude.addPolicyElement(type, (Policy) policyElement);
+
+ } else if (policyElement instanceof PolicyReference) {
+ policyInclude.addPolicyRefElement(type,
+ (PolicyReference) policyElement);
+ }
+ }
}
+
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java?rev=365823&r1=365822&r2=365823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java Tue Jan 3 20:29:14 2006
@@ -376,7 +376,7 @@
return wsamapping;
}
- protected void processPolicyElements(Iterator policyElements,
+ protected void processPolicyElements(int type, Iterator policyElements,
PolicyInclude policyInclude) {
OMPolicyReader reader = (OMPolicyReader) PolicyFactory
.getPolicyReader(PolicyFactory.OM_POLICY_READER);
@@ -384,11 +384,11 @@
while (policyElements.hasNext()) {
Policy p = reader.readPolicy((OMElement) policyElements.next());
- policyInclude.addPolicyElement(p);
+ policyInclude.addPolicyElement(type, p);
}
}
- protected void processPolicyRefElements(Iterator policyRefElements,
+ protected void processPolicyRefElements(int type, Iterator policyRefElements,
PolicyInclude policyInclude) {
OMPolicyReader reader = (OMPolicyReader) PolicyFactory
.getPolicyReader(PolicyFactory.OM_POLICY_READER);
@@ -397,7 +397,7 @@
while (policyRefElements.hasNext()) {
PolicyReference policyReference = reader
.readPolicyReference((OMElement) policyRefElements.next());
- policyInclude.addPolicyRefElement(policyReference);
+ policyInclude.addPolicyRefElement(type, policyReference);
}
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ModuleBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ModuleBuilder.java?rev=365823&r1=365822&r2=365823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ModuleBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ModuleBuilder.java Tue Jan 3 20:29:14 2006
@@ -104,14 +104,14 @@
Iterator policyElements = moduleElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
if (policyElements != null) {
- processPolicyElements(policyElements, module.getPolicyInclude());
+ processPolicyElements(PolicyInclude.MODULE_POLICY, policyElements, module.getPolicyInclude());
}
// processing <wsp:PolicyReference> .. </..> elements
Iterator policyRefElements = moduleElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));
if (policyRefElements != null) {
- processPolicyRefElements(policyRefElements, module.getPolicyInclude());
+ processPolicyRefElements(PolicyInclude.MODULE_POLICY, policyRefElements, module.getPolicyInclude());
}
// processing Parameters
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java?rev=365823&r1=365822&r2=365823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java Tue Jan 3 20:29:14 2006
@@ -93,29 +93,20 @@
}
// setting the PolicyInclude
- PolicyInclude policyInclude;
-
- if (axisConfig != null) {
- PolicyInclude parent = axisConfig.getPolicyInclude();
- policyInclude = new PolicyInclude(parent);
-
- } else {
- policyInclude = new PolicyInclude();
- }
- service.setPolicyInclude(policyInclude);
+ PolicyInclude policyInclude = service.getPolicyInclude();
// processing <wsp:Policy> .. </..> elements
Iterator policyElements = service_element.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
if (policyElements != null) {
- processPolicyElements(policyElements, service.getPolicyInclude());
+ processPolicyElements(PolicyInclude.AXIS_SERVICE_POLICY, policyElements, service.getPolicyInclude());
}
// processing <wsp:PolicyReference> .. </..> elements
Iterator policyRefElements = service_element.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));
if (policyRefElements != null) {
- processPolicyRefElements(policyRefElements, service.getPolicyInclude());
+ processPolicyRefElements(PolicyInclude.AXIS_SERVICE_POLICY, policyRefElements, service.getPolicyInclude());
}
//processin Service Scop
@@ -184,34 +175,29 @@
throw new DeploymentException("message lebel can not be null");
}
- //TODO : fix that
- AxisMessage message = new AxisMessage();
+ AxisMessage message = operation.getMessage(lable.getAttributeValue());
Iterator parameters = messageElement.getChildrenWithName(new QName(TAG_PARAMETER));
// setting the PolicyInclude
- PolicyInclude parent = operation.getPolicyInclude();
- PolicyInclude policyInclude = new PolicyInclude(parent);
- message.setPolicyInclude(policyInclude);
+ PolicyInclude policyInclude = message.getPolicyInclude();
// processing <wsp:Policy> .. </..> elements
Iterator policyElements = messageElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
if (policyElements != null) {
- processPolicyElements(policyElements, message.getPolicyInclude());
+ processPolicyElements(PolicyInclude.AXIS_MESSAGE_POLICY, policyElements, message.getPolicyInclude());
}
// processing <wsp:PolicyReference> .. </..> elements
Iterator policyRefElements = messageElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));
if (policyRefElements != null) {
- processPolicyRefElements(policyRefElements, message.getPolicyInclude());
+ processPolicyRefElements(PolicyInclude.AXIS_MESSAGE_POLICY, policyRefElements, message.getPolicyInclude());
}
processParameters(parameters, message, operation);
-
- operation.addMessage(message, lable.getAttributeValue().trim());
}
}
@@ -296,6 +282,8 @@
if (mepurl == null) {
// assumed MEP is in-out
op_descrip = new InOutAxisOperation();
+ op_descrip.setParent(service);
+
} else {
op_descrip = AxisOperationFactory.getOperationDescription(mepurl);
}
@@ -303,30 +291,20 @@
}
// setting the PolicyInclude
- PolicyInclude policyInclude;
-
- if (service != null) {
- PolicyInclude parent = service.getPolicyInclude();
- policyInclude = new PolicyInclude(parent);
-
- } else {
- policyInclude = new PolicyInclude();
- }
-
- op_descrip.setPolicyInclude(policyInclude);
-
+ PolicyInclude policyInclude = op_descrip.getPolicyInclude();
+
// processing <wsp:Policy> .. </..> elements
Iterator policyElements = operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
if (policyElements != null) {
- processPolicyElements(policyElements, op_descrip.getPolicyInclude());
+ processPolicyElements(PolicyInclude.AXIS_OPERATION_POLICY, policyElements, op_descrip.getPolicyInclude());
}
// processing <wsp:PolicyReference> .. </..> elements
Iterator policyRefElements = operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));
if (policyRefElements != null) {
- processPolicyRefElements(policyRefElements, op_descrip.getPolicyInclude());
+ processPolicyRefElements(PolicyInclude.AXIS_OPERATION_POLICY, policyRefElements, op_descrip.getPolicyInclude());
}
// Operation Parameters
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java?rev=365823&r1=365822&r2=365823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java Tue Jan 3 20:29:14 2006
@@ -43,6 +43,7 @@
parameterinclude = new ParameterIncludeImpl();
handlerChain = new ArrayList();
messageReference = new MessageReferenceImpl();
+ policyInclude = new PolicyInclude();
}
public void addParameter(Parameter param) throws AxisFault {
@@ -101,6 +102,9 @@
public void setParent(AxisOperation parent) {
this.parent = parent;
+ if (parent.getPolicyInclude() != null) {
+ policyInclude.setParent(parent.getPolicyInclude());
+ }
}
public String getDirection() {
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java?rev=365823&r1=365822&r2=365823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java Tue Jan 3 20:29:14 2006
@@ -62,6 +62,7 @@
parameterInclude = new ParameterIncludeImpl();
modulerefs = new ArrayList();
moduleConfigmap = new HashMap();
+ policyInclude = new PolicyInclude();
}
public AxisOperation(QName name) {
@@ -398,6 +399,9 @@
public void setParent(AxisService parent) {
this.parent = parent;
+ if (parent.getPolicyInclude() != null) {
+ policyInclude.setParent(parent.getPolicyInclude());
+ }
}
public abstract void setPhasesInFaultFlow(ArrayList list);
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java?rev=365823&r1=365822&r2=365823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java Tue Jan 3 20:29:14 2006
@@ -102,6 +102,7 @@
//by dafault service scope is for the request
scope = Constants.SCOPE_REQUEST;
messageReceivers = new HashMap();
+ policyInclude = new PolicyInclude();
}
/**
@@ -356,7 +357,7 @@
// populate it with policy information ..
//TODO : This gives an NPE , Sanka pls fix that
-// PolicyUtil.populatePolicy(desc, this);
+ PolicyUtil.populatePolicy(desc, this);
WOMWriter womWriter = WOMWriterFactory.createWriter(WSDLConstants.WSDL_1_1);
womWriter.setdefaultWSDLPrefix("wsdl");
@@ -612,6 +613,9 @@
public void setParent(AxisServiceGroup parent) {
this.parent = parent;
+ if (parent.getPolicyInclude() != null) {
+ policyInclude.setParent(parent.getPolicyInclude());
+ }
}
public void setWSDLDefinition(Definition difDefinition) {
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java?rev=365823&r1=365822&r2=365823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java Tue Jan 3 20:29:14 2006
@@ -53,6 +53,9 @@
// to keep name of the service group
private String serviceGroupName;
+
+ // to store policy information
+ private PolicyInclude policyInclude;
/**
* Field services
@@ -64,6 +67,7 @@
services = new HashMap();
moduleConfigmap = new HashMap();
engagedModules = new ArrayList();
+ policyInclude = new PolicyInclude();
}
public AxisServiceGroup(AxisConfiguration axisDescription) {
@@ -233,6 +237,9 @@
public void setParent(AxisConfiguration parent) {
this.parent = parent;
+ if (parent.getPolicyInclude() != null) {
+ policyInclude.setParent(parent.getPolicyInclude());
+ }
}
public void setServiceGroupClassLoader(ClassLoader serviceGroupClassLoader) {
@@ -241,5 +248,13 @@
public void setServiceGroupName(String serviceGroupName) {
this.serviceGroupName = serviceGroupName;
+ }
+
+ public PolicyInclude getPolicyInclude() {
+ return policyInclude;
+ }
+
+ public void setPolicyInclude(PolicyInclude policyInclude) {
+ this.policyInclude = policyInclude;
}
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java?rev=365823&r1=365822&r2=365823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java Tue Jan 3 20:29:14 2006
@@ -52,8 +52,14 @@
private void createMessage() {
inMessage = new AxisMessage();
inMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
+ inMessage.setParent(this);
+
inFaultMessage = new AxisMessage();
+ inFaultMessage.setParent(this);
+
outFaultMessage = new AxisMessage();
+ outFaultMessage.setParent(this);
+
outPhase = new ArrayList();
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java?rev=365823&r1=365822&r2=365823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java Tue Jan 3 20:29:14 2006
@@ -62,10 +62,17 @@
private void createMessages() {
inMessage = new AxisMessage();
inMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
+ inMessage.setParent(this);
+
inFaultMessage = new AxisMessage();
+ inFaultMessage.setParent(this);
+
outFaultMessage = new AxisMessage();
+ outFaultMessage.setParent(this);
+
outMessage = new AxisMessage();
outMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
+ outMessage.setParent(this);
}
public AxisMessage getMessage(String label) {
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ModuleDescription.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ModuleDescription.java?rev=365823&r1=365822&r2=365823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ModuleDescription.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ModuleDescription.java Tue Jan 3 20:29:14 2006
@@ -68,6 +68,7 @@
*/
public ModuleDescription() {
operations = new HashMap();
+ policyInclude = new PolicyInclude();
}
/**
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/PolicyInclude.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/PolicyInclude.java?rev=365823&r1=365822&r2=365823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/PolicyInclude.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/PolicyInclude.java Tue Jan 3 20:29:14 2006
@@ -16,22 +16,61 @@
package org.apache.axis2.description;
+import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import org.apache.ws.policy.Policy;
import org.apache.ws.policy.PolicyReference;
+import org.apache.ws.policy.util.PolicyFactory;
import org.apache.ws.policy.util.PolicyRegistry;
+import org.apache.ws.policy.util.PolicyWriter;
/**
* @author Sanka Samaranayake (sanka@apache.org)
*/
public class PolicyInclude {
+ public static final String ANON_POLICY = "anonymous";
+
+ public static final int AXIS_POLICY = 1;
+
+ public static final int AXIS_SERVICE_POLICY = 2;
+
+ public static final int AXIS_OPERATION_POLICY = 14;
+
+ public static final int AXIS_MESSAGE_POLICY = 15;
+
+ public static final int MODULE_POLICY = 3;
+
+ public static final int SERVICE_POLICY = 3;
+
+ public static final int PORT_POLICY = 4;
+
+ public static final int PORT_TYPE_POLICY = 5;
+
+ public static final int BINDING_POLICY = 6;
+
+ public static final int OPERATION_POLICY = 7;
+
+ public static final int BINDING_OPERATOIN_POLICY = 8;
+
+ public static final int INPUT_POLICY = 9;
+
+ public static final int OUTPUT_POLICY = 10;
+
+ public static final int BINDING_INPUT_POLICY = 11;
+
+ public static final int BINDING_OUTPUT_POLICY = 12;
+
+ public static final int MESSAGE_POLICY = 13;
+
private Policy policy = null;
+
private Policy effectivePolicy = null;
-
+
private PolicyInclude parent = null;
+
private PolicyRegistry reg;
private ArrayList policyElements = new ArrayList();
@@ -41,17 +80,23 @@
}
public PolicyInclude(PolicyInclude parent) {
- reg = new PolicyRegistry(parent.getPolicyRegistry());
+ reg = new PolicyRegistry();
+ setParent(parent);
+ }
+
+ public void setParent(PolicyInclude parent) {
+ this.parent = parent;
+ reg.setParent(parent.getPolicyRegistry());
}
public void setPolicyRegistry(PolicyRegistry reg) {
this.reg = reg;
}
-
+
public PolicyRegistry getPolicyRegistry() {
return reg;
}
-
+
public void setPolicy(Policy policy) {
this.policy = policy;
}
@@ -60,9 +105,10 @@
if (policy == null) {
Iterator iterator = policyElements.iterator();
-
+
while (iterator.hasNext()) {
- Object policyElement = iterator.next();
+
+ Object policyElement = ((PolicyElement) iterator.next()).value;
Policy p = null;
if (policyElement instanceof PolicyReference) {
@@ -70,48 +116,102 @@
.normalize(getPolicyRegistry());
} else if (policyElement instanceof Policy) {
- p = (Policy) iterator.next();
+ p = (Policy) policyElement;
} else {
// TODO an exception ?
}
- policy = (policy == null) ? p : (Policy) policy.merge(p, reg);
+ policy = (policy == null) ? (Policy) p.normalize(reg)
+ : (Policy) policy.merge(p, reg);
}
}
+
return policy;
}
public Policy getEffectivePolicy() {
- if (parent == null || parent.getEffectivePolicy() == null) {
- return getPolicy();
+ if (effectivePolicy != null) {
+ return effectivePolicy;
}
+
+ Policy parentEffectivePolicy = parent.getEffectivePolicy();
+ if (parent == null || parentEffectivePolicy == null) {
+ return getPolicy();
+ }
+
if (getPolicy() != null) {
return parent.getEffectivePolicy();
}
-
- return (Policy) parent.getEffectivePolicy().merge(getPolicy(), reg);
+
+ return (Policy) parentEffectivePolicy.merge(getPolicy(), reg);
}
+
+ // public void setPolicyElements(ArrayList policyElements) {
+ // this.policyElements = policyElements;
+ // }
+
+ public ArrayList getPolicyElements() {
+ ArrayList policyElementsList = new ArrayList();
+ Iterator policyElementIterator = policyElements.iterator();
+
+ while (policyElementIterator.hasNext()) {
+ policyElementsList.add(((PolicyElement) policyElementIterator
+ .next()).value);
+ }
+ return policyElementsList;
+ }
+
- public void setPolicyElements(ArrayList policyElements) {
- this.policyElements = policyElements;
+ public ArrayList getPolicyElements(int type) {
+ ArrayList policyElementList = new ArrayList();
+ Iterator policyElementIterator = policyElements.iterator();
+
+ PolicyElement policyElement;
+
+ while (policyElementIterator.hasNext()) {
+ policyElement = (PolicyElement) policyElementIterator.next();
+
+ if (policyElement.type == type) {
+ policyElementList.add(policyElement.value);
+ }
+ }
+
+ return policyElementList;
+
+ }
+
+ public void registerPolicy(Policy policy) {
+ reg.register(policy.getPolicyURI(), policy);
}
- public ArrayList getPolicyElements() {
- return policyElements;
+ public Policy getPolicy(String policyURI){
+ return reg.lookup(policyURI);
}
- public void addPolicyElement(Policy policyElement) {
- if (policyElement.getPolicyURI() != null) {
- reg.register(policyElement.getPolicyURI(), policyElement);
+ public void addPolicyElement(int type, Policy policy) {
+ PolicyElement policyElement = new PolicyElement();
+ policyElement.type = type;
+ policyElement.value = policy;
+ policyElements.add(policyElement);
+
+ if (policy.getPolicyURI() != null) {
+ reg.register(policy.getPolicyURI(), policy);
}
-
+ }
+
+ public void addPolicyRefElement(int type, PolicyReference policyReference) {
+ PolicyElement policyElement = new PolicyElement();
+ policyElement.type = type;
+ policyElement.value = policyReference;
policyElements.add(policyElement);
}
- public void addPolicyRefElement(PolicyReference policyRefElement) {
- policyElements.add(policyRefElement);
+ private class PolicyElement {
+ int type;
+
+ Object value;
}
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java?rev=365823&r1=365822&r2=365823&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java Tue Jan 3 20:29:14 2006
@@ -17,23 +17,33 @@
package org.apache.axis2.util;
import java.util.Iterator;
+import java.util.List;
import javax.xml.namespace.QName;
+import org.apache.axis2.description.AxisDescWSDLComponentFactory;
import org.apache.axis2.description.AxisMessage;
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.PolicyInclude;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.wsdl.builder.WSDLComponentFactory;
import org.apache.ws.policy.Policy;
+import org.apache.ws.policy.PolicyConstants;
+import org.apache.ws.policy.PolicyReference;
import org.apache.wsdl.Component;
import org.apache.wsdl.WSDLBinding;
-import org.apache.wsdl.WSDLBindingMessageReference;
import org.apache.wsdl.WSDLBindingOperation;
import org.apache.wsdl.WSDLConstants;
import org.apache.wsdl.WSDLDescription;
import org.apache.wsdl.WSDLEndpoint;
-import org.apache.wsdl.WSDLExtensibilityElement;
+import org.apache.wsdl.WSDLExtensibilityAttribute;
+import org.apache.wsdl.WSDLInterface;
+import org.apache.wsdl.WSDLOperation;
import org.apache.wsdl.WSDLService;
import org.apache.wsdl.extensions.ExtensionConstants;
+import org.apache.wsdl.extensions.PolicyExtensibilityElement;
import org.apache.wsdl.extensions.impl.ExtensionFactoryImpl;
import org.apache.wsdl.impl.WSDLProcessingException;
@@ -45,18 +55,30 @@
AxisService axisService) {
WSDLService wsdlService = description.getService(new QName(axisService
.getName()));
- populatePolicy(wsdlService, axisService);
+ populatePolicy(description, wsdlService, axisService);
}
- public static void populatePolicy(WSDLService wsdlService,
- AxisService axisService) {
- Policy servicePolicy = axisService.getPolicyInclude().getPolicy();
+ private static void populatePolicy(WSDLDescription description,
+ WSDLService wsdlService, AxisService axisService) {
- if (servicePolicy != null) {
- addPolicyToComponent(servicePolicy, wsdlService);
- }
+ AxisServiceGroup axisServiceGroup = axisService.getParent();
+ AxisConfiguration axisConfiguration = axisServiceGroup.getParent();
+
+ PolicyInclude servicePolicyInclude = axisService.getPolicyInclude();
- // TODO CHECK ME //////////////////////////////////
+ List policyList;
+
+ // Policies defined in Axis2.xml
+ policyList = axisConfiguration.getPolicyInclude().getPolicyElements(
+ PolicyInclude.AXIS_POLICY);
+ addPolicyAsExtElements(description, policyList, wsdlService,
+ servicePolicyInclude);
+
+ // Policies defined in wsdl:Service
+ policyList = servicePolicyInclude
+ .getPolicyElements(PolicyInclude.SERVICE_POLICY);
+ addPolicyAsExtElements(description, policyList, wsdlService,
+ servicePolicyInclude);
Iterator wsdlEndpoints = wsdlService.getEndpoints().values().iterator();
if (!wsdlEndpoints.hasNext()) {
@@ -64,9 +86,107 @@
}
WSDLEndpoint wsdlEndpoint = (WSDLEndpoint) wsdlEndpoints.next();
+ populatePolicy(description, wsdlEndpoint, axisService);
+ }
+
+ private static void populatePolicy(WSDLDescription description,
+ WSDLEndpoint wsdlEndpoint, AxisService axisService) {
+ PolicyInclude policyInclude = axisService.getPolicyInclude();
+ List policyList = policyInclude
+ .getPolicyElements(PolicyInclude.PORT_POLICY);
+ addPolicyAsExtElements(description, policyList, wsdlEndpoint,
+ policyInclude);
+
WSDLBinding wsdlBinding = wsdlEndpoint.getBinding();
+ populatePolicy(description, wsdlBinding, axisService);
+ WSDLInterface wsdlInterface = wsdlBinding.getBoundInterface();
+ populatePolicy(description, wsdlInterface, axisService);
+
+ }
+
+ private static void populatePolicy(WSDLDescription description,
+ WSDLInterface wsdlInterface, AxisService axisService) {
+ PolicyInclude policyInclude = axisService.getPolicyInclude();
+ List policyList = policyInclude
+ .getPolicyElements(PolicyInclude.PORT_TYPE_POLICY);
+ addPolicyAsExtAttributes(description, policyList, wsdlInterface,
+ policyInclude);
+
+ Iterator wsdlOperations = wsdlInterface.getOperations().values()
+ .iterator();
+ WSDLOperation wsdlOperation;
+
+ while (wsdlOperations.hasNext()) {
+ wsdlOperation = (WSDLOperation) wsdlOperations.next();
+ populatePolicy(description, wsdlOperation, axisService
+ .getOperation(wsdlOperation.getName()));
+
+ }
+ }
+
+ private static void populatePolicy(WSDLDescription description,
+ WSDLOperation wsdlOperation, AxisOperation axisOperation) {
+
+ PolicyInclude policyInclude = axisOperation.getPolicyInclude();
+
+ // wsdl:PortType -> wsdl:Operation
+ List policyList = policyInclude
+ .getPolicyElements(PolicyInclude.OPERATION_POLICY);
+ addPolicyAsExtElements(description, policyList, wsdlOperation,
+ policyInclude);
+
+ if (WSDLConstants.MEP_URI_IN_ONLY.equals(axisOperation
+ .getMessageExchangePattern())) {
+ AxisMessage input = axisOperation
+ .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ PolicyInclude policyInclude2 = input.getPolicyInclude();
+
+ // wsdl:PortType -> wsdl:Operation -> wsdl:Input
+ List policyList2 = policyInclude2
+ .getPolicyElements(PolicyInclude.INPUT_POLICY);
+ addPolicyAsExtAttributes(description, policyList2, wsdlOperation
+ .getInputMessage(), policyInclude2);
+
+ } else if (WSDLConstants.MEP_URI_IN_OUT.equals(axisOperation
+ .getMessageExchangePattern())) {
+ PolicyInclude policyInclude2;
+ List policyList2;
- ////////////////////////////////////////////////////
+ AxisMessage input = axisOperation
+ .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ policyInclude2 = input.getPolicyInclude();
+
+ // wsdl:PortType -> wsdl:Operation -> wsdl:Input
+ policyList2 = policyInclude2
+ .getPolicyElements(PolicyInclude.INPUT_POLICY);
+ addPolicyAsExtAttributes(description, policyList2, wsdlOperation
+ .getInputMessage(), policyInclude2);
+
+ AxisMessage output = axisOperation
+ .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ policyInclude2 = output.getPolicyInclude();
+
+ // wsdl:PortType -> wsdl:Operation -> wsdl:Output
+ policyList2 = policyInclude2
+ .getPolicyElements(PolicyInclude.OUTPUT_POLICY);
+ addPolicyAsExtAttributes(description, policyList2, wsdlOperation
+ .getOutputMessage(), policyInclude2);
+ }
+ }
+
+ private static void populatePolicy(WSDLDescription description,
+ WSDLBinding wsdlBinding, AxisService axisService) {
+ PolicyInclude policyInclude = axisService.getPolicyInclude();
+
+ List policyList = policyInclude
+ .getPolicyElements(PolicyInclude.AXIS_SERVICE_POLICY);
+ addPolicyAsExtElements(description, policyList, wsdlBinding,
+ policyInclude);
+
+ policyList = policyInclude
+ .getPolicyElements(PolicyInclude.BINDING_POLICY);
+ addPolicyAsExtElements(description, policyList, wsdlBinding,
+ policyInclude);
Iterator wsdlOperations = wsdlBinding.getBindingOperations().values()
.iterator();
@@ -74,56 +194,145 @@
while (wsdlOperations.hasNext()) {
wsdlBindingOperation = (WSDLBindingOperation) wsdlOperations.next();
- populatePolicy(wsdlBindingOperation, axisService
+ populatePolicy(description, wsdlBindingOperation, axisService
.getOperation(wsdlBindingOperation.getName()));
}
-
}
- private static void populatePolicy(
+ private static void populatePolicy(WSDLDescription description,
WSDLBindingOperation wsdlBindingOperation,
AxisOperation axisOperation) {
- Policy operationPolicy = axisOperation.getPolicyInclude().getPolicy();
- if (operationPolicy != null) {
- addPolicyToComponent(operationPolicy, wsdlBindingOperation);
- }
+ PolicyInclude policyInclude = axisOperation.getPolicyInclude();
+ List policyList = policyInclude
+ .getPolicyElements(PolicyInclude.BINDING_OPERATOIN_POLICY);
+ addPolicyAsExtElements(description, policyList, wsdlBindingOperation,
+ policyInclude);
+
+ //
+ policyList = policyInclude
+ .getPolicyElements(PolicyInclude.AXIS_OPERATION_POLICY);
+ addPolicyAsExtElements(description, policyList, wsdlBindingOperation,
+ policyInclude);
if (WSDLConstants.MEP_URI_IN_ONLY.equals(axisOperation
.getMessageExchangePattern())) {
- populatePolicy(wsdlBindingOperation.getInput(), axisOperation
- .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
+ AxisMessage input = axisOperation
+ .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ PolicyInclude policyInclude2 = input.getPolicyInclude();
+
+ // wsdl:Binding -> wsdl:Operation -> wsdl:Input
+ List policyList2 = policyInclude2
+ .getPolicyElements(PolicyInclude.INPUT_POLICY);
+ addPolicyAsExtElements(description, policyList2,
+ wsdlBindingOperation.getInput(), policyInclude2);
+
+ //
+ policyList2 = policyInclude2
+ .getPolicyElements(PolicyInclude.AXIS_MESSAGE_POLICY);
+ addPolicyAsExtElements(description, policyList2,
+ wsdlBindingOperation.getInput(), policyInclude2);
} else if (WSDLConstants.MEP_URI_IN_OUT.equals(axisOperation
.getMessageExchangePattern())) {
- populatePolicy(wsdlBindingOperation.getInput(), axisOperation
- .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
- populatePolicy(wsdlBindingOperation.getOutput(), axisOperation
- .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));
+ PolicyInclude policyInclude2;
+ List policyList2;
+
+ AxisMessage input = axisOperation
+ .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ policyInclude2 = input.getPolicyInclude();
+
+ // wsdl:Binding -> wsdl:Operation -> wsdl:Input
+ policyList2 = policyInclude2
+ .getPolicyElements(PolicyInclude.INPUT_POLICY);
+ addPolicyAsExtElements(description, policyList2,
+ wsdlBindingOperation.getInput(), policyInclude2);
+ //
+ policyList2 = policyInclude2
+ .getPolicyElements(PolicyInclude.AXIS_MESSAGE_POLICY);
+ addPolicyAsExtElements(description, policyList2,
+ wsdlBindingOperation.getInput(), policyInclude2);
+
+ AxisMessage output = axisOperation
+ .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ policyInclude2 = output.getPolicyInclude();
+
+ // wsdl:Binding -> wsdl:Operation -> wsdl:Output
+ policyList2 = policyInclude2
+ .getPolicyElements(PolicyInclude.OUTPUT_POLICY);
+ addPolicyAsExtElements(description, policyList2,
+ wsdlBindingOperation.getOutput(), policyInclude2);
+ //
+ policyList2 = policyInclude2
+ .getPolicyElements(PolicyInclude.AXIS_MESSAGE_POLICY);
+ addPolicyAsExtElements(description, policyList2,
+ wsdlBindingOperation.getInput(), policyInclude2);
}
}
- private static void populatePolicy(
- WSDLBindingMessageReference wsdlBindingMsgReference,
- AxisMessage axisMessage) {
- if(axisMessage == null || axisMessage.getPolicyInclude() == null) {
- return;
- }
- Policy messagePolicy = axisMessage.getPolicyInclude().getPolicy();
+ // private static void addPolicyToComponent(Policy policy, Component
+ // component) {
+ // component.addExtensibilityElement(getExtensibilityElement(policy));
+ // }
+
+ private static PolicyExtensibilityElement getExtensibilityElement(
+ Object policyElement) {
+ PolicyExtensibilityElement element = (PolicyExtensibilityElement) (new ExtensionFactoryImpl())
+ .getExtensionElement(ExtensionConstants.POLICY);
+ element.setPolicyElement(policyElement);
+ return element;
+ }
- if (messagePolicy != null) {
- addPolicyToComponent(messagePolicy, wsdlBindingMsgReference);
- }
+ private static WSDLExtensibilityAttribute getExtensibilitiyAttribute(
+ PolicyReference policyReference) {
+ WSDLExtensibilityAttribute extensibilityAttribute = new AxisDescWSDLComponentFactory()
+ .createWSDLExtensibilityAttribute();
+ extensibilityAttribute.setKey(new QName(
+ PolicyConstants.WSU_NAMESPACE_URI, "PolicyURIs"));
+ extensibilityAttribute.setValue(new QName(policyReference
+ .getPolicyURIString()));
+ return extensibilityAttribute;
}
- private static void addPolicyToComponent(Policy policy, Component component) {
- component.addExtensibilityElement(getExtensibilityElement(policy));
+ private static void addPolicyAsExtElements(WSDLDescription description,
+ List policyList, Component component, PolicyInclude policyInclude) {
+ Iterator policyElementIterator = policyList.iterator();
+ Object policyElement;
+
+ while (policyElementIterator.hasNext()) {
+ policyElement = policyElementIterator.next();
+
+ if (policyElement instanceof PolicyReference) {
+ String policyURIString = ((PolicyReference) policyElement)
+ .getPolicyURIString();
+ description
+ .addExtensibilityElement(getExtensibilityElement(policyInclude
+ .getPolicy(policyURIString)));
+ }
+
+ component
+ .addExtensibilityElement(getExtensibilityElement(policyElement));
+ }
}
- private static WSDLExtensibilityElement getExtensibilityElement(
- Policy policy) {
- WSDLExtensibilityElement element = (new ExtensionFactoryImpl())
- .getExtensionElement(ExtensionConstants.POLICY);
- return element;
+ private static void addPolicyAsExtAttributes(WSDLDescription description,
+ List policyList, Component component, PolicyInclude policyInclude) {
+ Iterator policyElementIterator = policyList.iterator();
+ Object policyElement;
+
+ while (policyElementIterator.hasNext()) {
+ policyElement = policyElementIterator.next();
+
+ if (policyElement instanceof PolicyReference) {
+ String policyURIString = ((PolicyReference) policyElement)
+ .getPolicyURIString();
+ component
+ .addExtensibleAttributes(getExtensibilitiyAttribute((PolicyReference) policyElement));
+ description
+ .addExtensibilityElement(getExtensibilityElement(policyInclude
+ .getPolicy(policyURIString)));
+
+ }
+ }
}
}