You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by pr...@apache.org on 2007/06/04 09:40:58 UTC
svn commit: r544082 - in /webservices/axis2/branches/java/jaxws21/modules:
jaxws-api/src/javax/xml/ws/ jaxws-api/src/javax/xml/ws/wsaddressing/
jaxws/src/org/apache/axis2/jaxws/
jaxws/src/org/apache/axis2/jaxws/addressing/ jaxws/src/org/apache/axis2/ja...
Author: pradine
Date: Mon Jun 4 00:40:56 2007
New Revision: 544082
URL: http://svn.apache.org/viewvc?view=rev&rev=544082
Log:
Add a new test, plus some refactoring to make it work.
Added:
webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/addressing/
webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/addressing/util/
webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/addressing/util/EndpointReferenceConverterTests.java
Modified:
webservices/axis2/branches/java/jaxws21/modules/jaxws-api/src/javax/xml/ws/EndpointReference.java
webservices/axis2/branches/java/jaxws21/modules/jaxws-api/src/javax/xml/ws/wsaddressing/W3CEndpointReference.java
webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/SubmissionEndpointReference.java
webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceConverter.java
webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java
webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/EndpointReferenceHelper.java
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws-api/src/javax/xml/ws/EndpointReference.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws-api/src/javax/xml/ws/EndpointReference.java?view=diff&rev=544082&r1=544081&r2=544082
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws-api/src/javax/xml/ws/EndpointReference.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws-api/src/javax/xml/ws/EndpointReference.java Mon Jun 4 00:40:56 2007
@@ -18,8 +18,11 @@
*/
package javax.xml.ws;
+import java.io.ByteArrayOutputStream;
+
import javax.xml.transform.Result;
import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamResult;
import javax.xml.ws.spi.Provider;
public abstract class EndpointReference {
@@ -34,5 +37,13 @@
public <T> T getPort(Class<T> serviceEndpointInterface, WebServiceFeature... features) {
return Provider.provider().getPort(this, serviceEndpointInterface, features);
+ }
+
+ @Override
+ public String toString() {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ writeTo(new StreamResult(baos));
+
+ return baos.toString();
}
}
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws-api/src/javax/xml/ws/wsaddressing/W3CEndpointReference.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws-api/src/javax/xml/ws/wsaddressing/W3CEndpointReference.java?view=diff&rev=544082&r1=544081&r2=544082
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws-api/src/javax/xml/ws/wsaddressing/W3CEndpointReference.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws-api/src/javax/xml/ws/wsaddressing/W3CEndpointReference.java Mon Jun 4 00:40:56 2007
@@ -23,6 +23,7 @@
import java.util.Map;
import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
@@ -72,9 +73,11 @@
})
public final class W3CEndpointReference extends EndpointReference {
@XmlTransient
- private static volatile JAXBContext jaxbContext;
+ protected static volatile JAXBContext jaxbContext;
@XmlTransient
protected static final String NS = "http://www.w3.org/2005/08/addressing";
+ @XmlTransient
+ protected static final QName NAME = new QName(NS, "EndpointReference", "wsa");
@XmlElement(name = "Address", required = true)
protected AttributedURIType address;
@@ -96,8 +99,9 @@
try {
JAXBContext jaxbContext = getJAXBContext();
Unmarshaller um = jaxbContext.createUnmarshaller();
- W3CEndpointReference w3cEPR =
- (W3CEndpointReference) um.unmarshal(eprInfoset);
+ JAXBElement<W3CEndpointReference> element =
+ um.unmarshal(eprInfoset, W3CEndpointReference.class);
+ W3CEndpointReference w3cEPR = element.getValue();
address = w3cEPR.address;
referenceParameters = w3cEPR.referenceParameters;
@@ -120,14 +124,17 @@
try {
JAXBContext jaxbContext = getJAXBContext();
Marshaller m = jaxbContext.createMarshaller();
- m.marshal(this, result);
+ m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
+ JAXBElement<W3CEndpointReference> element =
+ new JAXBElement<W3CEndpointReference>(NAME, W3CEndpointReference.class, this);
+ m.marshal(element, result);
}
catch (Exception e) {
//TODO NLS enable
throw new WebServiceException("writeTo failure.", e);
}
}
-
+
private JAXBContext getJAXBContext() throws JAXBException {
//This is an implementation of double-checked locking.
//It works because jaxbContext is volatile.
@@ -168,6 +175,9 @@
protected String value;
@XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
+
+ public AttributedURIType() {
+ }
}
/**
@@ -199,6 +209,9 @@
protected List<Object> any;
@XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
+
+ public ReferenceParametersType() {
+ }
}
/**
@@ -230,5 +243,8 @@
protected List<Object> any;
@XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
+
+ public MetadataType() {
+ }
}
}
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java?view=diff&rev=544082&r1=544081&r2=544082
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java Mon Jun 4 00:40:56 2007
@@ -23,7 +23,6 @@
import org.apache.axis2.addressing.AddressingConstants.Submission;
import org.apache.axis2.addressing.metadata.ServiceName;
import org.apache.axis2.addressing.metadata.WSDLLocation;
-import org.apache.axis2.jaxws.addressing.SubmissionAddressingFeature;
import org.apache.axis2.jaxws.addressing.SubmissionEndpointReference;
import org.apache.axis2.jaxws.addressing.util.EndpointReferenceConverter;
import org.apache.axis2.jaxws.binding.BindingUtils;
@@ -44,7 +43,6 @@
import javax.xml.ws.EndpointReference;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.handler.HandlerResolver;
-import javax.xml.ws.soap.AddressingFeature;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import java.net.URL;
@@ -62,8 +60,10 @@
protected WebServiceFeatureValidator validator;
+ //TODO: Is this the best place for this code?
protected org.apache.axis2.addressing.EndpointReference epr;
+ //TODO: Is this the best place for this code?
protected String addressingNamespace;
private Binding binding; // force subclasses to use the lazy getter
@@ -91,16 +91,7 @@
// Setting standard property defaults for the request context
requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.FALSE);
-
- WebServiceFeature addressingFeature = validator.get(AddressingFeature.ID);
- WebServiceFeature submissionAddressingFeature = validator.get(SubmissionAddressingFeature.ID);
- String bindingID = endpointDesc.getClientBindingID();
-
- if (BindingUtils.isSOAPBinding(bindingID) &&
- (addressingFeature.isEnabled() || submissionAddressingFeature.isEnabled()))
- requestContext.put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
- else
- requestContext.put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.FALSE);
+ requestContext.put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
// Set the endpoint address
String endpointAddress = (epr != null ) ? epr.getAddress() : endpointDesc.getEndpointAddress();
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/SubmissionEndpointReference.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/SubmissionEndpointReference.java?view=diff&rev=544082&r1=544081&r2=544082
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/SubmissionEndpointReference.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/SubmissionEndpointReference.java Mon Jun 4 00:40:56 2007
@@ -23,6 +23,7 @@
import java.util.Map;
import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
@@ -79,9 +80,11 @@
})
public class SubmissionEndpointReference extends EndpointReference {
@XmlTransient
- private static volatile JAXBContext jaxbContext;
+ protected static volatile JAXBContext jaxbContext;
@XmlTransient
protected static final String NS = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
+ @XmlTransient
+ protected static final QName NAME = new QName(NS, "EndpointReference", "wsa");
@XmlElement(name = "Address", required = true)
@@ -108,8 +111,9 @@
try {
JAXBContext jaxbContext = getJAXBContext();
Unmarshaller um = jaxbContext.createUnmarshaller();
- SubmissionEndpointReference subEPR =
- (SubmissionEndpointReference) um.unmarshal(eprInfoset);
+ JAXBElement<SubmissionEndpointReference> element =
+ um.unmarshal(eprInfoset, SubmissionEndpointReference.class);
+ SubmissionEndpointReference subEPR = element.getValue();
address = subEPR.address;
referenceParameters = subEPR.referenceParameters;
@@ -134,7 +138,10 @@
try {
JAXBContext jaxbContext = getJAXBContext();
Marshaller m = jaxbContext.createMarshaller();
- m.marshal(this, result);
+ m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
+ JAXBElement<SubmissionEndpointReference> element =
+ new JAXBElement<SubmissionEndpointReference>(NAME, SubmissionEndpointReference.class, this);
+ m.marshal(element, result);
}
catch (Exception e) {
//TODO NLS enable
@@ -175,13 +182,16 @@
@XmlType(name = "AttributedURI", propOrder = {
"value"
})
- private class AttributedURI {
+ private static class AttributedURI {
@XmlValue
@XmlSchemaType(name = "anyURI")
protected String value;
@XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
+
+ public AttributedURI() {
+ }
}
/**
@@ -207,10 +217,13 @@
@XmlType(name = "ReferenceParametersType", propOrder = {
"any"
})
- private class ReferenceParametersType {
+ private static class ReferenceParametersType {
@XmlAnyElement(lax = true)
protected List<Object> any;
+
+ public ReferenceParametersType() {
+ }
}
/**
@@ -236,10 +249,13 @@
@XmlType(name = "ReferencePropertiesType", propOrder = {
"any"
})
- private class ReferencePropertiesType {
+ private static class ReferencePropertiesType {
@XmlAnyElement(lax = true)
protected List<Object> any;
+
+ public ReferencePropertiesType() {
+ }
}
/**
@@ -263,7 +279,7 @@
@XmlType(name = "ServiceNameType", propOrder = {
"value"
})
- private class ServiceNameType {
+ private static class ServiceNameType {
@XmlValue
protected QName value;
@@ -273,6 +289,9 @@
protected String portName;
@XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
+
+ public ServiceNameType() {
+ }
}
/**
@@ -295,11 +314,14 @@
@XmlType(name = "AttributedQName", propOrder = {
"value"
})
- private class AttributedQName {
+ private static class AttributedQName {
@XmlValue
protected QName value;
@XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
+
+ public AttributedQName() {
+ }
}
}
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceConverter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceConverter.java?view=diff&rev=544082&r1=544081&r2=544082
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceConverter.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceConverter.java Mon Jun 4 00:40:56 2007
@@ -20,6 +20,9 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.security.PrivilegedExceptionAction;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
@@ -28,23 +31,21 @@
import javax.xml.transform.stream.StreamResult;
import javax.xml.ws.EndpointReference;
+import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.AddressingConstants.Final;
import org.apache.axis2.addressing.AddressingConstants.Submission;
import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.java.security.AccessController;
import org.apache.axis2.jaxws.addressing.SubmissionEndpointReference;
-import org.apache.axis2.jaxws.spi.Provider;
import org.apache.axis2.util.XMLUtils;
-import org.w3c.dom.Node;
+import org.w3c.dom.Element;
public final class EndpointReferenceConverter {
- private static OMFactory omFactory = DOOMAbstractFactory.getOMFactory();
- private static QName eprType = new QName("namespace", "epr", "prefix");
- private static Provider provider = new Provider();
+ private static OMFactory omFactory = OMAbstractFactory.getOMFactory();
private EndpointReferenceConverter() {
}
@@ -59,15 +60,25 @@
* @return
* @throws AxisFault
*/
- public static <T extends EndpointReference> T convertFromAxis2(org.apache.axis2.addressing.EndpointReference axis2EPR, Class<T> clazz)
- throws AxisFault {
+ public static <T extends EndpointReference> T convertFromAxis2(org.apache.axis2.addressing.EndpointReference axis2EPR, final Class<T> clazz)
+ throws AxisFault, NoSuchMethodException, InstantiationException, InvocationTargetException, IllegalAccessException, Exception {
String addressingNamespace =
SubmissionEndpointReference.class.isAssignableFrom(clazz) ? Submission.WSA_NAMESPACE : Final.WSA_NAMESPACE;
- OMElement om = EndpointReferenceHelper.toOM(omFactory, axis2EPR, eprType, addressingNamespace);
- Source source = new DOMSource((Node) om);
- EndpointReference jaxwsEPR = provider.readEndpointReference(source);
+ QName qname = new QName(addressingNamespace, "EndpointReference", "wsa");
+ OMElement omElement =
+ EndpointReferenceHelper.toOM(omFactory, axis2EPR, qname, addressingNamespace);
+ Element eprElement = XMLUtils.toDOM(omElement);
+ Source eprInfoset = new DOMSource(eprElement);
- return clazz.cast(jaxwsEPR);
+ Constructor constructor =
+ (Constructor) AccessController.doPrivileged(
+ new PrivilegedExceptionAction() {
+ public Object run() throws NoSuchMethodException {
+ return clazz.getConstructor(Source.class);
+ }
+ });
+
+ return clazz.cast(constructor.newInstance(eprInfoset));
}
/**
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java?view=diff&rev=544082&r1=544081&r2=544082
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java Mon Jun 4 00:40:56 2007
@@ -18,11 +18,11 @@
*/
package org.apache.axis2.jaxws.spi;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
import javax.xml.ws.Endpoint;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.Service;
@@ -45,11 +45,12 @@
import org.apache.axis2.util.XMLUtils;
import org.w3c.dom.Element;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.net.URL;
import java.util.List;
public class Provider extends javax.xml.ws.spi.Provider {
- private static volatile JAXBContext jaxbContext;
@Override
public Endpoint createAndPublishEndpoint(String s, Object obj) {
@@ -160,31 +161,31 @@
@Override
public EndpointReference readEndpointReference(Source eprInfoset) {
- EndpointReference epr = null;
+ EndpointReference jaxwsEPR = null;
try {
- JAXBContext jaxbContext = getJAXBContext();
- Unmarshaller um = jaxbContext.createUnmarshaller();
- epr = (EndpointReference) um.unmarshal(eprInfoset);
+ Transformer xformer = TransformerFactory.newInstance().newTransformer();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ xformer.transform(eprInfoset, new StreamResult(baos));
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ OMElement eprElement = (OMElement) XMLUtils.toOM(bais);
+ org.apache.axis2.addressing.EndpointReference axis2EPR =
+ new org.apache.axis2.addressing.EndpointReference("");
+ String addressingNamespace = EndpointReferenceHelper.fromOM(axis2EPR, eprElement);
+ Class<? extends EndpointReference> clazz = null;
+
+ if (Submission.WSA_NAMESPACE.equals(addressingNamespace))
+ clazz = SubmissionEndpointReference.class;
+ else
+ clazz = W3CEndpointReference.class;
+
+ jaxwsEPR = EndpointReferenceConverter.convertFromAxis2(axis2EPR, clazz);
}
catch (Exception e) {
//TODO NLS enable.
throw ExceptionFactory.makeWebServiceException("A problem occured during the creation of an endpoint reference. See the nested exception for details.", e);
}
- return epr;
- }
-
- private JAXBContext getJAXBContext() throws JAXBException {
- //This is an implementation of double-checked locking.
- //It works because jaxbContext is volatile.
- if (jaxbContext == null) {
- synchronized (javax.xml.ws.spi.Provider.class) {
- if (jaxbContext == null)
- jaxbContext = JAXBContext.newInstance(W3CEndpointReference.class, SubmissionEndpointReference.class);
- }
- }
-
- return jaxbContext;
+ return jaxwsEPR;
}
}
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java?view=diff&rev=544082&r1=544081&r2=544082
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java Mon Jun 4 00:40:56 2007
@@ -42,6 +42,7 @@
import org.apache.axis2.jaxws.feature.util.WebServiceFeatureConfigUtil;
import org.apache.axis2.jaxws.feature.util.WebServiceFeatureConfigurator;
import org.apache.axis2.jaxws.i18n.Messages;
+import org.apache.axis2.jaxws.spi.migrator.ApplicationContextMigrator;
import org.apache.axis2.jaxws.spi.migrator.ApplicationContextMigratorUtil;
import org.apache.axis2.jaxws.util.WSDLWrapper;
import org.apache.commons.logging.Log;
@@ -74,6 +75,10 @@
* javax.xml.ws.Service} API. This is the plug point for the client implementation.
*/
public class ServiceDelegate extends javax.xml.ws.spi.ServiceDelegate {
+ private static final WebServiceFeatureConfigurator[] CONFIGURATORS = {
+ new W3CAndSubmissionAddressingConfigurator(), new MTOMConfigurator(), new RespectBindingConfigurator()};
+ private static final ApplicationContextMigrator[] MIGRATORS = {new PropertyMigrator()};
+
private static final Log log = LogFactory.getLog(ServiceDelegate.class);
private Executor executor;
@@ -101,17 +106,17 @@
}
}
- ConfigurationContext context= serviceDescription.getAxisConfigContext();
+ //TODO: Is this the best place for this code?
+ ConfigurationContext context = serviceDescription.getAxisConfigContext();
// Register the necessary ApplicationContextMigrators
- ApplicationContextMigratorUtil.addApplicationContextMigrator(context,
- Constants.APPLICATION_CONTEXT_MIGRATOR_LIST_ID, new PropertyMigrator());
+ for (ApplicationContextMigrator migrator : MIGRATORS) {
+ ApplicationContextMigratorUtil.addApplicationContextMigrator(context,
+ Constants.APPLICATION_CONTEXT_MIGRATOR_LIST_ID, migrator);
+ }
// Register our WebServiceFeature configurators.
- WebServiceFeatureConfigurator[] configurators = {new W3CAndSubmissionAddressingConfigurator(),
- new MTOMConfigurator(), new RespectBindingConfigurator()};
-
- for (WebServiceFeatureConfigurator configurator : configurators) {
+ for (WebServiceFeatureConfigurator configurator : CONFIGURATORS) {
WebServiceFeatureConfigUtil.addWebServiceFeatureConfigurator(context,
Constants.WEB_SERVICE_FEATURE_CONFIGURATOR_LIST_ID, configurator);
}
Added: webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/addressing/util/EndpointReferenceConverterTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/addressing/util/EndpointReferenceConverterTests.java?view=auto&rev=544082
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/addressing/util/EndpointReferenceConverterTests.java (added)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/addressing/util/EndpointReferenceConverterTests.java Mon Jun 4 00:40:56 2007
@@ -0,0 +1,194 @@
+/*
+ * 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.jaxws.addressing.util;
+
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.addressing.AddressingConstants.Final;
+import org.apache.axis2.addressing.AddressingConstants.Submission;
+import org.apache.axis2.jaxws.addressing.SubmissionEndpointReference;
+import org.apache.axis2.jaxws.addressing.util.EndpointReferenceConverter;
+import org.custommonkey.xmlunit.XMLTestCase;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+/**
+ * This class uses the JAX-WS Dispatch API to test sending and receiving
+ * messages using SOAP 1.2.
+ */
+public class EndpointReferenceConverterTests extends XMLTestCase {
+ private static final OMFactory OMF = OMAbstractFactory.getOMFactory();
+ private static final QName ELEMENT200508 =
+ new QName(Final.WSA_NAMESPACE, "EndpointReference", "wsa");
+ private static final QName ELEMENT200408 =
+ new QName(Submission.WSA_NAMESPACE, "EndpointReference", "wsa");
+
+ private static final String EPR200508 =
+ "<wsa:EndpointReference xmlns:axis2=\"http://ws.apache.org/namespaces/axis2\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\" axis2:AttrExt=\"123456789\">"+
+ "<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>"+
+ "<wsa:ReferenceParameters xmlns:fabrikam=\"http://example.com/fabrikam\">"+
+ "<fabrikam:CustomerKey>123456789</fabrikam:CustomerKey>"+
+ "<fabrikam:ShoppingCart>ABCDEFG</fabrikam:ShoppingCart>"+
+ "</wsa:ReferenceParameters>"+
+ "<wsa:Metadata>"+
+ "<axis2:MetaExt axis2:AttrExt=\"123456789\">123456789</axis2:MetaExt>"+
+ "</wsa:Metadata>"+
+ "<axis2:EPRExt axis2:AttrExt=\"123456789\">123456789</axis2:EPRExt>"+
+ "</wsa:EndpointReference>";
+
+ private static final String EPR200408 =
+ "<wsa:EndpointReference xmlns:axis2=\"http://ws.apache.org/namespaces/axis2\" xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" axis2:AttrExt=\"123456789\">"+
+ "<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/anonymous</wsa:Address>"+
+ "<wsa:ReferenceParameters xmlns:fabrikam=\"http://example.com/fabrikam\">"+
+ "<fabrikam:CustomerKey>123456789</fabrikam:CustomerKey>"+
+ "<fabrikam:ShoppingCart>ABCDEFG</fabrikam:ShoppingCart>"+
+ "</wsa:ReferenceParameters>"+
+ "<wsa:PortType>axis2:Jane</wsa:PortType>"+
+ "<wsa:ServiceName PortName=\"Fred\">axis2:John</wsa:ServiceName>"+
+ "<axis2:EPRExt axis2:AttrExt=\"123456789\">123456789</axis2:EPRExt>"+
+ "</wsa:EndpointReference>";
+
+ public EndpointReferenceConverterTests(String name) {
+ super(name);
+ }
+
+ public void test200508ConversionStartingFromAxis2() throws Exception {
+ XMLStreamReader parser =
+ XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(EPR200508));
+ StAXOMBuilder builder = new StAXOMBuilder(parser);
+ OMElement omElement = builder.getDocumentElement();
+
+ org.apache.axis2.addressing.EndpointReference axis2EPR =
+ EndpointReferenceHelper.fromOM(omElement);
+ W3CEndpointReference jaxwsEPR =
+ EndpointReferenceConverter.convertFromAxis2(axis2EPR, W3CEndpointReference.class);
+ assertXMLEqual(EPR200508, jaxwsEPR.toString());
+
+ org.apache.axis2.addressing.EndpointReference axis2Result =
+ EndpointReferenceConverter.convertToAxis2(jaxwsEPR);
+ OMElement eprElement =
+ EndpointReferenceHelper.toOM(OMF, axis2Result, ELEMENT200508, Final.WSA_NAMESPACE);
+ assertXMLEqual(EPR200508, eprElement.toString());
+ }
+
+ public void test200508ConversionStartingFromJAXWS() throws Exception {
+ DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
+ dbfac.setNamespaceAware(true);
+ DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
+ Document jaxwsDoc = docBuilder.parse(new InputSource(new StringReader(EPR200508)));
+ Source source = new DOMSource(jaxwsDoc);
+
+ W3CEndpointReference jaxwsEPR = new W3CEndpointReference(source);
+ org.apache.axis2.addressing.EndpointReference axis2EPR =
+ EndpointReferenceConverter.convertToAxis2(jaxwsEPR);
+ OMElement eprElement =
+ EndpointReferenceHelper.toOM(OMF, axis2EPR, ELEMENT200508, Final.WSA_NAMESPACE);
+ assertXMLEqual(EPR200508, eprElement.toString());
+
+ W3CEndpointReference jaxwsResult =
+ EndpointReferenceConverter.convertFromAxis2(axis2EPR, W3CEndpointReference.class);
+ assertXMLEqual(EPR200508, jaxwsResult.toString());
+ }
+
+ public void test200408ConversionStartingFromAxis2() throws Exception {
+ XMLStreamReader parser =
+ XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(EPR200408));
+ StAXOMBuilder builder = new StAXOMBuilder(parser);
+ OMElement omElement = builder.getDocumentElement();
+
+ org.apache.axis2.addressing.EndpointReference axis2EPR =
+ EndpointReferenceHelper.fromOM(omElement);
+ SubmissionEndpointReference jaxwsEPR =
+ EndpointReferenceConverter.convertFromAxis2(axis2EPR, SubmissionEndpointReference.class);
+ assertXMLEqual(EPR200408, jaxwsEPR.toString());
+
+ org.apache.axis2.addressing.EndpointReference axis2Result =
+ EndpointReferenceConverter.convertToAxis2(jaxwsEPR);
+ OMElement eprElement =
+ EndpointReferenceHelper.toOM(OMF, axis2Result, ELEMENT200408, Submission.WSA_NAMESPACE);
+ assertXMLEqual(EPR200408, eprElement.toString());
+ }
+
+ public void test200408ConversionStartingFromJAXWS() throws Exception {
+ DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
+ dbfac.setNamespaceAware(true);
+ DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
+ Document jaxwsDoc = docBuilder.parse(new InputSource(new StringReader(EPR200408)));
+ Source source = new DOMSource(jaxwsDoc);
+
+ SubmissionEndpointReference jaxwsEPR = new SubmissionEndpointReference(source);
+ org.apache.axis2.addressing.EndpointReference axis2EPR =
+ EndpointReferenceConverter.convertToAxis2(jaxwsEPR);
+ OMElement eprElement =
+ EndpointReferenceHelper.toOM(OMF, axis2EPR, ELEMENT200408, Submission.WSA_NAMESPACE);
+ assertXMLEqual(EPR200408, eprElement.toString());
+
+ SubmissionEndpointReference jaxwsResult =
+ EndpointReferenceConverter.convertFromAxis2(axis2EPR, SubmissionEndpointReference.class);
+ assertXMLEqual(EPR200408, jaxwsResult.toString());
+ }
+
+ public void testFailures() throws Exception {
+ try {
+ EndpointReferenceConverter.convertFromAxis2(null, W3CEndpointReference.class);
+ fail("Expected a failure.");
+ }
+ catch (Exception e) {
+ //pass
+ }
+
+ try {
+ EndpointReferenceConverter.convertFromAxis2(null, SubmissionEndpointReference.class);
+ fail("Expected a failure.");
+ }
+ catch (Exception e) {
+ //pass
+ }
+
+ try {
+ EndpointReferenceConverter.convertFromAxis2(null, null);
+ fail("Expected a failure.");
+ }
+ catch (Exception e) {
+ //pass
+ }
+
+ try {
+ EndpointReferenceConverter.convertToAxis2(null);
+ fail("Expected a failure.");
+ }
+ catch (Exception e) {
+ //pass
+ }
+ }
+}
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?view=diff&rev=544082&r1=544081&r2=544082
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java Mon Jun 4 00:40:56 2007
@@ -21,6 +21,7 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.apache.axis2.jaxws.addressing.util.EndpointReferenceConverterTests;
import org.apache.axis2.jaxws.anytype.tests.AnyTypeTests;
import org.apache.axis2.jaxws.attachments.MTOMSerializationTests;
import org.apache.axis2.jaxws.client.ClientConfigTests;
@@ -125,6 +126,9 @@
suite.addTestSuite(SOAP12Tests.class);
suite.addTestSuite(MTOMSerializationTests.class);
suite.addTestSuite(BindingToProtocolTests.class);
+
+ // ------ Addressing Tests ------
+ suite.addTestSuite(EndpointReferenceConverterTests.class);
// ------ Metadata Tests ------
suite.addTestSuite(WSDLTests.class);
Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/EndpointReferenceHelper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/EndpointReferenceHelper.java?view=diff&rev=544082&r1=544081&r2=544082
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/EndpointReferenceHelper.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/EndpointReferenceHelper.java Mon Jun 4 00:40:56 2007
@@ -56,49 +56,60 @@
/**
* Populates an endpoint reference based on the <code>OMElement</code> and
- * WS-Addressing namespace that is passed in. If the string passed in is not
- * recognized as a valid WS-Addressing namespace then this method behaves as
- * if http://www.w3.org/2005/08/addressing has been passed in.
+ * WS-Addressing namespace that is passed in.
*
* @param epr an endpoint reference instance to hold the info.
* @param eprOMElement an element of endpoint reference type
* @param addressingNamespace the namespace of the WS-Addressing spec to comply with.
- * @throws AxisFault if unable to locate an address element
+ * @throws AxisFault if unable to locate an address element, or if the specified namespace
+ * is different to the actual namespace.
* @see #fromOM(OMElement)
*/
public static void fromOM(EndpointReference epr, OMElement eprOMElement,
String addressingNamespace) throws AxisFault {
+ String namespace = fromOM(epr, eprOMElement);
+
+ if (!namespace.equals(addressingNamespace))
+ throw new AxisFault("The endpoint reference does not match the specified namespace.");
+ }
+
+ /**
+ * Populates an endpoint reference based on the <code>OMElement</code>. Returns the
+ * WS-Addressing namespace that the endpoint reference is in compliance with.
+ *
+ * @param epr an endpoint reference instance to hold the info.
+ * @param eprOMElement an element of endpoint reference type
+ * @return a string representing the namespace of the endpoint reference.
+ * @throws AxisFault if unable to locate an address element.
+ */
+ public static String fromOM(EndpointReference epr, OMElement eprOMElement)
+ throws AxisFault {
boolean isFinalAddressingNamespace = false;
Map map = null;
//First pass, identify the addressing namespace.
- if (AddressingConstants.Submission.WSA_NAMESPACE.equals(addressingNamespace)) {
- OMElement address = eprOMElement.getFirstChildWithName(
- (QName) submissionQNames.get(AddressingConstants.EPR_ADDRESS));
+ OMElement address = eprOMElement
+ .getFirstChildWithName((QName) finalQNames.get(AddressingConstants.EPR_ADDRESS));
- if (address != null) {
- map = submissionQNames;
- isFinalAddressingNamespace = false;
+ if (address != null) {
+ map = finalQNames;
+ isFinalAddressingNamespace = true;
- if (log.isDebugEnabled()) {
- log.debug("fromOM: Found address element for namespace, " +
- AddressingConstants.Submission.WSA_NAMESPACE);
- }
- } else {
- throw new AxisFault(
- "Unable to locate an address element for the endpoint reference type.");
+ if (log.isDebugEnabled()) {
+ log.debug("fromOM: Found address element for namespace, " +
+ AddressingConstants.Final.WSA_NAMESPACE);
}
} else {
- OMElement address = eprOMElement.getFirstChildWithName(
- (QName) finalQNames.get(AddressingConstants.EPR_ADDRESS));
+ address = eprOMElement.getFirstChildWithName(
+ (QName) submissionQNames.get(AddressingConstants.EPR_ADDRESS));
if (address != null) {
- map = finalQNames;
- isFinalAddressingNamespace = true;
+ map = submissionQNames;
+ isFinalAddressingNamespace = false;
if (log.isDebugEnabled()) {
log.debug("fromOM: Found address element for namespace, " +
- AddressingConstants.Final.WSA_NAMESPACE);
+ AddressingConstants.Submission.WSA_NAMESPACE);
}
} else {
throw new AxisFault(
@@ -108,6 +119,8 @@
//Second pass, identify the properties.
fromOM(epr, eprOMElement, map, isFinalAddressingNamespace);
+
+ return ((QName) map.get(AddressingConstants.EPR_ADDRESS)).getNamespaceURI();
}
/**
@@ -119,6 +132,7 @@
*
* @param eprString string from the element of endpoint reference type
* @throws AxisFault if unable to locate an address element
+ * @deprecated use {@link #fromString(String)} instead.
*/
public static EndpointReference fromOM(String eprString) throws AxisFault {
try {
@@ -130,6 +144,25 @@
}
/**
+ * Populates an endpoint reference based on the <code>String</code> that is
+ * passed in. If the http://schemas.xmlsoap.org/ws/2004/08/addressing namespace
+ * is in effect then any reference properties will be saved as reference parameters.
+ * Regardless of the addressing namespace in effect, any elements present in the
+ * <code>String</code> that are not recognised are saved as extensibility elements.
+ *
+ * @param eprString string from the element of endpoint reference type
+ * @throws AxisFault if unable to locate an address element
+ */
+ public static EndpointReference fromString(String eprString) throws AxisFault {
+ try {
+ return fromOM(new StAXOMBuilder(
+ new ByteArrayInputStream(eprString.getBytes())).getDocumentElement());
+ } catch (XMLStreamException e) {
+ throw AxisFault.makeFault(e);
+ }
+ }
+
+ /**
* Populates an endpoint reference based on the <code>OMElement</code> that is
* passed in. If the http://schemas.xmlsoap.org/ws/2004/08/addressing namespace
* is in effect then any reference properties will be saved as reference parameters.
@@ -141,41 +174,7 @@
*/
public static EndpointReference fromOM(OMElement eprOMElement) throws AxisFault {
EndpointReference epr = new EndpointReference("");
- boolean isFinalAddressingNamespace = false;
- Map map = null;
-
- //First pass, identify the addressing namespace.
- OMElement address = eprOMElement
- .getFirstChildWithName((QName) finalQNames.get(AddressingConstants.EPR_ADDRESS));
-
- if (address != null) {
- map = finalQNames;
- isFinalAddressingNamespace = true;
-
- if (log.isDebugEnabled()) {
- log.debug("fromOM: Found address element for namespace, " +
- AddressingConstants.Final.WSA_NAMESPACE);
- }
- } else {
- address = eprOMElement.getFirstChildWithName(
- (QName) submissionQNames.get(AddressingConstants.EPR_ADDRESS));
-
- if (address != null) {
- map = submissionQNames;
- isFinalAddressingNamespace = false;
-
- if (log.isDebugEnabled()) {
- log.debug("fromOM: Found address element for namespace, " +
- AddressingConstants.Submission.WSA_NAMESPACE);
- }
- } else {
- throw new AxisFault(
- "Unable to locate an address element for the endpoint reference type.");
- }
- }
-
- //Second pass, identify the properties.
- fromOM(epr, eprOMElement, map, isFinalAddressingNamespace);
+ fromOM(epr, eprOMElement);
return epr;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org