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 ba...@apache.org on 2006/11/30 19:36:21 UTC
svn commit: r481032 - in /webservices/axis2/trunk/java/modules/jaxws: ./
src/org/apache/axis2/jaxws/description/
src/org/apache/axis2/jaxws/description/impl/
src/org/apache/axis2/jaxws/util/ test-resources/wsdl/
test/org/apache/axis2/jaxws/description/...
Author: barrettj
Date: Thu Nov 30 10:36:17 2006
New Revision: 481032
URL: http://svn.apache.org/viewvc?view=rev&rev=481032
Log:
Add support for runtime selecting an appropriate port from the WSDL or annotations if a portQName is not supplied to Service.getPort(...).
Added:
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/PortSelectionTests.java
Modified:
webservices/axis2/trunk/java/modules/jaxws/maven.xml
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescription.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescriptionWSDL.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescriptionWSDL.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/util/WSDLWrapper.java
webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/WSDLMultiTests.wsdl
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/WSDLDescriptionTests.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
Modified: webservices/axis2/trunk/java/modules/jaxws/maven.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/maven.xml?view=diff&rev=481032&r1=481031&r2=481032
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/maven.xml (original)
+++ webservices/axis2/trunk/java/modules/jaxws/maven.xml Thu Nov 30 10:36:17 2006
@@ -158,14 +158,6 @@
<arg line="-d ${schema.generated.src.dir} -quiet -wsdl ${wsdl.source.dir}/AnyType.wsdl"/>
</java>
- <ant:echo>Generating java from WSDLMultiTests.wsdl</ant:echo>
- <java classname="com.sun.tools.xjc.Driver" fork="true">
- <jvmarg line="${maven.junit.jvmargs}"/>
- <classpath refid="maven.dependency.classpath"/>
- <classpath location="${compiled.classes.dir}"/>
- <arg line="-d ${schema.generated.src.dir} -quiet -wsdl ${wsdl.source.dir}/WSDLMultiTests.wsdl"/>
- </java>
-
<!-- Compile the generated classes -->
<ant:echo>Compiling generated schema</ant:echo>
<javac destdir="${schema.generated.classes.dir}" srcdir="${schema.generated.src.dir}">
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescription.java?view=diff&rev=481032&r1=481031&r2=481032
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescription.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescription.java Thu Nov 30 10:36:17 2006
@@ -65,7 +65,6 @@
public static final String AXIS_SERVICE_PARAMETER = "org.apache.axis2.jaxws.description.EndpointDescription";
public static final String DEFAULT_CLIENT_BINDING_ID = SOAPBinding.SOAP11HTTP_BINDING;
- public static final QName SOAP_11_ADDRESS_ELEMENT = new QName(Constants.URI_WSDL_SOAP11, "address");
public abstract AxisService getAxisService();
public abstract ServiceClient getServiceClient();
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescriptionWSDL.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescriptionWSDL.java?view=diff&rev=481032&r1=481031&r2=481032
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescriptionWSDL.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/EndpointDescriptionWSDL.java Thu Nov 30 10:36:17 2006
@@ -22,18 +22,23 @@
import javax.wsdl.Port;
import javax.wsdl.PortType;
import javax.wsdl.Service;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.jaxws.util.Constants;
/**
*
*/
public interface EndpointDescriptionWSDL {
+ public static final QName SOAP_11_ADDRESS_ELEMENT = new QName(Constants.URI_WSDL_SOAP11, "address");
+ public static final QName SOAP_12_ADDRESS_ELEMENT = new QName(Constants.URI_WSDL_SOAP12, "address");
public Service getWSDLService();
public Port getWSDLPort();
public Binding getWSDLBinding();
public String getWSDLBindingType();
public String getWSDLSOAPAddress();
-
/**
* Is the WSDL definition fully specified for the endpoint (WSDL 1.1 port)
* represented by this EndpointDescription. If the WSDL is Partial, that means
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescriptionWSDL.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescriptionWSDL.java?view=diff&rev=481032&r1=481031&r2=481032
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescriptionWSDL.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescriptionWSDL.java Thu Nov 30 10:36:17 2006
@@ -1,10 +1,13 @@
package org.apache.axis2.jaxws.description;
import java.net.URL;
+import java.util.List;
import java.util.Map;
import javax.wsdl.Definition;
+import javax.wsdl.Port;
import javax.wsdl.Service;
+import javax.xml.namespace.QName;
import org.apache.axis2.jaxws.util.WSDLWrapper;
@@ -15,6 +18,20 @@
public Service getWSDLService();
public Map getWSDLPorts();
+ /**
+ * Return a collection of WSDL ports under this service which use
+ * the portType QName.
+ * @param portTypeQN
+ * @return
+ */
+ public List<Port> getWSDLPortsUsingPortType(QName portTypeQN);
+ /**
+ * Return a subset of the collection of WSDL ports which specify a
+ * SOAP 1.1 or 1.2 address.
+ * @param wsdlPorts
+ * @return
+ */
+ public List<Port> getWSDLPortsUsingSOAPAddress(List<Port> wsdlPorts);
public abstract URL getWSDLLocation();
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?view=diff&rev=481032&r1=481031&r2=481032
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java Thu Nov 30 10:36:17 2006
@@ -32,6 +32,7 @@
import javax.wsdl.PortType;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingType;
import javax.xml.ws.Service;
@@ -177,9 +178,26 @@
// TODO: This and the other constructor will (eventually) take the same args, so the logic needs to be combined
// TODO: If there is WSDL, could compare the namespace of the defn against the portQName.namespace
this.parentServiceDescription = parent;
- this.portQName = portName;
this.implOrSEIClass = theClass;
+ // REVIEW: setting these should probably be done in the getters! It needs to be done before we try to select a
+ // port to use if one wasn't specified because we'll try to get to the annotations to get the PortType
+ if (this.implOrSEIClass != null) {
+ webServiceAnnotation = (WebService) implOrSEIClass.getAnnotation(WebService.class);
+ webServiceProviderAnnotation = (WebServiceProvider) implOrSEIClass.getAnnotation(WebServiceProvider.class);
+ }
this.isDynamicPort = dynamicPort;
+ if (DescriptionUtils.isEmpty(portName)) {
+ // If the port name is null, then per JAX-WS 2.0 spec p. 55, the runtime is responsible for selecting the port.
+ this.portQName = selectPortToUse();
+ }
+ else {
+ this.portQName = portName;
+ }
+ // At this point, there must be a port QName set, either as passed in, or determined from the WSDL and/or annotations.
+ // If not, that is an error.
+ if (this.portQName == null) {
+ throw ExceptionFactory.makeWebServiceException("EndpointDescription.EndpointDescription: portQName could not be determined");
+ }
// TODO: Refactor this with the consideration of no WSDL/Generic Service/Annotated SEI
setupAxisService();
@@ -1203,6 +1221,10 @@
return endpointAddress;
}
+ /**
+ * Return the SOAP Address from the WSDL for this port.
+ * @return The SOAP Address from the WSDL for this port or null.
+ */
public String getWSDLSOAPAddress() {
if (wsdlSOAPAddress == null) {
Port wsdlPort = getWSDLPort();
@@ -1212,7 +1234,7 @@
for (Object listElement : extElementList) {
ExtensibilityElement extElement = (ExtensibilityElement) listElement;
if (isSOAPAddressElement(extElement)) {
- String soapAddress = ((SOAPAddress) extElement).getLocationURI();
+ String soapAddress = getSOAPAddressFromElement(extElement);
if (!DescriptionUtils.isEmpty(soapAddress)) {
wsdlSOAPAddress = soapAddress;
}
@@ -1223,16 +1245,101 @@
return wsdlSOAPAddress;
}
- private static boolean isSOAPAddressElement(ExtensibilityElement exElement){
+ /**
+ * Determine if the WSDL Extensibility element corresponds to the SOAP Address element.
+ * @param exElement
+ * @return
+ */
+ static boolean isSOAPAddressElement(ExtensibilityElement exElement){
boolean isAddress = false;
- // TODO: Add soap12 support later
- // || WSDLWrapper.SOAP_12_ADDRESS.equals(exElement.getElementType());
if (exElement != null) {
- isAddress = (SOAP_11_ADDRESS_ELEMENT.equals(exElement.getElementType()));
+ isAddress = (SOAP_11_ADDRESS_ELEMENT.equals(exElement.getElementType())
+ ||
+ (SOAP_12_ADDRESS_ELEMENT.equals(exElement.getElementType())));
}
return isAddress;
}
+
+ static String getSOAPAddressFromElement(ExtensibilityElement extElement) {
+ String returnAddress = null;
+
+ if (extElement != null) {
+ if (SOAP_11_ADDRESS_ELEMENT.equals(extElement.getElementType())) {
+ returnAddress = ((SOAPAddress) extElement).getLocationURI();
+ }
+ else if (SOAP_12_ADDRESS_ELEMENT.equals(extElement.getElementType())) {
+ returnAddress = ((SOAP12Address) extElement).getLocationURI();
+ }
+ }
+
+ return returnAddress;
+ }
+
+ /**
+ * Selects a port to use in the case where a portQName was not specified by the client on the
+ * Service.getPort(Class) call. If WSDL is present, then an appropriate port is looked for under
+ * the service element, and an exception is thrown if none can be found. If WSDL is not present,
+ * then the selected port is simply the one determined by annotations.
+ * @return A QName representing the port that is to be used.
+ */
+ private QName selectPortToUse() {
+ QName portToUse = null;
+ // If WSDL Service for this port is present, then we'll find an appropriate port defined in there and set
+ // the name accordingly. If no WSDL is present, the the PortQName getter will use annotations to set the value.
+ if (getWSDLService() != null) {
+ portToUse = selectWSDLPortToUse();
+ }
+ else {
+ // No WSDL, so the port to use is the one defined by the annotations.
+ portToUse = getPortQName();
+ }
+ return portToUse;
+ }
+
+ /**
+ * Look through the WSDL Service for a port that should be used. If none can be
+ * found, then throw an exception.
+ * @param wsdlService
+ * @return A QName representing the port from the WSDL that should be used.
+ */
+ private QName selectWSDLPortToUse() {
+ QName wsdlPortToUse = null;
+
+ // To select which WSDL Port to use, we do the following
+ // 1) Find the subset of all ports under the service that use the PortType represented by the SEI
+ // 2) From the subset in (1) find all those ports that specify a SOAP Address
+ // 3) Use the first port from (2)
+ // REVIEW: Should we be looking at the binding type or something else to determin which subset of ports to use;
+ // i.e. instead of just finding ports that specify a SOAP Address?
+
+ // Per JSR-181,
+ // - The portType name corresponds to the WebService.name annotation value, which is
+ // returned by getName()
+ // - The portType namespace corresponds to the WebService.targetNamespace annotation, which
+ // is returned by getTargetNamespace()
+ String portTypeLP = getName();
+ String portTypeTNS = getTargetNamespace();
+ QName portTypeQN = new QName(portTypeTNS, portTypeLP);
+
+ ServiceDescriptionWSDL serviceDescWSDL = (ServiceDescriptionWSDL) getServiceDescription();
+
+ List<Port> wsdlPortsUsingPortType = serviceDescWSDL.getWSDLPortsUsingPortType(portTypeQN);
+ List<Port> wsdlPortsUsingSOAPAddresses = serviceDescWSDL.getWSDLPortsUsingSOAPAddress(wsdlPortsUsingPortType);
+ if (wsdlPortsUsingSOAPAddresses != null && !wsdlPortsUsingSOAPAddresses.isEmpty()) {
+ // We return the first port that uses the particluar PortType and has a SOAP address.
+ // HOWEVER, that is not necessarily the first one in the WSDL that meets that criteria!
+ // The problem is that WSDL4J Service.getPorts(), which is used to get a Map of ports under the service
+ // DOES NOT return the ports in the order they are defined in the WSDL.
+ // Therefore, we can't necessarily predict which one we'll get back as the "first" one in the collection.
+ // REVIEW: Note the above comment; is there anything more predictible and determinstic we can do?
+ Port portToUse = (Port) wsdlPortsUsingSOAPAddresses.toArray()[0];
+ String portLocalPart = portToUse.getName();
+ String portNamespace = serviceDescWSDL.getWSDLService().getQName().getNamespaceURI();
+ wsdlPortToUse = new QName(portNamespace, portLocalPart);
+ }
+ return wsdlPortToUse;
+ }
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?view=diff&rev=481032&r1=481031&r2=481032
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java Thu Nov 30 10:36:17 2006
@@ -27,8 +27,12 @@
import javax.wsdl.Definition;
import javax.wsdl.Port;
+import javax.wsdl.PortType;
import javax.wsdl.Service;
import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
import javax.xml.namespace.QName;
import org.apache.axis2.client.ServiceClient;
@@ -225,11 +229,6 @@
break;
case GET_PORT:
- // TODO: Add support: portQName can be null when called from Service.getPort(Class)
- // TODO: I think this is the only place we need to handle a null portQName (not for create Dispatch or addPort)
- if (DescriptionUtils.isEmpty(portQName)) {
- throw new UnsupportedOperationException("ServiceDescription.updateEndpointDescription null PortQName not supported");
- }
// If an endpointDesc doesn't exist, and the port exists in the WSDL, create it
// If an endpointDesc already exists and has an associated SEI already, make sure they match
// If an endpointDesc already exists and was created for Dispatch (no SEI), update that with the SEI provided on the getPort
@@ -237,14 +236,16 @@
// Port must be declared (e.g. in WSDL or via annotations)
// TODO: Once isPortDeclared understands annotations and not just WSDL, the 2nd part of this check can possibly be removed.
// Although consider the check below that updates an existing EndpointDescritpion with an SEI.
- else if (!isPortDeclared || (endpointDescription != null && endpointDescription.isDynamicPort())) {
+ if (!isPortDeclared || (endpointDescription != null && endpointDescription.isDynamicPort())) {
// This guards against the case where an addPort was done previously and now a getPort is done on it.
// TODO: RAS & NLS
- throw ExceptionFactory.makeWebServiceException("ServiceDescription.updateEndpointDescription: Can not do a getPort on a port added via addPort(). PortQN: " + portQName.toString());
+ throw ExceptionFactory.makeWebServiceException("ServiceDescription.updateEndpointDescription: Can not do a getPort on a port added via addPort(). PortQN: " +
+ portQName != null ? portQName.toString() : "not specified");
}
else if (sei == null) {
// TODO: RAS & NLS
- throw ExceptionFactory.makeWebServiceException("ServiceDescription.updateEndpointDescription: Can not do a getPort with a null SEI. PortQN: " + portQName.toString());
+ throw ExceptionFactory.makeWebServiceException("ServiceDescription.updateEndpointDescription: Can not do a getPort with a null SEI. PortQN: " +
+ portQName != null ? portQName.toString() : "not specified");
}
else if (endpointDescription == null) {
// Use the SEI Class and its annotations to finish creating the Description hierachy: Endpoint, EndpointInterface, Operations, Parameters, etc.
@@ -326,6 +327,11 @@
portIsDeclared = true;
}
}
+ else {
+ // PortQName is null, so the runtime gets to choose which one to use. Since there's no WSDL
+ // we'll use annotations, so it is implicitly declared
+ portIsDeclared = true;
+ }
return portIsDeclared;
}
@@ -860,5 +866,38 @@
}
}
return portList;
+ }
+
+ public List<Port> getWSDLPortsUsingPortType(QName portTypeQN) {
+ ArrayList<Port> portList = new ArrayList<Port>();
+ if (!DescriptionUtils.isEmpty(portTypeQN)) {
+ Map wsdlPortMap = getWSDLPorts();
+ if (wsdlPortMap != null && !wsdlPortMap.isEmpty()) {
+ for (Object mapElement : wsdlPortMap.values()) {
+ Port wsdlPort = (Port) mapElement;
+ PortType wsdlPortType = wsdlPort.getBinding().getPortType();
+ QName wsdlPortTypeQN = wsdlPortType.getQName();
+ if (portTypeQN.equals(wsdlPortTypeQN)) {
+ portList.add(wsdlPort);
+ }
+ }
+ }
+ }
+ return portList;
+ }
+
+ public List<Port> getWSDLPortsUsingSOAPAddress(List<Port> wsdlPorts) {
+ ArrayList<Port> portsUsingAddress = new ArrayList<Port>();
+ if (wsdlPorts != null && !wsdlPorts.isEmpty()) {
+ for (Port checkPort : wsdlPorts) {
+ List extensibilityElementList = checkPort.getExtensibilityElements();
+ for (Object checkElement : extensibilityElementList) {
+ if (EndpointDescriptionImpl.isSOAPAddressElement((ExtensibilityElement) checkElement)) {
+ portsUsingAddress.add(checkPort);
+ }
+ }
+ }
+ }
+ return portsUsingAddress;
}
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/util/WSDLWrapper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/util/WSDLWrapper.java?view=diff&rev=481032&r1=481031&r2=481032
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/util/WSDLWrapper.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/util/WSDLWrapper.java Thu Nov 30 10:36:17 2006
@@ -32,7 +32,6 @@
public static final QName SOAP_11_BODY = new QName(Constants.URI_WSDL_SOAP11_BODY, "body");
public static final QName SOAP_11_HEADER = new QName(Constants.URI_WSDL_SOAP11_HEADER, "header");
public static final QName SOAP_11_OPERATION = new QName(Constants.URI_WSDL_SOAP11, "operation");
- public static final QName SOAP_12_ADDRESS = new QName(Constants.URI_WSDL_SOAP12, "address");
public static final QName SOAP_12_BINDING = new QName(Constants.URI_WSDL_SOAP12_BINDING, "binding");
public static final QName SOAP_12_BODY = new QName(Constants.URI_WSDL_SOAP12_BODY, "body");
public static final QName SOAP_12_HEADER = new QName(Constants.URI_WSDL_SOAP12_HEADER, "header");
Modified: webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/WSDLMultiTests.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/WSDLMultiTests.wsdl?view=diff&rev=481032&r1=481031&r2=481032
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/WSDLMultiTests.wsdl (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/WSDLMultiTests.wsdl Thu Nov 30 10:36:17 2006
@@ -1,15 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
-<definitions name="AddNumbers" targetNamespace="http://org/test/wsdlmultitests"
- xmlns:tns="http://org/test/wsdlmultitests" xmlns="http://schemas.xmlsoap.org/wsdl/"
+<definitions name="AddNumbers" targetNamespace="http://org/test/addnumbers"
+ xmlns:tns="http://org/test/addnumbers" xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+ xmlns:notsoap="http://not.a.soap.address/wsdl/notsoap/">
<types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified" targetNamespace="http://org/test/wsdlmultitests">
+ elementFormDefault="qualified" targetNamespace="http://org/test/addnumbers">
<element name="addNumbersResponse">
<complexType>
<sequence>
@@ -70,6 +72,17 @@
<input message="tns:oneWayInt" />
</operation>
</portType>
+ <portType name="AddNumbersPortTypeOtherPT">
+ <operation name="addNumbers">
+ <input message="tns:addNumbers" name="add" />
+ <output message="tns:addNumbersResponse" name="addResponse" />
+ <fault name="addNumbersFault" message="tns:addNumbersFault" />
+ </operation>
+ <operation name="oneWayInt">
+ <input message="tns:oneWayInt" />
+ </operation>
+ </portType>
+
<binding name="AddNumbersBinding" type="tns:AddNumbersPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
@@ -92,6 +105,50 @@
</input>
</operation>
</binding>
+ <binding name="AddNumbersBindingSamePT" type="tns:AddNumbersPortType">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
+ style="document" />
+ <operation name="addNumbers">
+ <soap:operation soapAction="" />
+ <input>
+ <soap:body use="literal" />
+ </input>
+ <output>
+ <soap:body use="literal" />
+ </output>
+ <fault name="addNumbersFault">
+ <soap:fault name="addNumbersFault" use="literal" />
+ </fault>
+ </operation>
+ <operation name="oneWayInt">
+ <soap:operation soapAction="" />
+ <input>
+ <soap:body use="literal" />
+ </input>
+ </operation>
+ </binding>
+ <binding name="AddNumbersBindingOtherPT" type="tns:AddNumbersPortTypeOtherPT">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
+ style="document" />
+ <operation name="addNumbers">
+ <soap:operation soapAction="" />
+ <input>
+ <soap:body use="literal" />
+ </input>
+ <output>
+ <soap:body use="literal" />
+ </output>
+ <fault name="addNumbersFault">
+ <soap:fault name="addNumbersFault" use="literal" />
+ </fault>
+ </operation>
+ <operation name="oneWayInt">
+ <soap:operation soapAction="" />
+ <input>
+ <soap:body use="literal" />
+ </input>
+ </operation>
+ </binding>
<!--
IMPORTANT NOTE: These ports are not intended to be connected too! This test is simply for
@@ -133,4 +190,24 @@
</port>
</service>
+ <service name="AddNumbersService3">
+ <port name="AddNumbersPortS3P1" binding="tns:AddNumbersBindingOtherPT">
+ <soap:address
+ location="http://localhost:9080/AddNumber/AddNumbersImplServiceS3P1" />
+ </port>
+ <port name="AddNumbersPortS3P2" binding="tns:AddNumbersBinding">
+ <soap:address
+ location="http://localhost:9080/AddNumber/AddNumbersImplServiceS3P2" />
+ </port>
+ <port name="AddNumbersPortS3P3" binding="tns:AddNumbersBindingSamePT">
+ <notsoap:address
+ location="http://localhost:9080/AddNumber/AddNumbersImplServiceS3P3" />
+ </port>
+ <port name="AddNumbersPortS3P4" binding="tns:AddNumbersBinding">
+ <soap12:address
+ location="http://localhost:9080/AddNumber/AddNumbersImplServiceS3P4" />
+ </port>
+
+ </service>
+
</definitions>
Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/PortSelectionTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/PortSelectionTests.java?view=auto&rev=481032
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/PortSelectionTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/PortSelectionTests.java Thu Nov 30 10:36:17 2006
@@ -0,0 +1,127 @@
+/*
+ * 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.description;
+
+import java.lang.reflect.Proxy;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Port;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+
+import org.apache.axis2.jaxws.sample.addnumbers.AddNumbersPortType;
+import org.apache.axis2.jaxws.spi.BindingProvider;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
+import org.apache.ws.axis2.tests.EchoPort;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class PortSelectionTests extends TestCase {
+ private static String VALID_SERVICE_NAMESPACE = "http://org/test/addnumbers";
+ private static String VALID_SERVICE_LOCALPART_3 = "AddNumbersService3";
+
+ public void testServiceDescPortSelectionMethods() {
+ URL wsdlURL = DescriptionTestUtils.getWSDLURL("WSDLMultiTests.wsdl");
+
+ QName serviceQN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_3);
+ Service service = Service.create(wsdlURL, serviceQN);
+ assertNotNull(service);
+ ServiceDelegate serviceDelegate = DescriptionTestUtils.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+
+ ServiceDescriptionWSDL serviceDescWSDL = (ServiceDescriptionWSDL) serviceDesc;
+
+ Map allPorts = serviceDescWSDL.getWSDLPorts();
+ assertEquals(4, allPorts.size());
+
+ QName portTypeQName = new QName(VALID_SERVICE_NAMESPACE, "AddNumbersPortType");
+ List<Port> portsUsingPortType = serviceDescWSDL.getWSDLPortsUsingPortType(portTypeQName);
+ assertEquals(3, portsUsingPortType.size());
+
+ QName otherPortTypeQName = new QName(VALID_SERVICE_NAMESPACE, "AddNumbersPortTypeOtherPT");
+ List<Port> portsUsingOtherPortType = serviceDescWSDL.getWSDLPortsUsingPortType(otherPortTypeQName);
+ assertEquals(1, portsUsingOtherPortType.size());
+
+ List<Port> portsUsingSOAPAddress = serviceDescWSDL.getWSDLPortsUsingSOAPAddress(portsUsingPortType);
+ assertEquals(2, portsUsingSOAPAddress.size());
+ }
+
+ public void testPortSelection() {
+ // Test the Service.getPort call
+ URL wsdlURL = DescriptionTestUtils.getWSDLURL("WSDLMultiTests.wsdl");
+
+ QName serviceQN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_3);
+ Service service = Service.create(wsdlURL, serviceQN);
+ assertNotNull(service);
+ AddNumbersPortType selectPort = service.getPort(AddNumbersPortType.class);
+ BindingProvider bindingProvider = (BindingProvider)Proxy.getInvocationHandler(selectPort);
+ EndpointDescription endpointDesc = bindingProvider.getEndpointDescription();
+ QName selectedPortQName = endpointDesc.getPortQName();
+ assertNotNull(selectedPortQName);
+ // We expect the first port in the WSDL which uses the PortType for the SEI AddNumbersPortType to be selected
+ // UNFORTUNATELY! WSDL4J Service.getPorts(), which returns a Map of ports under the service DOES NOT return
+ // them in the order defined in the WSDL. Therefore, we can't necessarily predict which one we'll get back.
+ // So, the following two lines may cause the test to fail.
+// QName expectedQName = new QName(VALID_SERVICE_NAMESPACE, "AddNumbersPortS3P2");
+// assertEquals(expectedQName, selectedPortQName);
+ // So, the best we can do is just test that ONE of the valid ports is the one that was selected.
+ boolean testSuccessful = false;
+ QName[] validPorts = new QName[3];
+ validPorts[0] = new QName(VALID_SERVICE_NAMESPACE, "AddNumbersPortS3P2");
+ validPorts[1] = new QName(VALID_SERVICE_NAMESPACE, "AddNumbersPortS3P3");
+ validPorts[2] = new QName(VALID_SERVICE_NAMESPACE, "AddNumbersPortS3P4");
+ for (QName checkPort : validPorts) {
+ if (selectedPortQName.equals(checkPort)) {
+ testSuccessful = true;
+ break;
+ }
+ }
+ assertTrue(testSuccessful);
+ }
+
+ public void testInvalidPortSelection() {
+ URL wsdlURL = DescriptionTestUtils.getWSDLURL("WSDLMultiTests.wsdl");
+
+ QName serviceQN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_3);
+ Service service = Service.create(wsdlURL, serviceQN);
+ assertNotNull(service);
+ // There should be no ports in the service that use this SEI!
+ try {
+ EchoPort selectPort = service.getPort(EchoPort.class);
+ fail("Shouldn't have found a port for the given SEI!");
+ }
+ catch (WebServiceException ex) {
+ // Expected code path
+ }
+ catch (Exception ex) {
+ fail("Unexpected exception " + ex.toString());
+ }
+
+
+ }
+
+}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java?view=diff&rev=481032&r1=481031&r2=481032
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java Thu Nov 30 10:36:17 2006
@@ -34,7 +34,7 @@
import junit.framework.TestCase;
public class ServiceTests extends TestCase {
- private static String VALID_SERVICE_NAMESPACE = "http://org/test/wsdlmultitests";
+ private static String VALID_SERVICE_NAMESPACE = "http://org/test/addnumbers";
private static String VALID_SERVICE_LOCALPART_1 = "AddNumbersService1";
private static String VALID_SERVICE_LOCALPART_2 = "AddNumbersService2";
private static String VALID_PORT_S1P1 = "AddNumbersPortS1P1";
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/WSDLDescriptionTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/WSDLDescriptionTests.java?view=diff&rev=481032&r1=481031&r2=481032
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/WSDLDescriptionTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/WSDLDescriptionTests.java Thu Nov 30 10:36:17 2006
@@ -87,14 +87,11 @@
// ========================================================================
public void testValidGetPortWithClass() {
- // TODO: This is currently not supported (in Beta) but needs to be supported; this test tests the unsupported behavior
- // The try/catch should be removed and the pass/fail criteria changed.
try {
EchoPort echoPort = service.getPort(EchoPort.class);
- fail("BETA ONLY: didn't catch expected exception");
}
- catch (UnsupportedOperationException e) {
- // FOR BETA ONLY: expect this exception
+ catch (Exception e) {
+ fail("Caught unexpected exception");
}
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?view=diff&rev=481032&r1=481031&r2=481032
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java Thu Nov 30 10:36:17 2006
@@ -29,6 +29,7 @@
import org.apache.axis2.jaxws.description.AnnotationServiceImplWithDBCTests;
import org.apache.axis2.jaxws.description.GetDescFromBindingProvider;
import org.apache.axis2.jaxws.description.PartialWSDLTests;
+import org.apache.axis2.jaxws.description.PortSelectionTests;
import org.apache.axis2.jaxws.description.ServiceTests;
import org.apache.axis2.jaxws.description.ServiceAnnotationTests;
import org.apache.axis2.jaxws.description.ValidateWSDLTests;
@@ -112,6 +113,7 @@
suite.addTestSuite(GetDescFromBindingProvider.class);
suite.addTestSuite(WrapperPackageTests.class);
suite.addTestSuite(ServiceTests.class);
+ suite.addTestSuite(PortSelectionTests.class);
suite.addTestSuite(HandlerChainProcessorTests.class);
suite.addTestSuite(JaxwsMessageBundleTests.class);
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org