axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r643008 [4/4] - in /webservices/axis2/trunk/java/modules: integration/test-resources/ integration/test-resources/ComplexDataTypes/ integration/test/org/apache/axis2/deployment/ kernel/src/org/apache/axis2/ kernel/src/org/apache/axis2/contex...
Date Mon, 31 Mar 2008 14:51:42 GMT
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java Mon Mar 31 07:51:35 2008
@@ -45,6 +45,7 @@
 import org.apache.neethi.PolicyComponent;
 import org.apache.neethi.PolicyReference;
 import org.apache.neethi.PolicyRegistry;
+import org.apache.woden.wsdl20.Endpoint;
 import org.apache.ws.commons.schema.XmlSchema;
 
 import javax.xml.namespace.QName;
@@ -52,11 +53,13 @@
 import java.io.StringWriter;
 import java.net.URI;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.Map.Entry;
 
 public class AxisService2WSDL11 implements Java2WSDLConstants {
 
@@ -388,10 +391,7 @@
 					operation, fac, wsdl);
 			portType.addChild(operation);
 			operation.addAttribute(ATTRIBUTE_NAME, operationName, null);
-			addPolicyAsExtElement(PolicyInclude.OPERATION_POLICY, axisOperation
-					.getPolicyInclude(), operation);
-			addPolicyAsExtElement(PolicyInclude.AXIS_OPERATION_POLICY,
-					axisOperation.getPolicyInclude(), operation);
+			addPolicyAsExtElement(axisOperation, operation);
 
 			String MEP = axisOperation.getMessageExchangePattern();
 			if (WSDL2Constants.MEP_URI_IN_ONLY.equals(MEP)
@@ -409,10 +409,7 @@
 							inaxisMessage, input, fac, wsdl);
 					input.addAttribute(MESSAGE_LOCAL_NAME, tns.getPrefix()
 							+ ":" + inaxisMessage.getName(), null);
-					addPolicyAsExtElement(PolicyInclude.INPUT_POLICY,
-							inaxisMessage.getPolicyInclude(), input);
-					addPolicyAsExtElement(PolicyInclude.AXIS_MESSAGE_POLICY,
-							inaxisMessage.getPolicyInclude(), input);
+					addPolicyAsExtElement(inaxisMessage, input);
 
 					WSDLSerializationUtil.addWSAWActionAttribute(input,
 							axisOperation.getInputAction(), wsaw);
@@ -435,10 +432,7 @@
 							outAxisMessage, output, fac, wsdl);
 					output.addAttribute(MESSAGE_LOCAL_NAME, tns.getPrefix()
 							+ ":" + outAxisMessage.getName(), null);
-					addPolicyAsExtElement(PolicyInclude.OUTPUT_POLICY,
-							outAxisMessage.getPolicyInclude(), output);
-					addPolicyAsExtElement(PolicyInclude.AXIS_MESSAGE_POLICY,
-							outAxisMessage.getPolicyInclude(), output);
+					addPolicyAsExtElement(outAxisMessage, output);
 					WSDLSerializationUtil.addWSAWActionAttribute(output,
 							axisOperation.getOutputAction(), wsaw);
 					operation.addChild(output);
@@ -1091,9 +1085,7 @@
 			policy = (Policy) iterator.next();
 			policyElement = PolicyUtil.getPolicyComponentAsOMElement(policy,
 					serializer);
-
 			firstChild = definition.getFirstOMChild();
-
 			if (firstChild != null) {
 				firstChild.insertSiblingBefore(policyElement);
 			} else {
@@ -1124,46 +1116,41 @@
 
 	private void generateSoap11Port(OMFactory fac, OMElement definition,
 			OMElement service) throws Exception {
-
-		// /////////////////// FIXME //////////////////////////////////////////
 		Iterator iterator = axisService.getEndpoints().values().iterator();
 		AxisEndpoint axisEndpoint = null;
 		AxisBinding axisBinding = null;
-		boolean found = false;
 		for (; iterator.hasNext();) {
 			axisEndpoint = (AxisEndpoint) iterator.next();
 			/*
 			 * Some transports might not be active at runtime.
 			 */
-			if (axisEndpoint.getEndpointURL() == null) {
+			if (!axisEndpoint.isActive()) {
 				continue;
 			}
 			axisBinding = axisEndpoint.getBinding();
 			String type = axisBinding.getType();
-			if (Java2WSDLConstants.TRANSPORT_URI.equals(type)) {
+			if (Java2WSDLConstants.TRANSPORT_URI.equals(type)
+					|| WSDL2Constants.URI_WSDL2_SOAP.equals(type)) {
 				String version = (String) axisBinding
 						.getProperty(WSDL2Constants.ATTR_WSOAP_VERSION);
 				if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(version)) {
-					found = true;
-					break;
+					OMElement port = fac.createOMElement(PORT, wsdl);
+					service.addChild(port);
+					port.addAttribute(ATTRIBUTE_NAME, axisEndpoint.getName(),
+							null);
+					QName qname = axisBinding.getName();
+					port.addAttribute(BINDING_LOCAL_NAME, tns.getPrefix() + ":"
+							+ qname.getLocalPart(), null);
+					String endpointURL = axisEndpoint.getEndpointURL();
+					WSDLSerializationUtil.addExtensionElement(fac, port,
+							SOAP_ADDRESS, LOCATION, (endpointURL == null) ? ""
+									: endpointURL, soap);
+					addPolicyAsExtElement(axisEndpoint, port);
+					generateSoap11Binding(fac, definition, axisEndpoint
+							.getBinding());
 				}
 			}
 		}
-		if (!found) {
-			return;
-		}
-		// /////////////////////////////////////////////////////////////////////
-
-		OMElement port = fac.createOMElement(PORT, wsdl);
-		service.addChild(port);
-		port.addAttribute(ATTRIBUTE_NAME, axisEndpoint.getName(), null);
-		QName qname = axisBinding.getName();
-		port.addAttribute(BINDING_LOCAL_NAME, tns.getPrefix() + ":"
-				+ qname.getLocalPart(), null);
-		WSDLSerializationUtil.addExtensionElement(fac, port, SOAP_ADDRESS,
-				LOCATION, axisEndpoint.getEndpointURL(), soap);
-		addPolicyAsExtElement(axisEndpoint, port);
-		generateSoap11Binding(fac, definition, axisEndpoint.getBinding());
 	}
 
 	private void generateSoap12Port(OMFactory fac, OMElement definition,
@@ -1173,41 +1160,39 @@
 		Iterator iterator = axisService.getEndpoints().values().iterator();
 		AxisEndpoint axisEndpoint = null;
 		AxisBinding axisBinding = null;
-		boolean found = false;
 		for (; iterator.hasNext();) {
 			axisEndpoint = (AxisEndpoint) iterator.next();
 			/*
 			 * 
 			 */
-			if (axisEndpoint.getEndpointURL() == null) {
+			if (!axisEndpoint.isActive()) {
 				continue;
 			}
 			axisBinding = axisEndpoint.getBinding();
 			String type = axisBinding.getType();
-			if (Java2WSDLConstants.TRANSPORT_URI.equals(type)) {
+			if (Java2WSDLConstants.TRANSPORT_URI.equals(type)
+					|| WSDL2Constants.URI_WSDL2_SOAP.equals(type)) {
 				String version = (String) axisBinding
 						.getProperty(WSDL2Constants.ATTR_WSOAP_VERSION);
 				if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(version)) {
-					found = true;
-					break;
+
+					OMElement port = fac.createOMElement(PORT, wsdl);
+					service.addChild(port);
+					port.addAttribute(ATTRIBUTE_NAME, axisEndpoint.getName(),
+							null);
+					QName qname = axisBinding.getName();
+					port.addAttribute(BINDING_LOCAL_NAME, tns.getPrefix() + ":"
+							+ qname.getLocalPart(), null);
+					String endpointURL = axisEndpoint.getEndpointURL();
+					WSDLSerializationUtil.addExtensionElement(fac, port,
+							SOAP_ADDRESS, LOCATION, (endpointURL == null) ? ""
+									: endpointURL, soap12);
+					addPolicyAsExtElement(axisEndpoint, port);
+					generateSoap12Binding(fac, definition, axisEndpoint
+							.getBinding());
 				}
 			}
 		}
-		if (!found) {
-			return;
-		}
-		// /////////////////////////////////////////////////////////////////////
-
-		OMElement port = fac.createOMElement(PORT, wsdl);
-		service.addChild(port);
-		port.addAttribute(ATTRIBUTE_NAME, axisEndpoint.getName(), null);
-		QName qname = axisBinding.getName();
-		port.addAttribute(BINDING_LOCAL_NAME, tns.getPrefix() + ":"
-				+ qname.getLocalPart(), null);
-		WSDLSerializationUtil.addExtensionElement(fac, port, SOAP_ADDRESS,
-				LOCATION, axisEndpoint.getEndpointURL(), soap12);
-		addPolicyAsExtElement(axisEndpoint, port);
-		generateSoap12Binding(fac, definition, axisEndpoint.getBinding());
 	}
 
 	private void generateHttpPort(OMFactory fac, OMElement definition,
@@ -1217,44 +1202,40 @@
 		Iterator iterator = axisService.getEndpoints().values().iterator();
 		AxisEndpoint axisEndpoint = null;
 		AxisBinding axisBinding = null;
-		boolean found = false;
 		for (; iterator.hasNext();) {
 			axisEndpoint = (AxisEndpoint) iterator.next();
 			/*
 			 * 
 			 */
-			if (axisEndpoint.getEndpointURL() == null) {
+			if (!axisEndpoint.isActive()) {
 				continue;
 			}
 			axisBinding = axisEndpoint.getBinding();
 			String type = axisBinding.getType();
 			if (WSDL2Constants.URI_WSDL2_HTTP.equals(type)) {
-				found = true;
-				break;
+				OMElement port = fac.createOMElement(PORT, wsdl);
+				service.addChild(port);
+				port.addAttribute(ATTRIBUTE_NAME, axisEndpoint.getName(), null);
+				QName qname = axisBinding.getName();
+				port.addAttribute(BINDING_LOCAL_NAME, tns.getPrefix() + ":"
+						+ qname.getLocalPart(), null);
+				OMElement extElement = fac.createOMElement("address", http);
+				String endpointURL = axisEndpoint.getEndpointURL();
+				extElement.addAttribute("location", (endpointURL == null) ? ""
+						: endpointURL, null);
+				port.addChild(extElement);
+
+				addPolicyAsExtElement(axisEndpoint, port);
+				generateHttpBinding(fac, definition, axisEndpoint.getBinding());
 			}
 		}
-		if (!found) {
-			return;
-		}
-		// /////////////////////////////////////////////////////////////////////
-
-		OMElement port = fac.createOMElement(PORT, wsdl);
-		service.addChild(port);
-		port.addAttribute(ATTRIBUTE_NAME, axisEndpoint.getName(), null);
-		QName qname = axisBinding.getName();
-		port.addAttribute(BINDING_LOCAL_NAME, tns.getPrefix() + ":"
-				+ qname.getLocalPart(), null);
-		OMElement extElement = fac.createOMElement("address", http);
-		extElement
-				.addAttribute("location", axisEndpoint.getEndpointURL(), null);
-		port.addChild(extElement);
-
-		addPolicyAsExtElement(axisEndpoint, port);
-		generateHttpBinding(fac, definition, axisEndpoint.getBinding());
 	}
 
 	private void generateSoap11Binding(OMFactory fac, OMElement defintions,
 			AxisBinding axisBinding) throws Exception {
+		if (isAlreadyAdded(axisBinding, defintions)) {
+			return;
+		}
 		OMElement binding = fac.createOMElement(BINDING_LOCAL_NAME, wsdl);
 		OMElement serviceElement = defintions.getFirstChildWithName(new QName(
 				wsdl.getNamespaceURI(), SERVICE_LOCAL_NAME));
@@ -1320,84 +1301,89 @@
 					|| WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_IN_OUT.equals(MEP)) {
-                AxisBindingMessage axisBindingInMessage = (AxisBindingMessage) axisBindingOperation
-                        .getChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-                if (axisBindingInMessage != null) {
-                    AxisMessage inaxisMessage = axisBindingInMessage
-                            .getAxisMessage();
-
-                    if (inaxisMessage != null) {
-                        operation.addAttribute(ATTRIBUTE_NAME, opeartionName, null);
-                        OMElement input = fac.createOMElement(IN_PUT_LOCAL_NAME,
-                                wsdl);
-                        addPolicyAsExtElement(axisBindingInMessage, input);
-                        addExtensionElement(fac, input, SOAP_BODY, SOAP_USE, use,
-                                null, targetNamespace, soap);
-                        // addPolicyAsExtElement(PolicyInclude.BINDING_INPUT_POLICY,
-                        // inaxisMessage.getPolicyInclude(), input);
-                        operation.addChild(input);
-                        writeSoapHeaders(inaxisMessage, fac, input, soap12);
-                    }
-                }
-            }
+				AxisBindingMessage axisBindingInMessage = (AxisBindingMessage) axisBindingOperation
+						.getChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+				if (axisBindingInMessage != null) {
+					AxisMessage inaxisMessage = axisBindingInMessage
+							.getAxisMessage();
+
+					if (inaxisMessage != null) {
+						operation.addAttribute(ATTRIBUTE_NAME, opeartionName,
+								null);
+						OMElement input = fac.createOMElement(
+								IN_PUT_LOCAL_NAME, wsdl);
+						addPolicyAsExtElement(axisBindingInMessage, input);
+						addExtensionElement(fac, input, SOAP_BODY, SOAP_USE,
+								use, null, targetNamespace, soap);
+						// addPolicyAsExtElement(PolicyInclude.BINDING_INPUT_POLICY,
+						// inaxisMessage.getPolicyInclude(), input);
+						operation.addChild(input);
+						writeSoapHeaders(inaxisMessage, fac, input, soap12);
+					}
+				}
+			}
 
-            if (WSDL2Constants.MEP_URI_OUT_ONLY.equals(MEP)
+			if (WSDL2Constants.MEP_URI_OUT_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN.equals(MEP)
 					|| WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT.equals(MEP)
 					|| WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_IN_OUT.equals(MEP)) {
 
-                AxisBindingMessage axisBindingOutMessage = (AxisBindingMessage) axisBindingOperation
-                        .getChild(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
-                if (axisBindingOutMessage != null) {
-                    AxisMessage outAxisMessage = axisBindingOutMessage
-                            .getAxisMessage();
-                    if (outAxisMessage != null) {
-                        OMElement output = fac.createOMElement(OUT_PUT_LOCAL_NAME,
-                                wsdl);
-                        addPolicyAsExtElement(axisBindingOutMessage, output);
-                        addExtensionElement(fac, output, SOAP_BODY, SOAP_USE, use,
-                                null, targetNamespace, soap);
-                        // addPolicyAsExtElement(PolicyInclude.BINDING_OUTPUT_POLICY,
-                        // outAxisMessage.getPolicyInclude(), output);
-                        operation.addChild(output);
-                        writeSoapHeaders(outAxisMessage, fac, output, soap12);
-                    }
-                }
-            }
-
-            // generate fault Messages
-            ArrayList faultyMessages = axisBindingOperation.getFaults();
-            if (faultyMessages != null) {
-                for (int i = 0; i < faultyMessages.size(); i++) {
-                    AxisBindingMessage bindingFaultyMessage = (AxisBindingMessage) faultyMessages
-                            .get(i);
-                    if (bindingFaultyMessage != null) {
-                        AxisMessage faultyMessage = bindingFaultyMessage
-                                .getAxisMessage();
-
-                        OMElement fault = fac.createOMElement(FAULT_LOCAL_NAME,
-                                wsdl);
-
-                        addPolicyAsExtElement(bindingFaultyMessage, fault);
-                        addExtensionElement(fac, fault, FAULT_LOCAL_NAME, SOAP_USE,
-                                use, ATTRIBUTE_NAME, faultyMessage.getName(), soap);
-                        fault.addAttribute(ATTRIBUTE_NAME, faultyMessage.getName(),
-                                null);
-                        // add policies for fault messages
-                        operation.addChild(fault);
-                        writeSoapHeaders(faultyMessage, fac, fault, soap);
-                    }
-                }
-            }
-        }
-    }
+				AxisBindingMessage axisBindingOutMessage = (AxisBindingMessage) axisBindingOperation
+						.getChild(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+				if (axisBindingOutMessage != null) {
+					AxisMessage outAxisMessage = axisBindingOutMessage
+							.getAxisMessage();
+					if (outAxisMessage != null) {
+						OMElement output = fac.createOMElement(
+								OUT_PUT_LOCAL_NAME, wsdl);
+						addPolicyAsExtElement(axisBindingOutMessage, output);
+						addExtensionElement(fac, output, SOAP_BODY, SOAP_USE,
+								use, null, targetNamespace, soap);
+						// addPolicyAsExtElement(PolicyInclude.BINDING_OUTPUT_POLICY,
+						// outAxisMessage.getPolicyInclude(), output);
+						operation.addChild(output);
+						writeSoapHeaders(outAxisMessage, fac, output, soap12);
+					}
+				}
+			}
+
+			// generate fault Messages
+			ArrayList faultyMessages = axisBindingOperation.getFaults();
+			if (faultyMessages != null) {
+				for (int i = 0; i < faultyMessages.size(); i++) {
+					AxisBindingMessage bindingFaultyMessage = (AxisBindingMessage) faultyMessages
+							.get(i);
+					if (bindingFaultyMessage != null) {
+						AxisMessage faultyMessage = bindingFaultyMessage
+								.getAxisMessage();
+
+						OMElement fault = fac.createOMElement(FAULT_LOCAL_NAME,
+								wsdl);
+
+						addPolicyAsExtElement(bindingFaultyMessage, fault);
+						addExtensionElement(fac, fault, FAULT_LOCAL_NAME,
+								SOAP_USE, use, ATTRIBUTE_NAME, faultyMessage
+										.getName(), soap);
+						fault.addAttribute(ATTRIBUTE_NAME, faultyMessage
+								.getName(), null);
+						// add policies for fault messages
+						operation.addChild(fault);
+						writeSoapHeaders(faultyMessage, fac, fault, soap);
+					}
+				}
+			}
+		}
+	}
 
-	private void generateSoap12Binding(OMFactory fac, OMElement defintions,
+	private void generateSoap12Binding(OMFactory fac, OMElement definitions,
 			AxisBinding axisBinding) throws Exception {
+		if (isAlreadyAdded(axisBinding, definitions)) {
+			return;
+		}
 		OMElement binding = fac.createOMElement(BINDING_LOCAL_NAME, wsdl);
-		OMElement serviceElement = defintions.getFirstChildWithName(new QName(
+		OMElement serviceElement = definitions.getFirstChildWithName(new QName(
 				wsdl.getNamespaceURI(), SERVICE_LOCAL_NAME));
 		serviceElement.insertSiblingBefore(binding);
 
@@ -1461,81 +1447,85 @@
 					|| WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_IN_OUT.equals(MEP)) {
-                AxisBindingMessage axisBindingInMessage = (AxisBindingMessage) axisBindingOperation
-                        .getChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-                if (axisBindingInMessage != null) {
-                    AxisMessage inaxisMessage = axisBindingInMessage
-                            .getAxisMessage();
-
-                    if (inaxisMessage != null) {
-                        operation.addAttribute(ATTRIBUTE_NAME, opeartionName, null);
-                        OMElement input = fac.createOMElement(IN_PUT_LOCAL_NAME,
-                                wsdl);
-                        addPolicyAsExtElement(axisBindingInMessage, input);
-                        addExtensionElement(fac, input, SOAP_BODY, SOAP_USE, use,
-                                null, targetNamespace, soap12);
-                        operation.addChild(input);
-                        writeSoapHeaders(inaxisMessage, fac, input, soap12);
-                    }
-                }
-            }
+				AxisBindingMessage axisBindingInMessage = (AxisBindingMessage) axisBindingOperation
+						.getChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+				if (axisBindingInMessage != null) {
+					AxisMessage inaxisMessage = axisBindingInMessage
+							.getAxisMessage();
+
+					if (inaxisMessage != null) {
+						operation.addAttribute(ATTRIBUTE_NAME, opeartionName,
+								null);
+						OMElement input = fac.createOMElement(
+								IN_PUT_LOCAL_NAME, wsdl);
+						addPolicyAsExtElement(axisBindingInMessage, input);
+						addExtensionElement(fac, input, SOAP_BODY, SOAP_USE,
+								use, null, targetNamespace, soap12);
+						operation.addChild(input);
+						writeSoapHeaders(inaxisMessage, fac, input, soap12);
+					}
+				}
+			}
 
-            if (WSDL2Constants.MEP_URI_OUT_ONLY.equals(MEP)
+			if (WSDL2Constants.MEP_URI_OUT_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN.equals(MEP)
 					|| WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT.equals(MEP)
 					|| WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_IN_OUT.equals(MEP)) {
 
-                AxisBindingMessage axisBindingOutMessage = (AxisBindingMessage) axisBindingOperation
-                        .getChild(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
-                if (axisBindingOutMessage != null) {
-                    AxisMessage outAxisMessage = axisBindingOutMessage
-                            .getAxisMessage();
-                    if (outAxisMessage != null) {
-                        OMElement output = fac.createOMElement(OUT_PUT_LOCAL_NAME,
-                                wsdl);
-                        addPolicyAsExtElement(axisBindingOutMessage, output);
-                        addExtensionElement(fac, output, SOAP_BODY, SOAP_USE, use,
-                                null, targetNamespace, soap12);
-                        // addPolicyAsExtElement(PolicyInclude.BINDING_OUTPUT_POLICY,
-                        // outAxisMessage.getPolicyInclude(), output);
-                        operation.addChild(output);
-                        writeSoapHeaders(outAxisMessage, fac, output, soap12);
-                    }
-                }
-            }
-
-            // generate fault Messages
-            ArrayList faultyMessages = axisBindingOperation.getFaults();
-            if (faultyMessages != null) {
-                for (int i = 0; i < faultyMessages.size(); i++) {
-                    AxisBindingMessage bindingFaultyMessage = (AxisBindingMessage) faultyMessages
-                            .get(i);
-                    if (bindingFaultyMessage != null) {
-                        AxisMessage faultyMessage = bindingFaultyMessage
-                                .getAxisMessage();
-                        OMElement fault = fac.createOMElement(FAULT_LOCAL_NAME,
-                                wsdl);
-                        addPolicyAsExtElement(bindingFaultyMessage, fault);
-                        addExtensionElement(fac, fault, FAULT_LOCAL_NAME, SOAP_USE,
-                                use, ATTRIBUTE_NAME, faultyMessage.getName(),
-                                soap12);
-                        fault.addAttribute(ATTRIBUTE_NAME, faultyMessage.getName(),
-                                null);
-                        // add policies for fault messages
-                        operation.addChild(fault);
-                        writeSoapHeaders(faultyMessage, fac, fault, soap12);
-                    }
-                }
-            }
-        }
-    }
+				AxisBindingMessage axisBindingOutMessage = (AxisBindingMessage) axisBindingOperation
+						.getChild(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+				if (axisBindingOutMessage != null) {
+					AxisMessage outAxisMessage = axisBindingOutMessage
+							.getAxisMessage();
+					if (outAxisMessage != null) {
+						OMElement output = fac.createOMElement(
+								OUT_PUT_LOCAL_NAME, wsdl);
+						addPolicyAsExtElement(axisBindingOutMessage, output);
+						addExtensionElement(fac, output, SOAP_BODY, SOAP_USE,
+								use, null, targetNamespace, soap12);
+						// addPolicyAsExtElement(PolicyInclude.BINDING_OUTPUT_POLICY,
+						// outAxisMessage.getPolicyInclude(), output);
+						operation.addChild(output);
+						writeSoapHeaders(outAxisMessage, fac, output, soap12);
+					}
+				}
+			}
+
+			// generate fault Messages
+			ArrayList faultyMessages = axisBindingOperation.getFaults();
+			if (faultyMessages != null) {
+				for (int i = 0; i < faultyMessages.size(); i++) {
+					AxisBindingMessage bindingFaultyMessage = (AxisBindingMessage) faultyMessages
+							.get(i);
+					if (bindingFaultyMessage != null) {
+						AxisMessage faultyMessage = bindingFaultyMessage
+								.getAxisMessage();
+						OMElement fault = fac.createOMElement(FAULT_LOCAL_NAME,
+								wsdl);
+						addPolicyAsExtElement(bindingFaultyMessage, fault);
+						addExtensionElement(fac, fault, FAULT_LOCAL_NAME,
+								SOAP_USE, use, ATTRIBUTE_NAME, faultyMessage
+										.getName(), soap12);
+						fault.addAttribute(ATTRIBUTE_NAME, faultyMessage
+								.getName(), null);
+						// add policies for fault messages
+						operation.addChild(fault);
+						writeSoapHeaders(faultyMessage, fac, fault, soap12);
+					}
+				}
+			}
+		}
+	}
 
-	private void generateHttpBinding(OMFactory fac, OMElement defintions,
+	private void generateHttpBinding(OMFactory fac, OMElement definitions,
 			AxisBinding axisBinding) throws Exception {
+		if (isAlreadyAdded(axisBinding, definitions)) {
+			return;
+		}
 		OMElement binding = fac.createOMElement(BINDING_LOCAL_NAME, wsdl);
-		OMElement serviceElement = defintions.getFirstChildWithName(new QName(
+		OMElement serviceElement = definitions.getFirstChildWithName(new QName(
 				wsdl.getNamespaceURI(), SERVICE_LOCAL_NAME));
 		serviceElement.insertSiblingBefore(binding);
 
@@ -1576,90 +1566,93 @@
 					|| WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_IN_OUT.equals(MEP)) {
-                AxisBindingMessage axisBindingInMessage = (AxisBindingMessage) axisBindingOperation
-                        .getChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-                if (axisBindingInMessage != null) {
-                    AxisMessage inaxisMessage = axisBindingInMessage
-                            .getAxisMessage();
-
-                    if (inaxisMessage != null) {
-                        operation.addAttribute(ATTRIBUTE_NAME, opeartionName, null);
-                        OMElement input = fac.createOMElement(IN_PUT_LOCAL_NAME,
-                                wsdl);
-                        OMElement inputelement = fac.createOMElement("content",
-                                mime);
-                        input.addChild(inputelement);
-                        inputelement.addAttribute("type", "text/xml", null);
-                        inputelement.addAttribute("part", axisOperation.getName()
-                                .getLocalPart(), null);
-                        operation.addChild(input);
-                    }
-                }
-            }
+				AxisBindingMessage axisBindingInMessage = (AxisBindingMessage) axisBindingOperation
+						.getChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+				if (axisBindingInMessage != null) {
+					AxisMessage inaxisMessage = axisBindingInMessage
+							.getAxisMessage();
+
+					if (inaxisMessage != null) {
+						operation.addAttribute(ATTRIBUTE_NAME, opeartionName,
+								null);
+						OMElement input = fac.createOMElement(
+								IN_PUT_LOCAL_NAME, wsdl);
+						OMElement inputelement = fac.createOMElement("content",
+								mime);
+						input.addChild(inputelement);
+						inputelement.addAttribute("type", "text/xml", null);
+						inputelement.addAttribute("part", axisOperation
+								.getName().getLocalPart(), null);
+						operation.addChild(input);
+					}
+				}
+			}
 
-            if (WSDL2Constants.MEP_URI_OUT_ONLY.equals(MEP)
+			if (WSDL2Constants.MEP_URI_OUT_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN.equals(MEP)
 					|| WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT.equals(MEP)
 					|| WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(MEP)
 					|| WSDL2Constants.MEP_URI_IN_OUT.equals(MEP)) {
 
-                AxisBindingMessage axisBindingOutMessage = (AxisBindingMessage) axisBindingOperation
-                        .getChild(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
-                if (axisBindingOutMessage != null) {
-                    AxisMessage outAxisMessage = axisBindingOutMessage
-                            .getAxisMessage();
-                    if (outAxisMessage != null) {
-                        OMElement output = fac.createOMElement(OUT_PUT_LOCAL_NAME,
-                                wsdl);
-                        OMElement outElement = fac.createOMElement("content", mime);
-                        outElement.addChild(outElement);
-                        outElement.addAttribute("type", "text/xml", null);
-                        outElement.addAttribute("part", axisOperation.getName()
-                                .getLocalPart(), null);
-                        output.addChild(outElement);
-                        operation.addChild(output);
-                    }
-                }
-            }
-        }
-    }
+				AxisBindingMessage axisBindingOutMessage = (AxisBindingMessage) axisBindingOperation
+						.getChild(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+				if (axisBindingOutMessage != null) {
+					AxisMessage outAxisMessage = axisBindingOutMessage
+							.getAxisMessage();
+					if (outAxisMessage != null) {
+						OMElement output = fac.createOMElement(
+								OUT_PUT_LOCAL_NAME, wsdl);
+						OMElement outElement = fac.createOMElement("content",
+								mime);
+						outElement.addChild(outElement);
+						outElement.addAttribute("type", "text/xml", null);
+						outElement.addAttribute("part", axisOperation.getName()
+								.getLocalPart(), null);
+						output.addChild(outElement);
+						operation.addChild(output);
+					}
+				}
+			}
+		}
+	}
 
 	private void addPolicyAsExtElement(AxisDescription axisDescription,
-			OMElement element) throws Exception {
+			OMElement wsdlElement) throws Exception {
 		PolicySubject policySubject = axisDescription.getPolicySubject();
-		Set attachPolicyComponents = policySubject.getAttachPolicyComponents();
+		Collection attachPolicyComponents = policySubject
+				.getAttachPolicyComponents();
 
 		for (Iterator iterator = attachPolicyComponents.iterator(); iterator
 				.hasNext();) {
 			Object policyElement = iterator.next();
 
 			if (policyElement instanceof Policy) {
-				OMElement child = PolicyUtil.getPolicyComponentAsOMElement(
-						(PolicyComponent) policyElement, serializer);
+				PolicyReference policyReference = PolicyUtil
+						.createPolicyReference((Policy) policyElement);
+				OMElement policyRefElement = PolicyUtil
+						.getPolicyComponentAsOMElement(
+								(PolicyComponent) policyReference, serializer);
 
-				OMNode firstChildElem = element.getFirstElement();
-				// if (firstChildElem == null) {
-				// parentElement.addChild(child);
-				// } else {
-				// firstChildElem.insertSiblingBefore(child);
-				// }
-				// there is a problem with the OM insertSiblingBefore element
-				// with
-				// drops the already exists elements.
-				// since there is no any techical problem of adding policy
-				// elements after other
-				// children temporaliy fix this as it is.
-				// one OM fix this issue we can revert this change.
-				element.addChild(child);
+				OMNode firstChildElem = wsdlElement.getFirstElement();
+				if (firstChildElem == null) {
+					wsdlElement.addChild(policyRefElement);
+				} else {
+					firstChildElem.insertSiblingBefore(policyRefElement);
+				}
+				String key = ((PolicyReference) policyReference).getURI();
+				if (key.startsWith("#")) {
+					key = key.substring(key.indexOf("#") + 1);
+				}
+				addPolicyToDefinitionElement(key, (Policy) policyElement);
 
 			} else if (policyElement instanceof PolicyReference) {
-				OMElement child = PolicyUtil
-						.getPolicyComponentAsOMElement((PolicyComponent) policyElement);
-				OMElement firstChildElem = element.getFirstElement();
+				OMElement child = PolicyUtil.getPolicyComponentAsOMElement(
+						(PolicyComponent) policyElement, serializer);
+				OMElement firstChildElem = wsdlElement.getFirstElement();
 
 				if (firstChildElem == null) {
-					element.addChild(child);
+					wsdlElement.addChild(child);
 				} else {
 					firstChildElem.insertSiblingBefore(child);
 				}
@@ -1744,5 +1737,21 @@
 					value);
 			element.addAttribute(URIs);
 		}
+	}
+
+	private boolean isAlreadyAdded(AxisBinding axisBinding,
+			OMElement definitionElement) {
+		QName bindingName = axisBinding.getName();
+		QName name = new QName("name");
+		for (Iterator iterator = definitionElement
+				.getChildrenWithName(new QName(wsdl.getNamespaceURI(),
+						BINDING_LOCAL_NAME)); iterator.hasNext();) {
+			OMElement element = (OMElement) iterator.next();
+			String value = element.getAttributeValue(name);
+			if (bindingName.getLocalPart().equals(value)) {
+				return true;
+			}
+		}
+		return false;
 	}
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicySubject.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicySubject.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicySubject.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicySubject.java Mon Mar 31 07:51:35 2008
@@ -1,73 +1,94 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-package org.apache.axis2.description;
-
-import org.apache.axiom.om.util.UUIDGenerator;
-import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyComponent;
-import org.apache.neethi.PolicyReference;
-
-import java.util.HashMap;
-import java.util.Set;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-public class PolicySubject {
-	private HashMap attachedPolicyComponents = new HashMap();
-	
-	public void attachPolicy(Policy policy) {
-		String key = policy.getName();
-		if (key == null) {
-			key = policy.getId();
-			if (key == null) {
-				key = UUIDGenerator.getUUID();
-				policy.setId(key);
-			}
-		}
-		attachPolicyComponent(key, policy);
-	}
-	
-	public void attachPolicyReference(PolicyReference reference) {
-		attachedPolicyComponents.put(reference.getURI(), reference); 
-	}
-	
-	public void attachPolicyComponent(String key, PolicyComponent policyComponent) {
-		attachedPolicyComponents.put(key, policyComponent);
-	}
-	
-	public Set getAttachPolicyComponents() {
-		return attachedPolicyComponents.entrySet();
-	}
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.axis2.description;
+
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyComponent;
+import org.apache.neethi.PolicyReference;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+public class PolicySubject {
+	private HashMap attachedPolicyComponents = new HashMap();
+	
+	public void attachPolicy(Policy policy) {
+		String key = policy.getName();
+		if (key == null) {
+			key = policy.getId();
+			if (key == null) {
+				key = UUIDGenerator.getUUID();
+				policy.setId(key);
+			}
+		}
+		attachPolicyComponent(key, policy);
+	}
+	
+	public void attachPolicyReference(PolicyReference reference) {
+		attachedPolicyComponents.put(reference.getURI(), reference); 
+	}
+	
+	public void attachPolicyComponents(List policyComponents) {
+		for (Iterator iterator = policyComponents.iterator(); iterator.hasNext();) {
+			attachPolicyComponent((PolicyComponent) iterator.next());
+		}
+	}
+	
+	public void attachPolicyComponent(PolicyComponent policyComponent) {
+		if (policyComponent instanceof Policy) {
+			attachPolicy((Policy) policyComponent);
+		} else if (policyComponent instanceof PolicyReference) {
+			attachPolicyReference((PolicyReference) policyComponent);
+		} else {
+			throw new IllegalArgumentException("Invalid top level policy component type");
+		}
+		
+	}
+	public void attachPolicyComponent(String key, PolicyComponent policyComponent) {
+		attachedPolicyComponents.put(key, policyComponent);
+	}
+	
+	
+	
+	public Collection getAttachPolicyComponents() {
+		return attachedPolicyComponents.values();
+	}
+}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Mon Mar 31 07:51:35 2008
@@ -96,6 +96,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -2296,21 +2297,18 @@
             } else if (wsdl4jExtensibilityElement instanceof SOAP12Address) {
                 SOAP12Address soapAddress = (SOAP12Address) wsdl4jExtensibilityElement;
                 if (description instanceof AxisEndpoint) {
-                    ((AxisEndpoint) description)
-                            .setEndpointURL(soapAddress.getLocationURI());
+                	setEndpointURL((AxisEndpoint) description, soapAddress.getLocationURI());
                 }
 
             } else if (wsdl4jExtensibilityElement instanceof SOAPAddress) {
                 SOAPAddress soapAddress = (SOAPAddress) wsdl4jExtensibilityElement;
                 if (description instanceof AxisEndpoint) {
-                    ((AxisEndpoint) description)
-                            .setEndpointURL(soapAddress.getLocationURI());
+                	setEndpointURL((AxisEndpoint) description, soapAddress.getLocationURI());
                 }
             } else if (wsdl4jExtensibilityElement instanceof HTTPAddress) {
                 HTTPAddress httpAddress = (HTTPAddress) wsdl4jExtensibilityElement;
                 if (description instanceof AxisEndpoint) {
-                    ((AxisEndpoint) description)
-                            .setEndpointURL(httpAddress.getLocationURI());
+                	setEndpointURL((AxisEndpoint) description, httpAddress.getLocationURI());
                 }
 
             } else if (wsdl4jExtensibilityElement instanceof Schema) {
@@ -2841,6 +2839,16 @@
                 }
             }
         }
+    }
+    
+    private void setEndpointURL(AxisEndpoint axisEndpoint, String endpointURL) throws AxisFault {
+    	axisEndpoint.setEndpointURL(endpointURL);
+    	try {
+    		URL url = new URL(endpointURL);
+    		axisEndpoint.setTransportInDescription(url.getProtocol());
+    	} catch (Exception e) {
+    		log.debug(e.getMessage(),e);
+		}    	
     }
 
 

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java Mon Mar 31 07:51:35 2008
@@ -96,6 +96,7 @@
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.HashMap;
@@ -384,7 +385,7 @@
     private AxisEndpoint processEndpoint(Endpoint endpoint, Interface serviceInterface) throws AxisFault {
         AxisEndpoint axisEndpoint = new AxisEndpoint();
         axisEndpoint.setName(endpoint.getName().toString());
-        axisEndpoint.setEndpointURL(endpoint.getAddress().toString());
+        setEndpointURL(axisEndpoint, endpoint.getAddress().toString());
         Binding binding = endpoint.getBinding();
         AxisBinding axisBinding = null;
         if (processedBindings.containsKey(binding.getName())) {
@@ -1279,5 +1280,15 @@
         if (!"".equals(documentation)) {
             axisDescription.setDocumentation(documentation);
         }
+    }
+    
+    private void setEndpointURL(AxisEndpoint axisEndpoint, String endpointURL) {
+    	axisEndpoint.setEndpointURL(endpointURL);
+    	try {
+    		URL url = new URL(endpointURL);
+    		axisEndpoint.setTransportInDescription(url.getProtocol());
+    	} catch (Exception e) {
+    		log.debug(e.getMessage(), e);
+		}    	
     }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AbstractDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AbstractDispatcher.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AbstractDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AbstractDispatcher.java Mon Mar 31 07:51:35 2008
@@ -119,7 +119,13 @@
                     AxisBindingOperation axisBindingOperation =
                             (AxisBindingOperation) axisEndpoint.getBinding()
                                     .getChild(axisOperation.getName());
+                    msgctx
+					.setProperty(
+							Constants.AXIS_BINDING_MESSAGE,
+							axisBindingOperation
+									.getChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
                     msgctx.setProperty(Constants.AXIS_BINDING_OPERATION, axisBindingOperation);
+
                 }
 
             }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java Mon Mar 31 07:51:35 2008
@@ -291,6 +291,7 @@
         axisServiceGroup.setParent(this);
         axisServiceGroup.addService(service);
         addServiceGroup(axisServiceGroup);
+        processEndpoints(service, service.getAxisConfiguration());
     }
 
     public synchronized void addServiceGroup(AxisServiceGroup axisServiceGroup)
@@ -1222,4 +1223,13 @@
 
         return phaseList;
     }
+    
+    private void processEndpoints(AxisService axisService,
+    		AxisConfiguration axisConfiguration) throws AxisFault {
+		String endpointName = axisService.getEndpointName();
+		if (endpointName == null || endpointName.length() == 0) {
+			org.apache.axis2.deployment.util.Utils.addEndpointsToService(
+					axisService, axisConfiguration);
+		}
+	}
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java Mon Mar 31 07:51:35 2008
@@ -19,8 +19,23 @@
 
 package org.apache.axis2.util;
 
-import com.ibm.wsdl.util.xml.DOM2Writer;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Transformer;
+
+import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.axis2.description.AxisDescription;
 import org.apache.axis2.description.AxisMessage;
 import org.apache.axis2.description.AxisOperation;
@@ -32,222 +47,258 @@
 import org.apache.neethi.PolicyEngine;
 import org.apache.neethi.PolicyReference;
 
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.transform.Transformer;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.List;
+import com.ibm.wsdl.util.xml.DOM2Writer;
 
 public class PolicyUtil {
 
-    public static String getSafeString(String unsafeString) {
-        StringBuffer sbuf = new StringBuffer();
+	public static String getSafeString(String unsafeString) {
+		StringBuffer sbuf = new StringBuffer();
+
+		char[] chars = unsafeString.toCharArray();
 
-        char[] chars = unsafeString.toCharArray();
+		for (int i = 0; i < chars.length; i++) {
+			char c = chars[i];
 
-        for (int i = 0; i < chars.length; i++) {
-            char c = chars[i];
+			switch (c) {
+			case '\\':
+				sbuf.append('\\');
+				sbuf.append('\\');
+				break;
+			case '"':
+				sbuf.append('\\');
+				sbuf.append('"');
+				break;
+			case '\n':
+				sbuf.append('\\');
+				sbuf.append('n');
+				break;
+			case '\r':
+				sbuf.append('\\');
+				sbuf.append('r');
+				break;
+			default:
+				sbuf.append(c);
+			}
+		}
+
+		return sbuf.toString();
+	}
+
+	public static PolicyReference createPolicyReference(Policy policy) {
+		PolicyReference policyReference = new PolicyReference();
+		String key = policy.getName();
+		if (key == null) {
+			key = policy.getId();
+			if (key == null) {
+				key = UUIDGenerator.getUUID();
+				policy.setId(key);
+			}
+			policyReference.setURI("#" + key);
+		} else {
+			policyReference.setURI(key);
+		}
+		return policyReference;
+	}
+
+	public static OMElement getPolicyComponentAsOMElement(
+			PolicyComponent policyComponent,
+			ExternalPolicySerializer externalPolicySerializer)
+			throws XMLStreamException, FactoryConfigurationError {
+
+		if (policyComponent instanceof Policy) {
+			ByteArrayOutputStream baos = new ByteArrayOutputStream();
+			externalPolicySerializer.serialize((Policy) policyComponent, baos);
+			ByteArrayInputStream bais = new ByteArrayInputStream(baos
+					.toByteArray());
+			return (OMElement) XMLUtils.toOM(bais);
+
+		} else {
+			OMFactory fac = OMAbstractFactory.getOMFactory();
+			OMElement elem = fac.createOMElement(Constants.ELEM_POLICY_REF,
+					Constants.URI_POLICY_NS, Constants.ATTR_WSP);
+			elem.addAttribute(Constants.ATTR_URI,
+					((PolicyReference) policyComponent).getURI(), null);
+			return elem;
+		}
+	}
+
+	public static OMElement getPolicyComponentAsOMElement(
+			PolicyComponent component) throws XMLStreamException,
+			FactoryConfigurationError {
+
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		XMLStreamWriter writer = XMLOutputFactory.newInstance()
+				.createXMLStreamWriter(baos);
+
+		component.serialize(writer);
+		writer.flush();
+
+		ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+		return (OMElement) XMLUtils.toOM(bais);
+	}
+
+	public static PolicyComponent getPolicyComponentFromOMElement(
+			OMElement policyComponent) throws IllegalArgumentException {
+
+		if (Constants.Q_ELEM_POLICY.equals(policyComponent.getQName())) {
+			return PolicyEngine.getPolicy(policyComponent);
+
+		} else if (policyComponent.getQName().equals(
+				new QName(Constants.URI_POLICY_NS, Constants.ELEM_POLICY_REF))) {
+			return PolicyEngine.getPolicyReference(policyComponent);
+
+		} else {
+			throw new IllegalArgumentException(
+					"Agrument is neither a <wsp:Policy> nor a <wsp:PolicyReference> element");
+		}
+	}
+
+	public static Policy getPolicyFromOMElement(OMElement policyElement) {
+		if (Constants.Q_ELEM_POLICY.equals(policyElement.getQName())) {
+			return PolicyEngine.getPolicy(policyElement);
+		} else {
+			throw new IllegalArgumentException(
+					"argument is not a <wsp:Policy ..> element");
+		}
+	}
+
+	public static PolicyReference getPolicyReferenceFromOMElement(
+			OMElement policyRefElement) {
+		if (Constants.URI_POLICY_NS.equals(policyRefElement.getNamespace()
+				.getNamespaceURI())
+				&& Constants.ELEM_POLICY_REF.equals(policyRefElement
+						.getLocalName())) {
+			return PolicyEngine.getPolicyReference(policyRefElement);
+		} else {
+			throw new IllegalArgumentException(
+					"argument is not a <wsp:PolicyReference> element");
+		}
+	}
+
+	public static PolicyComponent getPolicyComponent(org.w3c.dom.Element element) {
+		if (Constants.URI_POLICY_NS.equals(element.getNamespaceURI())) {
+
+			if (Constants.ELEM_POLICY.equals(element.getLocalName())) {
+				return PolicyEngine.getPolicy(nodeToStream(element));
+
+			} else if (Constants.ELEM_POLICY_REF.equals(element.getLocalName())) {
+				return PolicyEngine.getPolicyReferene(nodeToStream(element));
+			}
+		}
+		throw new IllegalArgumentException(
+				"Agrument is neither a <wsp:Policy> nor a <wsp:PolicyReference> element");
+	}
+
+	private static InputStream nodeToStream(org.w3c.dom.Element element) {
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		Transformer tf;
+		try {
+			// tf = TransformerFactory.newInstance().newTransformer();
+			// tf.transform(new DOMSource(element), new StreamResult(baos));
+			String nodeString = DOM2Writer.nodeToString(element);
+			return new ByteArrayInputStream(nodeString.getBytes());
+		} catch (Exception e) {
+			throw new RuntimeException("Unable to process policy");
+		}
+	}
+
+	public static String policyComponentToString(PolicyComponent policyComponent)
+			throws XMLStreamException, FactoryConfigurationError {
+
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		XMLStreamWriter writer = XMLOutputFactory.newInstance()
+				.createXMLStreamWriter(baos);
+
+		policyComponent.serialize(writer);
+		writer.flush();
+
+		return baos.toString();
+	}
+
+	public static String generateId(AxisDescription description) {
+		PolicyInclude policyInclude = description.getPolicyInclude();
+		String identifier = "-policy-1";
+
+		if (description instanceof AxisMessage) {
+			identifier = "msg-" + ((AxisMessage) description).getName()
+					+ identifier;
+			description = description.getParent();
+		}
+
+		if (description instanceof AxisOperation) {
+			identifier = "op-" + ((AxisOperation) description).getName()
+					+ identifier;
+			description = description.getParent();
+		}
+
+		if (description instanceof AxisService) {
+			identifier = "service-" + ((AxisService) description).getName()
+					+ identifier;
+		}
+
+		/*
+		 * Int 49 is the value of the Character '1'. Here we want to change '1'
+		 * to '2' or '2' to '3' .. etc. to construct a unique identifier.
+		 */
+		for (int index = 49; policyInclude.getPolicy(identifier) != null; index++) {
+			identifier = identifier.replace((char) index, (char) (index + 1));
+		}
+
+		return identifier;
+	}
+
+	public static Policy getMergedPolicy(List policies,
+			AxisDescription description) {
+
+		Policy policy = null;
+
+		for (Iterator iterator = policies.iterator(); iterator.hasNext();) {
+			Object policyElement = iterator.next();
+			if (policyElement instanceof Policy) {
+				policy = (policy == null) ? (Policy) policyElement
+						: (Policy) policy.merge((Policy) policyElement);
+
+			} else {
+				PolicyReference policyReference = (PolicyReference) policyElement;
+				Policy policy2 = (Policy) policyReference.normalize(
+						new AxisPolicyLocator(description), false);
+				policy = (policy == null) ? policy2 : (Policy) policy
+						.merge(policy2);
+			}
+		}
+
+		if (policy != null) {
+			policy = (Policy) policy.normalize(new AxisPolicyLocator(
+					description), false);
+		}
+
+		return policy;
+	}
+
+	public static Policy getMergedPolicy(List policies, AxisService service) {
+
+		Policy policy = null;
+
+		for (Iterator iterator = policies.iterator(); iterator.hasNext();) {
+			Object policyElement = iterator.next();
+			if (policyElement instanceof Policy) {
+				policy = (policy == null) ? (Policy) policyElement
+						: (Policy) policy.merge((Policy) policyElement);
+
+			} else {
+				PolicyReference policyReference = (PolicyReference) policyElement;
+				Policy policy2 = (Policy) policyReference.normalize(
+						new PolicyLocator(service), false);
+				policy = (policy == null) ? policy2 : (Policy) policy
+						.merge(policy2);
+			}
+		}
+
+		if (policy != null) {
+			policy = (Policy) policy.normalize(new PolicyLocator(service),
+					false);
+		}
 
-            switch (c) {
-                case'\\':
-                    sbuf.append('\\');
-                    sbuf.append('\\');
-                    break;
-                case'"':
-                    sbuf.append('\\');
-                    sbuf.append('"');
-                    break;
-                case'\n':
-                    sbuf.append('\\');
-                    sbuf.append('n');
-                    break;
-                case'\r':
-                    sbuf.append('\\');
-                    sbuf.append('r');
-                    break;
-                default:
-                    sbuf.append(c);
-            }
-        }
-
-        return sbuf.toString();
-    }
-
-    public static OMElement getPolicyComponentAsOMElement(
-            PolicyComponent policyComponent,
-            ExternalPolicySerializer externalPolicySerializer)
-            throws XMLStreamException, FactoryConfigurationError {
-
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
-        if (policyComponent instanceof Policy) {
-            externalPolicySerializer.serialize((Policy) policyComponent, baos);
-
-        } else {
-            XMLStreamWriter writer = XMLOutputFactory.newInstance()
-                    .createXMLStreamWriter(baos);
-            policyComponent.serialize(writer);
-            writer.flush();
-        }
-
-        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-        return (OMElement) XMLUtils.toOM(bais);
-
-    }
-
-    public static OMElement getPolicyComponentAsOMElement(
-            PolicyComponent component) throws XMLStreamException,
-            FactoryConfigurationError {
-
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        XMLStreamWriter writer = XMLOutputFactory.newInstance()
-                .createXMLStreamWriter(baos);
-
-        component.serialize(writer);
-        writer.flush();
-
-        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-        return (OMElement) XMLUtils.toOM(bais);
-    }
-
-    public static PolicyComponent getPolicyComponentFromOMElement(
-            OMElement policyComponent) throws IllegalArgumentException {
-
-        if (policyComponent instanceof Policy) {
-            return PolicyEngine.getPolicy(policyComponent);
-
-        } else if (policyComponent instanceof PolicyReference) {
-            return PolicyEngine.getPolicyReference(policyComponent);
-
-        } else {
-            throw new IllegalArgumentException(
-                    "Agrument is neither a <wsp:Policy> nor a <wsp:PolicyReference> element");
-        }
-    }
-
-    public static PolicyComponent getPolicyComponent(org.w3c.dom.Element element) {
-        if (Constants.URI_POLICY_NS.equals(element.getNamespaceURI())) {
-
-            if (Constants.ELEM_POLICY.equals(element.getLocalName())) {
-                return PolicyEngine.getPolicy(nodeToStream(element));
-
-            } else if (Constants.ELEM_POLICY_REF.equals(element.getLocalName())) {
-                return PolicyEngine.getPolicyReferene(nodeToStream(element));
-            }
-        }
-
-        throw new IllegalArgumentException(
-                "Agrument is neither a <wsp:Policy> nor a <wsp:PolicyReference> element");
-    }
-
-    private static InputStream nodeToStream(org.w3c.dom.Element element) {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        Transformer tf;
-        try {
-//            tf = TransformerFactory.newInstance().newTransformer();
-//            tf.transform(new DOMSource(element), new StreamResult(baos));
-            String nodeString =DOM2Writer.nodeToString(element);
-            return new ByteArrayInputStream(nodeString.getBytes());
-        } catch (Exception e) {
-            throw new RuntimeException("Unable to process policy");
-        }
-    }
-
-    public static String policyComponentToString(PolicyComponent policyComponent)
-            throws XMLStreamException, FactoryConfigurationError {
-
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        XMLStreamWriter writer = XMLOutputFactory.newInstance()
-                .createXMLStreamWriter(baos);
-
-        policyComponent.serialize(writer);
-        writer.flush();
-
-        return baos.toString();
-    }
-
-    public static String generateId(AxisDescription description) {
-        PolicyInclude policyInclude = description.getPolicyInclude();
-        String identifier = "-policy-1";
-
-        if (description instanceof AxisMessage) {
-            identifier = "msg-" + ((AxisMessage) description).getName() + identifier;
-            description = description.getParent();
-        }
-
-        if (description instanceof AxisOperation) {
-            identifier = "op-" + ((AxisOperation) description).getName() + identifier;
-            description = description.getParent();
-        }
-
-        if (description instanceof AxisService) {
-            identifier = "service-" + ((AxisService) description).getName() + identifier;
-        }
-
-        /*
-        *  Int 49 is the value of the Character '1'. Here we want to change '1' to '2' or
-        *  '2' to '3' .. etc. to construct a unique identifier.
-        */
-        for (int index = 49; policyInclude.getPolicy(identifier) != null; index++) {
-            identifier = identifier.replace((char) index, (char) (index + 1));
-        }
-
-        return identifier;
-    }
-    
-    
-    public static Policy getMergedPolicy(List policies, AxisDescription description) {
-        
-        Policy policy = null;
-        
-        for (Iterator iterator = policies.iterator(); iterator.hasNext(); ) {
-            Object policyElement = iterator.next()
-            ;
-            if (policyElement instanceof Policy) {
-                policy = (policy == null) ? (Policy) policyElement : (Policy) policy.merge((Policy) policyElement);
-                
-            } else {
-                PolicyReference policyReference = (PolicyReference) policyElement;
-                Policy policy2 = (Policy) policyReference.normalize(new AxisPolicyLocator(description), false);
-                policy = (policy == null) ? policy2 : (Policy) policy.merge(policy2);                 
-            }
-        }
-        
-        
-        if (policy != null) {
-            policy = (Policy) policy.normalize(new AxisPolicyLocator(description), false);            
-        }
-        
-        return policy;        
-    }
-    
-    public static Policy getMergedPolicy(List policies, AxisService service) {
-    	
-        Policy policy = null;
-        
-        for (Iterator iterator = policies.iterator(); iterator.hasNext(); ) {
-            Object policyElement = iterator.next()
-            ;
-            if (policyElement instanceof Policy) {
-                policy = (policy == null) ? (Policy) policyElement : (Policy) policy.merge((Policy) policyElement);
-                
-            } else {
-                PolicyReference policyReference = (PolicyReference) policyElement;
-                Policy policy2 = (Policy) policyReference.normalize(new PolicyLocator(service), false);
-                policy = (policy == null) ? policy2 : (Policy) policy.merge(policy2);                 
-            }
-        }
-        
-        
-        if (policy != null) {
-            policy = (Policy) policy.normalize(new PolicyLocator(service), false);            
-        }
-        
-        return policy;        
-    }
+		return policy;
+	}
 }

Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/EnginePausingTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/EnginePausingTest.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/EnginePausingTest.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/EnginePausingTest.java Mon Mar 31 07:51:35 2008
@@ -123,6 +123,7 @@
         AxisBinding binding = new AxisBinding();
         AxisBindingOperation bindingOp = new AxisBindingOperation();
 
+        bindingOp.setName(axisOp.getName());
         bindingOp.setAxisOperation(axisOp);
         binding.addChild(bindingOp);
         endpoint.setBinding(binding);



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message