You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2008/06/16 11:41:26 UTC

svn commit: r668095 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: description/ engine/ receivers/

Author: sanka
Date: Mon Jun 16 02:41:26 2008
New Revision: 668095

URL: http://svn.apache.org/viewvc?rev=668095&view=rev
Log:
Fixed the codebase s.t.
- When modifyUserWSDLPortAddress is set to true, the port address of stored WSDL is modified to the correct service address. 
- When messageReceiver.invokeOnSeparateThread property is set for a service, the AsyncMessageReceiverWroker will start in a separate thread even if ReplyTo is null for InOnly MEP.
- The AxisBindingOperation is located based on only the local part of QName of AxisOperation. (The namespaces may differ if wsdl:binding belongs to a different namespace). 




Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AbstractDispatcher.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java?rev=668095&r1=668094&r2=668095&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java Mon Jun 16 02:41:26 2008
@@ -173,7 +173,7 @@
 		this.transportInDescName = transportInDescName;
 	}
 
-	private String calculateEndpointURL() {
+	public String calculateEndpointURL() {
 		if (transportInDescName != null && parent != null) {
 			AxisConfiguration axisConfiguration = getAxisConfiguration();
 			if (axisConfiguration != null) {

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=668095&r1=668094&r2=668095&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 Jun 16 02:41:26 2008
@@ -667,7 +667,7 @@
 					QName qname = axisBinding.getName();
 					port.addAttribute(BINDING_LOCAL_NAME, tns.getPrefix() + ":"
 							+ qname.getLocalPart(), null);
-					String endpointURL = axisEndpoint.getEndpointURL();
+					String endpointURL = getEndpointURL(axisEndpoint);
 					WSDLSerializationUtil.addExtensionElement(fac, port,
 							SOAP_ADDRESS, LOCATION, (endpointURL == null) ? ""
 									: endpointURL, soap);
@@ -709,7 +709,7 @@
 					QName qname = axisBinding.getName();
 					port.addAttribute(BINDING_LOCAL_NAME, tns.getPrefix() + ":"
 							+ qname.getLocalPart(), null);
-					String endpointURL = axisEndpoint.getEndpointURL();
+					String endpointURL = getEndpointURL(axisEndpoint);
 					WSDLSerializationUtil.addExtensionElement(fac, port,
 							SOAP_ADDRESS, LOCATION, (endpointURL == null) ? ""
 									: endpointURL, soap12);
@@ -746,7 +746,7 @@
 				port.addAttribute(BINDING_LOCAL_NAME, tns.getPrefix() + ":"
 						+ qname.getLocalPart(), null);
 				OMElement extElement = fac.createOMElement("address", http);
-				String endpointURL = axisEndpoint.getEndpointURL();
+				String endpointURL = getEndpointURL(axisEndpoint);
 				extElement.addAttribute("location", (endpointURL == null) ? ""
 						: endpointURL, null);
 				port.addChild(extElement);
@@ -1280,4 +1280,15 @@
 		}
 		return false;
 	}
+	
+	private String getEndpointURL(AxisEndpoint axisEndpoint) {
+		Parameter modifyAddressParam = axisService
+				.getParameter("modifyUserWSDLPortAddress");
+		if (modifyAddressParam != null) {
+			if (Boolean.parseBoolean((String) modifyAddressParam.getValue())) {
+				return axisEndpoint.calculateEndpointURL();
+			}
+		}
+		return axisEndpoint.getEndpointURL();
+	}
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java?rev=668095&r1=668094&r2=668095&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java Mon Jun 16 02:41:26 2008
@@ -300,7 +300,21 @@
                 }
                 if (!endpointAlreadyAdded) {
 //                	addPolicyAsExtensibleElement(axisEndpoint, endpointElement);
-                    serviceElement.addChild(endpointElement);
+                	Parameter modifyAddressParam = axisService
+							.getParameter("modifyUserWSDLPortAddress");
+					if (modifyAddressParam != null) {
+						if (Boolean.parseBoolean((String) modifyAddressParam
+								.getValue())) {
+							String endpointURL = axisEndpoint
+									.calculateEndpointURL();
+							endpointElement
+									.getAttribute(
+											new QName(
+													WSDL2Constants.ATTRIBUTE_ADDRESS))
+									.setAttributeValue(endpointURL);
+						}
+					}
+                	serviceElement.addChild(endpointElement);
                 }
             }
             Iterator iter = bindings.iterator();

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=668095&r1=668094&r2=668095&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 Jun 16 02:41:26 2008
@@ -569,6 +569,8 @@
 
 	private void populatePortType(PortType wsdl4jPortType,
                                   Definition portTypeWSDL) throws AxisFault {
+		copyExtensionAttributes(wsdl4jPortType.getExtensionAttributes(),
+				axisService, PORT_TYPE);
         List wsdl4jOperations = wsdl4jPortType.getOperations();
 
         // Added to use in ?wsdl2 as the interface name
@@ -2740,55 +2742,54 @@
      * @param origin
      */
     private void copyExtensionAttributes(Map extAttributes,
-                                         AxisDescription description, String origin) {
+			AxisDescription description, String origin) {
 
-        QName key;
-        QName value;
+		QName key;
+		QName value;
 
-        for (Iterator iterator = extAttributes.keySet().iterator(); iterator
-                .hasNext();) {
-            key = (QName) iterator.next();
-
-            if (Constants.URI_POLICY_NS.equals(key.getNamespaceURI())
-                && "PolicyURIs".equals(key.getLocalPart())) {
-
-                value = (QName) extAttributes.get(key);
-                String policyURIs = value.getLocalPart();
-
-                if (policyURIs.length() != 0) {
-                    String[] uris = policyURIs.split(" ");
-
-                    PolicyReference ref;
-                    for (int i = 0; i < uris.length; i++) {
-                        ref = new PolicyReference();
-                        ref.setURI(uris[i]);
-
-                        if (PORT_TYPE.equals(origin)) {
-                            PolicyInclude include = description
-                                    .getPolicyInclude();
-                            include.addPolicyRefElement(
-                                    PolicyInclude.PORT_TYPE_POLICY, ref);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Process the policy definitions
-     *
-     * @param definition
-     */
+		for (Iterator iterator = extAttributes.keySet().iterator(); iterator
+				.hasNext();) {
+			key = (QName) iterator.next();
+
+			if (Constants.URI_POLICY_NS.equals(key.getNamespaceURI())
+					&& "PolicyURIs".equals(key.getLocalPart())) {
+
+				value = (QName) extAttributes.get(key);
+				String policyURIs = value.getLocalPart();
+
+				if (policyURIs.length() != 0) {
+					String[] uris = policyURIs.split(" ");
+
+					PolicyReference ref;
+					for (int i = 0; i < uris.length; i++) {
+						ref = new PolicyReference();
+						ref.setURI(uris[i]);
+
+						if (PORT_TYPE.equals(origin)) {
+							PolicySubject subject = description
+									.getPolicySubject();
+							subject.attachPolicyReference(ref);
+						}
+					}
+				}
+			}
+		}
+	}
+
+    /**
+	 * Process the policy definitions
+	 * 
+	 * @param definition
+	 */
     private void processPoliciesInDefintion(Definition definition) {
         processPoliciesInDefintion(definition, new HashSet());
     }
 
     /**
-     * Process the policy definitions
-     *
-     * @param definition
-     */
+	 * Process the policy definitions
+	 * 
+	 * @param definition
+	 */
     private void processPoliciesInDefintion(Definition definition, Set visitedWSDLs) {
         visitedWSDLs.add(definition.getDocumentBaseURI());
         List extElements = definition.getExtensibilityElements();

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=668095&r1=668094&r2=668095&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 Jun 16 02:41:26 2008
@@ -20,9 +20,12 @@
 
 package org.apache.axis2.engine;
 
+import java.util.Iterator;
+
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisBinding;
 import org.apache.axis2.description.AxisBindingOperation;
 import org.apache.axis2.description.AxisEndpoint;
 import org.apache.axis2.description.AxisOperation;
@@ -117,13 +120,28 @@
                         (AxisEndpoint) msgctx.getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME);
 
                 if (axisEndpoint != null) {
-                    AxisBindingOperation axisBindingOperation =
-                            (AxisBindingOperation) axisEndpoint.getBinding().getChild(axisOperation.getName());
-                    if (axisBindingOperation != null) {
-                        msgctx.setProperty(Constants.AXIS_BINDING_MESSAGE,
-                                axisBindingOperation.getChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
-                        msgctx.setProperty(Constants.AXIS_BINDING_OPERATION, axisBindingOperation);
-                    }
+                    AxisBinding axisBinding = axisEndpoint.getBinding();
+					AxisBindingOperation axisBindingOperation = (AxisBindingOperation) axisBinding
+							.getChild(axisOperation.getName());
+					if (axisBindingOperation == null) {
+						String localName = axisOperation.getName()
+								.getLocalPart();
+						AxisBindingOperation bindingOp = null;
+						for (Iterator iterator = axisBinding.getChildren(); iterator
+								.hasNext();) {
+							bindingOp = (AxisBindingOperation) iterator.next();
+							if (localName.equals(bindingOp.getName().getLocalPart())) {
+								axisBindingOperation = bindingOp;
+								break;
+							}
+						}
+					}
+                    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/receivers/AbstractMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java?rev=668095&r1=668094&r2=668095&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java Mon Jun 16 02:41:26 2008
@@ -40,8 +40,10 @@
 import org.apache.axis2.engine.DependencyManager;
 import org.apache.axis2.engine.MessageReceiver;
 import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.util.Loader;
 import org.apache.axis2.util.MessageContextBuilder;
+import org.apache.axis2.wsdl.WSDLUtil;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -85,15 +87,25 @@
      * @throws AxisFault if a problem occurred
      */
     public void receive(final MessageContext messageCtx) throws AxisFault {
-        if (messageCtx.isPropertyTrue(DO_ASYNC)) {
-            EndpointReference replyTo = messageCtx.getReplyTo();
-            if (replyTo != null && !replyTo.hasAnonymousAddress()) {
-                AsyncMessageReceiverWorker worker = new AsyncMessageReceiverWorker(messageCtx);
-                messageCtx.getEnvelope().build();
-                messageCtx.getConfigurationContext().getThreadPool().execute(worker);
-                return;
-            }
-        }
+    	if (messageCtx.isPropertyTrue(DO_ASYNC)
+				|| JavaUtils.isTrue(messageCtx.getParameter(DO_ASYNC))) {
+			String mep = messageCtx.getAxisOperation()
+					.getMessageExchangePattern();
+			EndpointReference replyTo = messageCtx.getReplyTo();
+			// In order to invoke the service in the ASYNC mode, the request
+			// should contain ReplyTo header if the MEP of the service is not
+			// InOnly type
+			if ((!WSDLUtil.isOutputPresentForMEP(mep))
+					|| (replyTo != null && !replyTo.hasAnonymousAddress())) {
+				AsyncMessageReceiverWorker worker = new AsyncMessageReceiverWorker(
+						messageCtx);
+				messageCtx.getEnvelope().build();
+				messageCtx.getConfigurationContext().getThreadPool().execute(
+						worker);
+				return;
+			}
+		}
+
 
         ThreadContextDescriptor tc = setThreadContext(messageCtx);
         try {