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 ip...@apache.org on 2005/04/21 20:14:02 UTC
cvs commit: ws-fx/addressing/src/org/apache/axis/message/addressing/util AddressingUtils.java
ips 2005/04/21 11:14:02
Modified: addressing/src/org/apache/axis/message/addressing/util
AddressingUtils.java
Log:
added fix to getResponseRelationshipType(); enhanced getAddressingNamespaceURI() to check for a "addressing.namespace.URI" sysprop prior to falling through to the hard-coded default of the WSA 2004/08 ns
Revision Changes Path
1.7 +80 -62 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AddressingUtils.java 8 Apr 2005 15:57:25 -0000 1.6
+++ AddressingUtils.java 21 Apr 2005 18:14:02 -0000 1.7
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,6 @@
* limitations under the License.
*
*/
-
package org.apache.axis.message.addressing.util;
import org.apache.axis.message.addressing.Constants;
@@ -42,15 +41,15 @@
import javax.xml.rpc.handler.MessageContext;
/**
- * Class AddressingUtils
+ * A set of WS-Addressing-related utility methods.
*
* @author Jarek Gawor (gawor@apache.org)
*/
public abstract class AddressingUtils {
/**
- * A set that contains the namespace URIs (as Strings) for the various revisions of
- * Addressing that we support.
+ * A set that contains the namespace URIs (as Strings) for the various versions of
+ * WSA that we support.
*/
private static final Set ADDRESSING_NS_URI_SET = new HashSet();
static {
@@ -60,8 +59,8 @@
}
/**
- * Removes all instances of a given header name in WS-Addressing
- * namespace for a given actor.
+ * Removes all instances of a given header name in WSA namespace for
+ * a given actor.
*/
public static void removeHeader(SOAPHeader soapHeader,
String actorURI,
@@ -85,13 +84,18 @@
}
}
- public static boolean isAddressingNamespaceURI( String nsURI ) {
- return ADDRESSING_NS_URI_SET.contains( nsURI );
+ /**
+ * Returns true if the specified URI is corresponds to the namespace URI
+ * of a supported version of the WSA specification, or false otherwise.
+ *
+ * @param uri a URI
+ */
+ public static boolean isAddressingNamespaceURI( String uri ) {
+ return ADDRESSING_NS_URI_SET.contains( uri );
}
/**
- * Removes all instances of all WS-Addressing headers for a given
- * actor.
+ * Removes all instances of all WSA headers for a given actor.
*/
public static void removeHeaders(SOAPHeader soapHeader,
String actorURI) {
@@ -132,24 +136,9 @@
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.
+ * Gets input action. See section 3.3 of the 2004/08 WSA specification.
*/
public static String getInputAction(QName portTypeQName,
Operation operation) {
@@ -165,8 +154,7 @@
}
/**
- * Gets output action. See section 3.3 of the 2004 WS-Addressing
- * specification.
+ * Gets output action. See section 3.3 of the 2004/08 WSA specification.
*/
public static String getOutputAction(QName portTypeQName,
Operation operation) {
@@ -180,35 +168,7 @@
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(new QName(getAddressingNamespaceURI(), Constants.WSDL_ATTRIB_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();
- }
-
+
/**
* Gets prefix for a given namespace. If the prefix is already defined
* for the namespace given, it is returned. Otherwise, a new prefix is
@@ -247,12 +207,16 @@
*/
public static String getAddressingNamespaceURI()
{
- // NOTE: this is currently Axis-specific...
String nsURI = null;
+ // NOTE: the below call is Axis-specific :-(
org.apache.axis.MessageContext msgContext = AxisEngine.getCurrentMessageContext();
if ( msgContext != null )
{
- nsURI = (String) msgContext.getProperty( Constants.ENV_ADDRESSING_NAMESPACE_URI );
+ nsURI = (String) msgContext.getProperty( Constants.ENV_ADDRESSING_NAMESPACE_URI );
+ }
+ if ( nsURI == null )
+ {
+ nsURI = (String) System.getProperty( Constants.ENV_ADDRESSING_NAMESPACE_URI );
}
if ( nsURI == null )
{
@@ -261,24 +225,78 @@
return nsURI;
}
+ /**
+ * Returns the fault wsa:Action URI that is appropriate for the WSA
+ * version being used.
+ */
public static String getFaultActionURI()
{
return getAddressingNamespaceURI() + "/fault";
}
+ /**
+ * Returns the anonymous endpoint URI that is appropriate for the WSA
+ * version being used.
+ */
public static String getAnonymousRoleURI()
{
return getAddressingNamespaceURI() + "/role/anonymous";
}
+ /**
+ * Returns the response/reply relationship QName that is appropriate for the
+ * WSA version being used.
+ */
public static QName getResponseRelationshipType()
{
String nsURI = getAddressingNamespaceURI();
if (nsURI.equals(Constants.NS_URI_ADDRESSING_2003_03)) {
- return new QName(Constants.NS_URI_ADDRESSING_DEFAULT, Constants.RESPONSE);
+ return new QName(nsURI, Constants.RESPONSE);
} else {
- return new QName(Constants.NS_URI_ADDRESSING_DEFAULT, Constants.REPLY);
+ return new QName(nsURI, Constants.REPLY);
}
}
+ private static AddressingHeaders getHeaders(MessageContext msgContext,
+ String type) {
+ AddressingHeaders headers =
+ (AddressingHeaders)msgContext.getProperty(type);
+
+ if (headers == null) {
+ headers = new AddressingHeaders();
+ // set property so other handlers might have a chance to use/modify
+ msgContext.setProperty(type, headers);
+ }
+
+ return headers;
+ }
+
+ private static String getAction(AttributeExtensible inputOutput,
+ String inputOutputName,
+ QName portTypeQName,
+ Operation operation,
+ String defaultName) {
+ Object value =
+ inputOutput.getExtensionAttribute(new QName(getAddressingNamespaceURI(), Constants.WSDL_ATTRIB_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();
+ }
+
}