Author: jliu
Date: Tue Jan 16 02:19:22 2007
New Revision: 496652
URL: http://svn.apache.org/viewvc?view=rev&rev=496652
Log:
[CXF-339] Apply patch on behalf of Unreal Jiang: If a service has two ports in
a wsdl file, and if port name is null, createPort() in serviceImpl will throw
out an exception.
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?view=diff&rev=496652&r1=496651&r2=496652
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
Tue Jan 16 02:19:22 2007
@@ -33,6 +33,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.jws.WebService;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
@@ -253,9 +254,28 @@
EndpointInfo ei = null;
if (portName == null) {
- if (1 == si.getEndpoints().size()) {
- ei = si.getEndpoints().iterator().next();
- pn = new QName(service.getName().getNamespaceURI(),
ei.getName().getLocalPart());
+ if (1 <= si.getEndpoints().size()) {
+ Iterator it = si.getEndpoints().iterator();
+ if (1 == si.getEndpoints().size()) {
+ ei = (EndpointInfo) it.next();
+ pn = new QName(service.getName().getNamespaceURI(),
ei.getName().getLocalPart());
+ } else {
+ WebService webService = (WebService)
serviceEndpointInterface
+ .getAnnotation(WebService.class);
+ String name = webService.name();
+ String nameSpace = webService.targetNamespace();
+ QName portTypeName = new QName(nameSpace, name);
+ EndpointInfo epi = null;
+ while (it.hasNext()) {
+ epi = (EndpointInfo) it.next();
+ //InterfaceInfo interfaceInfo =
epi.getBinding().getInterface();
+ if
(epi.getBinding().getInterface().getName().equals(portTypeName)) {
+ pn = new
QName(service.getName().getNamespaceURI(), epi.getName().getLocalPart());
+ ei = epi;
+ break;
+ }
+ }
+ }
}
} else {
// first check the endpointInfo from portInfos
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java?view=diff&rev=496652&r1=496651&r2=496652
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
Tue Jan 16 02:19:22 2007
@@ -46,9 +46,12 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+//import org.apache.cxf.Bus;
import org.apache.cxf.binding.soap.Soap11;
+//import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.helpers.XPathUtils;
+//import org.apache.cxf.jaxws.ServiceImpl;
import org.apache.cxf.message.Message;
import org.apache.cxf.systest.common.ClientServerSetupBase;
import org.apache.cxf.systest.common.ClientServerTestBase;
@@ -164,6 +167,23 @@
}
}
+ public void testGetPortOnePara() throws Exception {
+
+ Service service = Service.create(serviceName);
+
+ Greeter greeter = service.getPort(Greeter.class);
+ String response = new String("Bonjour");
+
+ try {
+ greeter.greetMe("test");
+ String reply = greeter.sayHi();
+ assertNotNull("no response received from service", reply);
+ assertEquals(response, reply);
+ } catch (UndeclaredThrowableException ex) {
+ throw (Exception)ex.getCause();
+ }
+ }
+
public void testDocLitBareConnection() throws Exception {
SOAPServiceDocLitBare service = new SOAPServiceDocLitBare();