Author: asoldano
Date: 2014-06-04 12:20:34 -0400 (Wed, 04 Jun 2014)
New Revision: 18715
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/webserviceref/MultipleEndpointService.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/jaxws/samples/webserviceref/META-INF/wsdl/MultipleEndpoint.wsdl
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/AbstractServiceObjectFactoryJAXWS.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/ant-import/build-samples-jaxws.xml
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/webserviceref/ServletClient.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/jaxws/samples/webserviceref/WEB-INF-client/jboss-web.xml
Log:
[JBWS-3798] @WebEndpoint name not considered when building up webservicerefs
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/AbstractServiceObjectFactoryJAXWS.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/AbstractServiceObjectFactoryJAXWS.java 2014-06-04
06:42:26 UTC (rev 18714)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/AbstractServiceObjectFactoryJAXWS.java 2014-06-04
16:20:34 UTC (rev 18715)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2014, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -29,13 +29,16 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collection;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.RespectBindingFeature;
import javax.xml.ws.Service;
+import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.soap.AddressingFeature;
@@ -54,6 +57,8 @@
*/
public abstract class AbstractServiceObjectFactoryJAXWS
{
+ private static enum PortMatch {YES, NO, MAYBE};
+
public final Object getObjectInstance(UnifiedServiceRefMetaData serviceRef)
{
try
@@ -179,11 +184,11 @@
final QName portQName, final WebServiceFeature[] features, final String
endpointAddress) throws NoSuchMethodException,
InstantiationException, IllegalAccessException, InvocationTargetException
{
- Object retVal = null;
-
Object port = null;
+ Object candidatePort = null;
if (serviceClass != Service.class)
{
+ final Set<Method> signatureMatchingMethods = new HashSet<Method>();
for (Method method : getDeclaredMethods(serviceClass))
{
String methodName = method.getName();
@@ -191,28 +196,51 @@
if (methodName.startsWith("get") &&
targetClass.isAssignableFrom(retType))
{
final Method targetMethod = getMethodFor(methodName, features,
serviceClass);
+ signatureMatchingMethods.add(targetMethod);
+ }
+ }
+ for (Method method : signatureMatchingMethods)
+ {
+ PortMatch matchResult = portNameMatches(portQName, method);
+ if (matchResult.equals(PortMatch.YES)) {
final Object[] args = getArgumentsFor(features);
- port = targetMethod.invoke(target, args);
- retVal = port;
+ port = method.invoke(target, args);
break;
+ } else if (matchResult.equals(PortMatch.MAYBE)) {
+ final Object[] args = getArgumentsFor(features);
+ candidatePort = method.invoke(target, args);
}
}
}
-
if (port == null)
{
+ port = candidatePort;
+ }
+ if (port == null)
+ {
Method method = getMethodFor("getPort", portQName, features,
serviceClass);
Object[] args = getArgumentsFor(portQName, features, targetClass);
port = method.invoke(target, args);
- retVal = port;
}
if (endpointAddress != null)
{
- ((BindingProvider)
retVal).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
endpointAddress);
+ ((BindingProvider)
port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
endpointAddress);
}
- return retVal;
+ return port;
}
+ private static PortMatch portNameMatches(final QName portQName, final Method
targetMethod) {
+ final String portName = portQName != null ? portQName.getLocalPart() : null;
+ if (portName == null) { //no port specified, so we *might* have a valid match...
+ return PortMatch.MAYBE;
+ }
+ WebEndpoint webEndpointAnnotation = targetMethod.getAnnotation(WebEndpoint.class);
+ if (webEndpointAnnotation == null || webEndpointAnnotation.name() == null ||
webEndpointAnnotation.name().isEmpty()) {
+ return PortMatch.MAYBE; // no way to match, no port specified using
@WebEndpoint
+ }
+ return webEndpointAnnotation.name().equals(portName) ? PortMatch.YES :
PortMatch.NO;
+ }
+
private static Method[] getDeclaredMethods(final Class<?> cls) {
return AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
public Method[] run() {
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/ant-import/build-samples-jaxws.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/ant-import/build-samples-jaxws.xml 2014-06-04
06:42:26 UTC (rev 18714)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/ant-import/build-samples-jaxws.xml 2014-06-04
16:20:34 UTC (rev 18715)
@@ -497,6 +497,7 @@
<classes dir="${tests.output.dir}/test-classes">
<include
name="org/jboss/test/ws/jaxws/samples/webserviceref/ServletClient.class"/>
<include
name="org/jboss/test/ws/jaxws/samples/webserviceref/EndpointService.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/webserviceref/MultipleEndpointService.class"/>
<include
name="org/jboss/test/ws/jaxws/samples/webserviceref/Endpoint.class"/>
<include
name="org/jboss/test/ws/jaxws/samples/webserviceref/EchoResponse.class"/>
<include
name="org/jboss/test/ws/jaxws/samples/webserviceref/Echo.class"/>
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/webserviceref/MultipleEndpointService.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/webserviceref/MultipleEndpointService.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/webserviceref/MultipleEndpointService.java 2014-06-04
16:20:34 UTC (rev 18715)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.webserviceref;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceClient;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.WebServiceFeature;
+
+@WebServiceClient(name = "EndpointService", targetNamespace =
"http://org.jboss.ws/wsref", wsdlLocation =
"META-INF/wsdl/MultipleEndpoint.wsdl")
+public class MultipleEndpointService extends Service
+{
+
+ private final static URL ENDPOINTSERVICE_WSDL_LOCATION;
+ private final static WebServiceException ENDPOINTSERVICE_EXCEPTION;
+ private final static QName ENDPOINTSERVICE_QNAME = new
QName("http://org.jboss.ws/wsref", "EndpointService");
+
+ static
+ {
+ URL url = null;
+ WebServiceException e = null;
+ url = MultipleEndpointService.class.getResource("bogusAddress");
//invalid address on purpose, to test JBWS-3015 via service7 in EJB3Client
+ if (url == null)
+ {
+ e = new WebServiceException("Cannot find wsdl, please put in
classpath");
+ }
+ ENDPOINTSERVICE_WSDL_LOCATION = url;
+ ENDPOINTSERVICE_EXCEPTION = e;
+ }
+
+ public MultipleEndpointService()
+ {
+ super(__getWsdlLocation(), ENDPOINTSERVICE_QNAME);
+ }
+
+ public MultipleEndpointService(URL wsdlLocation)
+ {
+ super(wsdlLocation, ENDPOINTSERVICE_QNAME);
+ }
+
+ public MultipleEndpointService(URL wsdlLocation, QName serviceName)
+ {
+ super(wsdlLocation, serviceName);
+ }
+
+ /**
+ *
+ * @return
+ * returns Endpoint
+ */
+ @WebEndpoint(name = "EndpointPort")
+ public Endpoint getEndpointPort()
+ {
+ return super.getPort(new QName("http://org.jboss.ws/wsref",
"EndpointPort"), Endpoint.class);
+ }
+
+ @WebEndpoint(name = "EndpointPort2")
+ public Endpoint getEndpointPort2()
+ {
+ return super.getPort(new QName("http://org.jboss.ws/wsref",
"EndpointPort2"), Endpoint.class);
+ }
+
+ /**
+ *
+ * @param features
+ * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.
Supported features not in the <code>features</code> parameter will have their
default values.
+ * @return
+ * returns Endpoint
+ */
+ @WebEndpoint(name = "EndpointPort")
+ public Endpoint getEndpointPort(WebServiceFeature... features)
+ {
+ return super.getPort(new QName("http://org.jboss.ws/wsref",
"EndpointPort"), Endpoint.class, features);
+ }
+
+ @WebEndpoint(name = "EndpointPort2")
+ public Endpoint getEndpointPort2(WebServiceFeature... features)
+ {
+ return super.getPort(new QName("http://org.jboss.ws/wsref",
"EndpointPort2"), Endpoint.class, features);
+ }
+
+ private static URL __getWsdlLocation()
+ {
+ if (ENDPOINTSERVICE_EXCEPTION != null)
+ {
+ throw ENDPOINTSERVICE_EXCEPTION;
+ }
+ return ENDPOINTSERVICE_WSDL_LOCATION;
+ }
+
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/webserviceref/MultipleEndpointService.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/webserviceref/ServletClient.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/webserviceref/ServletClient.java 2014-06-04
06:42:26 UTC (rev 18714)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/samples/webserviceref/ServletClient.java 2014-06-04
16:20:34 UTC (rev 18715)
@@ -32,6 +32,7 @@
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceRef;
import javax.xml.ws.WebServiceRefs;
+import javax.xml.ws.soap.SOAPFaultException;
import org.jboss.logging.Logger;
@@ -85,6 +86,12 @@
// Test on field with value
@WebServiceRef(value = EndpointService.class)
public Endpoint port3;
+
+ @WebServiceRef(value = MultipleEndpointService.class)
+ public Endpoint port7;
+
+ @WebServiceRef(value = MultipleEndpointService.class)
+ public Endpoint port8;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
@@ -111,6 +118,7 @@
ports.add((Endpoint)iniCtx.lookup("java:comp/env/Port2"));
ports.add(port3);
ports.add((Endpoint)iniCtx.lookup("java:comp/env/" +
getClass().getName() + "/port3"));
+ ports.add(port8);
}
catch (Exception ex)
{
@@ -124,6 +132,14 @@
if (inStr.equals(outStr) == false)
throw new WebServiceException("Invalid echo return: " + inStr);
}
+ try {
+ port7.echo("Foo");
+ throw new WebServiceException("Expected exception due to SOAP 1.2 message
sent to a SOAP 1.1 endpoint");
+ } catch (SOAPFaultException sfe) {
+ if (!sfe.getMessage().contains("SOAP 1.2")) {
+ throw new WebServiceException("Expected reference to SOAP version
mismatch in error message, but got: " + sfe.getMessage());
+ }
+ }
res.getWriter().print(inStr);
}
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/jaxws/samples/webserviceref/META-INF/wsdl/MultipleEndpoint.wsdl
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/jaxws/samples/webserviceref/META-INF/wsdl/MultipleEndpoint.wsdl
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/jaxws/samples/webserviceref/META-INF/wsdl/MultipleEndpoint.wsdl 2014-06-04
16:20:34 UTC (rev 18715)
@@ -0,0 +1,55 @@
+<!--
+ wsimport -d ../../../java -keep -p org.jboss.test.ws.jaxws.webserviceref
META-INF/wsdl/Endpoint.wsdl
+-->
+<definitions name='EndpointService'
targetNamespace='http://org.jboss.ws/wsref'
xmlns='http://schemas.xmlsoap.org/wsdl/'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:soap12='http://schemas.xmlsoap.org/wsdl/soap12/'
xmlns:tns='http://org.jboss.ws/wsref'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+
+ <message name='Endpoint_echo'>
+ <part name='arg0' type='xsd:string'/>
+ </message>
+ <message name='Endpoint_echoResponse'>
+ <part name='return' type='xsd:string'/>
+ </message>
+
+ <portType name='Endpoint'>
+ <operation name='echo' parameterOrder='arg0'>
+ <input message='tns:Endpoint_echo'/>
+ <output message='tns:Endpoint_echoResponse'/>
+ </operation>
+ </portType>
+
+ <binding name='EndpointBinding' type='tns:Endpoint'>
+ <soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='echo'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body namespace='http://org.jboss.ws/wsref'
use='literal'/>
+ </input>
+ <output>
+ <soap:body namespace='http://org.jboss.ws/wsref'
use='literal'/>
+ </output>
+ </operation>
+ </binding>
+
+ <binding name='EndpointBinding2' type='tns:Endpoint'>
+ <soap12:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='echo'>
+ <soap12:operation soapAction=''/>
+ <input>
+ <soap12:body namespace='http://org.jboss.ws/wsref'
use='literal'/>
+ </input>
+ <output>
+ <soap12:body namespace='http://org.jboss.ws/wsref'
use='literal'/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name='EndpointService'>
+ <port binding='tns:EndpointBinding' name='EndpointPort'>
+ <soap:address
location='http://@jboss.bind.address@:8080/jaxws-samples-webserviceref'/>
+ </port>
+ <port binding='tns:EndpointBinding2' name='EndpointPort2'>
+ <soap:address
location='http://@jboss.bind.address@:8080/jaxws-samples-webserviceref'/>
+ </port>
+ </service>
+
+</definitions>
Property changes on:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/jaxws/samples/webserviceref/META-INF/wsdl/MultipleEndpoint.wsdl
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/jaxws/samples/webserviceref/WEB-INF-client/jboss-web.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/jaxws/samples/webserviceref/WEB-INF-client/jboss-web.xml 2014-06-04
06:42:26 UTC (rev 18714)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/jaxws/samples/webserviceref/WEB-INF-client/jboss-web.xml 2014-06-04
16:20:34 UTC (rev 18715)
@@ -84,5 +84,31 @@
<service-qname>{http://org.jboss.ws/wsref}EndpointService</service-qname>
<wsdl-override>WEB-INF/wsdl/Endpoint.wsdl</wsdl-override>
</service-ref>
+
+ <!--
+ @WebServiceRef(value = MultipleEndpointService.class)
+ -->
+ <service-ref>
+
<service-ref-name>org.jboss.test.ws.jaxws.samples.webserviceref.ServletClient/port7</service-ref-name>
+
<service-qname>{http://org.jboss.ws/wsref}EndpointService</service-qname>
+ <wsdl-override>WEB-INF/wsdl/MultipleEndpoint.wsdl</wsdl-override>
+ <port-component-ref>
+
<service-endpoint-interface>org.jboss.test.ws.jaxws.samples.webserviceref.Endpoint</service-endpoint-interface>
+ <port-qname>{http://org.jboss.ws/wsref}EndpointPort2</port-qname>
+ </port-component-ref>
+ </service-ref>
+ <!--
+ @WebServiceRef(value = MultipleEndpointService.class)
+ -->
+ <service-ref>
+
<service-ref-name>org.jboss.test.ws.jaxws.samples.webserviceref.ServletClient/port8</service-ref-name>
+
<service-qname>{http://org.jboss.ws/wsref}EndpointService</service-qname>
+ <wsdl-override>WEB-INF/wsdl/MultipleEndpoint.wsdl</wsdl-override>
+ <port-component-ref>
+
<service-endpoint-interface>org.jboss.test.ws.jaxws.samples.webserviceref.Endpoint</service-endpoint-interface>
+ <port-qname>{http://org.jboss.ws/wsref}EndpointPort</port-qname>
+ </port-component-ref>
+ </service-ref>
+
</jboss-web>
\ No newline at end of file