You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by ga...@apache.org on 2004/07/04 07:37:06 UTC
cvs commit: ws-fx/addressing/src/org/apache/axis/message/addressing/util AddressingUtils.java
gawor 2004/07/03 22:37:06
Modified: addressing/src/org/apache/axis/message/addressing
Constants.java
addressing/src/org/apache/axis/message/addressing/handler
AddressingHandler.java
addressing/src/org/apache/axis/message/addressing/util
AddressingUtils.java
Log:
added util functions to get input/output actions based on wsdl, made functions protected in handler to allow overriding
Revision Changes Path
1.6 +6 -0 ws-fx/addressing/src/org/apache/axis/message/addressing/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/Constants.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Constants.java 18 Jun 2004 20:39:45 -0000 1.5
+++ Constants.java 4 Jul 2004 05:37:06 -0000 1.6
@@ -181,6 +181,12 @@
public static final String ENV_ADDRESSING_RESPONSE_HEADERS =
"org.apache.axis.message.addressing.RESPONSE.HEADERS";
+ /**
+ * Field QNAME_ACTION
+ */
+ public static final QName QNAME_ACTION =
+ new QName(NS_URI_ADDRESSING, ACTION);
+
static {
if (NS_URI_ADDRESSING.equals(NS_URI_ADDRESSING_04)) {
QNAME_RESPONSE = new QName(NS_URI_ADDRESSING, REPLY);
1.21 +15 -32 ws-fx/addressing/src/org/apache/axis/message/addressing/handler/AddressingHandler.java
Index: AddressingHandler.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/handler/AddressingHandler.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- AddressingHandler.java 25 Jun 2004 05:46:20 -0000 1.20
+++ AddressingHandler.java 4 Jul 2004 05:37:06 -0000 1.21
@@ -32,6 +32,7 @@
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.apache.axis.message.addressing.MessageID;
import org.apache.axis.message.addressing.To;
+import org.apache.axis.message.addressing.util.AddressingUtils;
import org.apache.axis.types.URI;
import org.apache.commons.logging.Log;
@@ -121,7 +122,7 @@
}
}
- private void processFault(MessageContext msgContext)
+ protected void processFault(MessageContext msgContext)
throws Exception {
AddressingHeaders reqHeaders =
(AddressingHeaders) msgContext.getProperty(
@@ -133,17 +134,8 @@
return;
}
- AddressingHeaders resHeaders =
- (AddressingHeaders) msgContext.getProperty(
- Constants.ENV_ADDRESSING_RESPONSE_HEADERS
- );
-
- if (resHeaders == null) {
- resHeaders = new AddressingHeaders();
- // set property so other handlers might have a chance to use/modify
- msgContext.setProperty(Constants.ENV_ADDRESSING_RESPONSE_HEADERS,
- resHeaders);
- }
+ AddressingHeaders resHeaders =
+ AddressingUtils.getResponseHeaders(msgContext);
// set From
EndpointReference fromEPR = resHeaders.getFrom();
@@ -204,8 +196,8 @@
*
* @param msgContext
*/
- void processClientRequest(MessageContext msgContext,
- boolean setMustUnderstand)
+ protected void processClientRequest(MessageContext msgContext,
+ boolean setMustUnderstand)
throws Exception {
AddressingHeaders headers =
(AddressingHeaders) msgContext.getProperty(
@@ -252,7 +244,7 @@
*
* @param msgContext
*/
- void processClientResponse(MessageContext msgContext)
+ protected void processClientResponse(MessageContext msgContext)
throws Exception {
// if no response - do nothing
Message msg = msgContext.getResponseMessage();
@@ -277,7 +269,7 @@
* @param msgContext
* @throws Exception
*/
- void processServerRequest(MessageContext msgContext)
+ protected void processServerRequest(MessageContext msgContext)
throws Exception {
Message msg = msgContext.getRequestMessage();
if (msg == null) {
@@ -329,14 +321,14 @@
int i = to.lastIndexOf('/');
msgContext.setTargetService(to.substring(i + 1));
}
-
+
/**
* Method processServerResponse
*
* @param msgContext
*/
- void processServerResponse(MessageContext msgContext,
- boolean setMustUnderstand)
+ protected void processServerResponse(MessageContext msgContext,
+ boolean setMustUnderstand)
throws Exception {
// if no response - do nothing
Message msg = msgContext.getResponseMessage();
@@ -354,17 +346,8 @@
return;
}
- AddressingHeaders resHeaders =
- (AddressingHeaders) msgContext.getProperty(
- Constants.ENV_ADDRESSING_RESPONSE_HEADERS
- );
-
- if (resHeaders == null) {
- resHeaders = new AddressingHeaders();
- // set property so other handlers might have a chance to use/modify
- msgContext.setProperty(Constants.ENV_ADDRESSING_RESPONSE_HEADERS,
- resHeaders);
- }
+ AddressingHeaders resHeaders =
+ AddressingUtils.getRequestHeaders(msgContext);
resHeaders.setSetMustUnderstand(setMustUnderstand);
@@ -428,8 +411,8 @@
}
}
- private void forwardMessage(EndpointReferenceType epr,
- Message msg)
+ protected void forwardMessage(EndpointReferenceType epr,
+ Message msg)
throws Exception {
Address address = epr.getAddress();
1.2 +107 -0 ws-fx/addressing/src/org/apache/axis/message/addressing/util/AddressingUtils.java
Index: AddressingUtils.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/util/AddressingUtils.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddressingUtils.java 22 Jun 2004 05:00:19 -0000 1.1
+++ AddressingUtils.java 4 Jul 2004 05:37:06 -0000 1.2
@@ -17,7 +17,10 @@
package org.apache.axis.message.addressing.util;
+import org.apache.axis.MessageContext;
+
import org.apache.axis.message.addressing.Constants;
+import org.apache.axis.message.addressing.AddressingHeaders;
import java.util.Iterator;
import java.util.List;
@@ -27,6 +30,13 @@
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
+import javax.wsdl.Input;
+import javax.wsdl.Output;
+import javax.wsdl.Operation;
+import javax.wsdl.extensions.AttributeExtensible;
+
+import javax.xml.namespace.QName;
+
/**
* Class AddressingUtils
*
@@ -56,4 +66,101 @@
}
}
+ /**
+ * Gets response <code>AddressingHeaders</code> associated with the
+ * specified context. If there are no <code>AddressingHeaders</code>
+ * associated with the context, new reponse <code>AddressingHeaders</code>
+ * are created and associated with the context.
+ */
+ public static AddressingHeaders getResponseHeaders(MessageContext msgCtx) {
+ return getHeaders(msgCtx, Constants.ENV_ADDRESSING_RESPONSE_HEADERS);
+ }
+
+ /**
+ * Gets request <code>AddressingHeaders</code> associated with the
+ * specified context. If there are no <code>AddressingHeaders</code>
+ * associated with the context, new request <code>AddressingHeaders</code>
+ * are created and associated with the context.
+ */
+ public static AddressingHeaders getRequestHeaders(MessageContext msgCtx) {
+ return getHeaders(msgCtx, Constants.ENV_ADDRESSING_REQUEST_HEADERS);
+ }
+
+ private static AddressingHeaders getHeaders(MessageContext msgCtx,
+ String type) {
+ AddressingHeaders headers =
+ (AddressingHeaders)msgCtx.getProperty(type);
+
+ if (headers == null) {
+ headers = new AddressingHeaders();
+ // set property so other handlers might have a chance to use/modify
+ msgCtx.setProperty(type, headers);
+ }
+
+ return headers;
+ }
+
+ /**
+ * Gets input action. See section 3.3 of the 2004 WS-Addressing
+ * specification.
+ */
+ public static String getInputAction(QName portTypeQName,
+ Operation operation) {
+ if (portTypeQName == null || operation == null) {
+ throw new IllegalArgumentException();
+ }
+ Input input = operation.getInput();
+ if (input == null) {
+ return null;
+ }
+ return getAction(input, input.getName(),
+ portTypeQName, operation, "Request");
+ }
+
+ /**
+ * Gets output action. See section 3.3 of the 2004 WS-Addressing
+ * specification.
+ */
+ public static String getOutputAction(QName portTypeQName,
+ Operation operation) {
+ if (portTypeQName == null || operation == null) {
+ throw new IllegalArgumentException();
+ }
+ Output output = operation.getOutput();
+ if (output == null) {
+ return null;
+ }
+ return getAction(output, output.getName(),
+ portTypeQName, operation, "Response");
+ }
+
+ private static String getAction(AttributeExtensible inputOutput,
+ String inputOutputName,
+ QName portTypeQName,
+ Operation operation,
+ String defaultName) {
+ Object value =
+ inputOutput.getExtensionAttribute(Constants.QNAME_ACTION);
+ if (value != null) {
+ // wsdl4j returns a qname by default?
+ if (value instanceof QName) {
+ return ((QName)value).getLocalPart();
+ } else {
+ return value.toString();
+ }
+ }
+ String name = inputOutputName;
+ if (name == null) {
+ name = operation.getName() + defaultName;
+ }
+ StringBuffer buf = new StringBuffer(50);
+ buf.append(portTypeQName.getNamespaceURI());
+ if (!portTypeQName.getNamespaceURI().endsWith("/")) {
+ buf.append("/");
+ }
+ buf.append(portTypeQName.getLocalPart()).append("/").append(name);
+ return buf.toString();
+ }
+
+
}