You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by na...@apache.org on 2010/02/25 17:04:01 UTC
svn commit: r916333 - in /axis/axis2/java/core/trunk/modules:
jaxws/src/org/apache/axis2/jaxws/spi/Provider.java
kernel/src/org/apache/axis2/addressing/metadata/WSDLLocation.java
kernel/test/org/apache/axis2/addressing/EndpointReferenceHelperTest.java
Author: nagy
Date: Thu Feb 25 16:04:00 2010
New Revision: 916333
URL: http://svn.apache.org/viewvc?rev=916333&view=rev
Log:
AXIS2-4574
Update WSDL Instance namespace on wsdlLocation Metadata attribute to make it match the example in the WS-A Metadata Spec and be compliant with the new WSDL 2.0 spec.
Contributor: Katherine Sanders
Modified:
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/addressing/metadata/WSDLLocation.java
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/addressing/EndpointReferenceHelperTest.java
Modified: axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java?rev=916333&r1=916332&r2=916333&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java (original)
+++ axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java Thu Feb 25 16:04:00 2010
@@ -26,6 +26,8 @@
import org.apache.axis2.jaxws.addressing.util.EndpointReferenceUtils;
import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.server.endpoint.EndpointImpl;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Element;
import javax.xml.namespace.QName;
@@ -40,6 +42,8 @@
import java.util.List;
public class Provider extends javax.xml.ws.spi.Provider {
+ private static final Log log = LogFactory.getLog(Provider.class);
+
private static final Element[] ZERO_LENGTH_ARRAY = new Element[0];
@Override
@@ -126,10 +130,17 @@
EndpointReferenceHelper.getWSDLLocationMetadata(axis2EPR, addressingNamespace);
URL wsdlLocationURL = null;
- if (wsdlLocation.getLocation() != null)
+ if (wsdlLocation.getLocation() != null) {
wsdlLocationURL = new URL(wsdlLocation.getLocation());
- else
+ if (log.isDebugEnabled()) {
+ log.debug("getPort: Using EPR wsdlLocationURL = " + wsdlLocationURL);
+ }
+ } else {
wsdlLocationURL = new URL(axis2EPR.getAddress() + "?wsdl");
+ if (log.isDebugEnabled()) {
+ log.debug("getPort: Using default wsdlLocationURL = " + wsdlLocationURL);
+ }
+ }
serviceDelegate =
new org.apache.axis2.jaxws.spi.ServiceDelegate(wsdlLocationURL, serviceName.getName(), Service.class);
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/addressing/metadata/WSDLLocation.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/addressing/metadata/WSDLLocation.java?rev=916333&r1=916332&r2=916333&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/addressing/metadata/WSDLLocation.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/addressing/metadata/WSDLLocation.java Thu Feb 25 16:04:00 2010
@@ -23,11 +23,17 @@
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import javax.xml.namespace.QName;
public class WSDLLocation {
+ private static final Log log = LogFactory.getLog(WSDLLocation.class);
+
+ // Support both WSDLI namespaces on inbound messages to allow interop with earlier versions of axis2
private static final QName WSDLI = new QName("http://www.w3.org/2006/01/wsdl-instance", "wsdlLocation", "wsdli");
+ private static final QName FINAL_WSDLI = new QName("http://www.w3.org/ns/wsdl-instance", "wsdlLocation", "wsdli");
private String targetNamespace;
private String wsdlURL;
@@ -55,29 +61,35 @@
/**
* Convenience method to convert an object of this type to an <code>OMAttribute</code>
+ * <p>
+ * <... xmlns:wsdli="http://www.w3.org/ns/wsdl-instance" wsdli:wsdlLocation="targetNamespace wsdlURL" ...>
+ * </p>
* @param factory <code>OMFactory</code> to use when generating <code>OMElement</code>s
*
* @return an <code>OMAttribute</code> that can be added to an <code>EndpointReference</code>
*/
public OMAttribute toOM(OMFactory factory) {
String value = new StringBuffer(targetNamespace).append(" ").append(wsdlURL).toString();
- OMNamespace wsdliNs = factory.createOMNamespace(WSDLI.getNamespaceURI(), WSDLI.getPrefix());
- OMAttribute omAttribute = factory.createOMAttribute(WSDLI.getLocalPart(), wsdliNs, value);
-
+ OMNamespace wsdliNs = factory.createOMNamespace(FINAL_WSDLI.getNamespaceURI(), FINAL_WSDLI.getPrefix());
+ OMAttribute omAttribute = factory.createOMAttribute(FINAL_WSDLI.getLocalPart(), wsdliNs, value);
+
return omAttribute;
}
/**
- * Convenience method for converting an OMAttribute to an instance of this type.
+ * Convenience method for converting an OMAttribute to an instance of either of these types.
* <p>
* <... xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance" wsdli:wsdlLocation="targetNamespace wsdlURL" ...>
* </p>
+ * <p>
+ * <... xmlns:wsdli="http://www.w3.org/ns/wsdl-instance" wsdli:wsdlLocation="targetNamespace wsdlURL" ...>
+ * </p>
* @param omAttribute the <code>OMAttribute</code> that holds the wsdl location.
* @throws AxisFault
*/
public void fromOM(OMAttribute omAttribute) throws AxisFault {
QName qname = omAttribute.getQName();
- if (WSDLI.equals(qname)) {
+ if (WSDLI.equals(qname) || FINAL_WSDLI.equals(qname)) {
String value = omAttribute.getAttributeValue().trim();
String[] values = value.split("\\s", 2);
@@ -88,6 +100,10 @@
targetNamespace = values[0];
wsdlURL = values[1];
+
+ if (log.isDebugEnabled()) {
+ log.debug("fromOM: Extracted WSDLLocation targetNamespace = " + targetNamespace + " and wsdlURL = " + wsdlURL + " from an OMAttribute with QName = " + qname);
+ }
}
else {
throw new AxisFault("Unrecognized element.");
@@ -108,8 +124,12 @@
boolean result = false;
QName qname = omAttribute.getQName();
- if (WSDLI.equals(qname))
+ if (WSDLI.equals(qname) || FINAL_WSDLI.equals(qname))
result = true;
+
+ if (log.isDebugEnabled()) {
+ log.debug("isWSDLLocationAttribute: OMAttribute QName = " + qname + ", result = " + result);
+ }
return result;
}
Modified: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/addressing/EndpointReferenceHelperTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/addressing/EndpointReferenceHelperTest.java?rev=916333&r1=916332&r2=916333&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/addressing/EndpointReferenceHelperTest.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/addressing/EndpointReferenceHelperTest.java Thu Feb 25 16:04:00 2010
@@ -25,8 +25,10 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.addressing.metadata.WSDLLocation;
import javax.xml.namespace.QName;
+
import java.util.ArrayList;
import java.util.Map;
@@ -247,4 +249,82 @@
//pass
}
}
+
+ public void testSetAndGetWSDLLocationMetadataForFinalSpecEPR() throws Exception {
+ String address = "http://ws.apache.org/axis2";
+ String targetNamespace = "targetNamespace";
+ String location = "wsdlLocation";
+
+ EndpointReference epr = new EndpointReference(address);
+
+ OMFactory omf = OMAbstractFactory.getOMFactory();
+
+ // Uses final WSDLI namespace on wsdlLocation attribute
+ EndpointReferenceHelper.setWSDLLocationMetadata(omf, epr, AddressingConstants.Final.WSA_NAMESPACE, new WSDLLocation(targetNamespace, location));
+
+ WSDLLocation wsdlLocation = EndpointReferenceHelper.getWSDLLocationMetadata(epr, AddressingConstants.Final.WSA_NAMESPACE);
+ assertEquals(wsdlLocation.getTargetNamespace(), targetNamespace);
+ assertEquals(wsdlLocation.getLocation(), location);
+ }
+
+ public void testSetAndGetWSDLLocationMetadataForSubmissionSpecEPR() throws Exception {
+ String address = "http://ws.apache.org/axis2";
+ String targetNamespace = "targetNamespace";
+ String location = "wsdlLocation";
+
+ EndpointReference epr = new EndpointReference(address);
+
+ OMFactory omf = OMAbstractFactory.getOMFactory();
+
+ // Uses final WSDLI namespace on wsdlLocation attribute
+ EndpointReferenceHelper.setWSDLLocationMetadata(omf, epr, AddressingConstants.Submission.WSA_NAMESPACE, new WSDLLocation(targetNamespace, location));
+
+ WSDLLocation wsdlLocation = EndpointReferenceHelper.getWSDLLocationMetadata(epr, AddressingConstants.Submission.WSA_NAMESPACE);
+ assertEquals(wsdlLocation.getTargetNamespace(), targetNamespace);
+ assertEquals(wsdlLocation.getLocation(), location);
+ }
+
+ public void testGetWSDLLocationMetadataForFinalSpecEPRWithOldWsdliNamespace() throws Exception {
+ String address = "http://ws.apache.org/axis2";
+ String targetNamespace = "targetNamespace";
+ String location = "wsdlLocation";
+
+ EndpointReference epr = new EndpointReference(address);
+
+ // Uses old candidate spec WSDLI namespace on wsdlLocation attribute
+ OMFactory omf = OMAbstractFactory.getOMFactory();
+ String value = new StringBuffer(targetNamespace).append(" ").append(location).toString();
+ QName OLD_WSDLI = new QName("http://www.w3.org/2006/01/wsdl-instance", "wsdlLocation", "wsdli");
+ OMNamespace wsdliNs = omf.createOMNamespace(OLD_WSDLI.getNamespaceURI(), OLD_WSDLI.getPrefix());
+ OMAttribute attribute = omf.createOMAttribute(OLD_WSDLI.getLocalPart(), wsdliNs, value);
+
+ ArrayList list = new ArrayList();
+ list.add(attribute);
+ epr.setMetadataAttributes(list);
+
+ WSDLLocation wsdlLocation = EndpointReferenceHelper.getWSDLLocationMetadata(epr, AddressingConstants.Final.WSA_NAMESPACE);
+ assertEquals(wsdlLocation.getTargetNamespace(), targetNamespace);
+ assertEquals(wsdlLocation.getLocation(), location);
+ }
+
+ public void testGetWSDLLocationMetadataForSubmissionSpecEPRWithOldWsdliNamespace() throws Exception {
+ String address = "http://ws.apache.org/axis2";
+ String targetNamespace = "targetNamespace";
+ String location = "wsdlLocation";
+
+ EndpointReference epr = new EndpointReference(address);
+
+ // Uses old candidate spec WSDLI namespace on wsdlLocation attribute
+ OMFactory omf = OMAbstractFactory.getOMFactory();
+ String value = new StringBuffer(targetNamespace).append(" ").append(location).toString();
+ QName OLD_WSDLI = new QName("http://www.w3.org/2006/01/wsdl-instance", "wsdlLocation", "wsdli");
+ OMNamespace wsdliNs = omf.createOMNamespace(OLD_WSDLI.getNamespaceURI(), OLD_WSDLI.getPrefix());
+ OMAttribute attribute = omf.createOMAttribute(OLD_WSDLI.getLocalPart(), wsdliNs, value);
+
+ epr.addAttribute(attribute);
+
+ WSDLLocation wsdlLocation = EndpointReferenceHelper.getWSDLLocationMetadata(epr, AddressingConstants.Submission.WSA_NAMESPACE);
+ assertEquals(wsdlLocation.getTargetNamespace(), targetNamespace);
+ assertEquals(wsdlLocation.getLocation(), location);
+ }
}