Author: jliu
Date: Sun Apr 15 07:04:09 2007
New Revision: 528981
URL: http://svn.apache.org/viewvc?view=rev&rev=528981
Log:
CXF-519: wrong name space is generated when using ReflectionServiceFactoryBean
to build service model from class. This problem occurs for wrapped doc/lit.
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?view=diff&rev=528981&r1=528980&r2=528981
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
Sun Apr 15 07:04:09 2007
@@ -325,9 +325,25 @@
}
@Override
- public QName getOutputMessageName(OperationInfo op, Method method) {
+ public Boolean isOutParam(Method method, int j) {
+ method = getDeclaredMethod(method);
+ if (j == -1) {
+ return !method.getReturnType().equals(void.class);
+ }
+
+ WebParam webParam = getWebParam(method, j);
+
+ if (webParam != null && (webParam.mode().equals(Mode.OUT) ||
webParam.mode().equals(Mode.INOUT))) {
+ return Boolean.TRUE;
+ }
+
+ return method.getParameterTypes()[j] == Holder.class;
+ }
+
+ @Override
+ public QName getRequestWrapperName(OperationInfo op, Method method) {
Method m = getDeclaredMethod(method);
- ResponseWrapper rw = m.getAnnotation(ResponseWrapper.class);
+ RequestWrapper rw = m.getAnnotation(RequestWrapper.class);
if (rw == null) {
return null;
}
@@ -336,13 +352,13 @@
if (nm.length() > 0 && lp.length() > 0) {
return new QName(nm, lp);
}
- return null;
- }
+ return null;
+ }
@Override
- public QName getInputMessageName(OperationInfo op, Method method) {
+ public QName getResponseWrapperName(OperationInfo op, Method method) {
Method m = getDeclaredMethod(method);
- RequestWrapper rw = m.getAnnotation(RequestWrapper.class);
+ ResponseWrapper rw = m.getAnnotation(ResponseWrapper.class);
if (rw == null) {
return null;
}
@@ -351,25 +367,10 @@
if (nm.length() > 0 && lp.length() > 0) {
return new QName(nm, lp);
}
- return null;
+ return null;
}
-
- @Override
- public Boolean isOutParam(Method method, int j) {
- method = getDeclaredMethod(method);
- if (j == -1) {
- return !method.getReturnType().equals(void.class);
- }
-
- WebParam webParam = getWebParam(method, j);
-
- if (webParam != null && (webParam.mode().equals(Mode.OUT) ||
webParam.mode().equals(Mode.INOUT))) {
- return Boolean.TRUE;
- }
-
- return method.getParameterTypes()[j] == Holder.class;
- }
-
+
+
@Override
public Class getResponseWrapper(Method selected) {
Method m = getDeclaredMethod(selected);
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java?view=diff&rev=528981&r1=528980&r2=528981
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
Sun Apr 15 07:04:09 2007
@@ -22,6 +22,7 @@
import java.net.URL;
import java.util.Collection;
import java.util.Iterator;
+import java.util.List;
import javax.xml.namespace.QName;
@@ -35,6 +36,7 @@
import org.apache.cxf.service.model.InterfaceInfo;
import org.apache.cxf.service.model.MessagePartInfo;
import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
import org.apache.hello_world_soap_http.GreeterImpl;
import org.junit.Test;
@@ -134,4 +136,55 @@
assertEquals(Boolean.TRUE,
part.getProperty(JaxWsServiceFactoryBean.MODE_INOUT));
*/
}
+
+ @Test
+ public void testWrappedDocLit() throws Exception {
+ ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
+ Bus bus = getBus();
+ bean.setBus(bus);
+ bean.setServiceClass(org.apache.hello_world_doc_lit.Greeter.class);
+ Service service = bean.create();
+
+ ServiceInfo si = service.getServiceInfos().get(0);
+ InterfaceInfo intf = si.getInterface();
+
+ assertEquals(4, intf.getOperations().size());
+
+ String ns = si.getName().getNamespaceURI();
+ assertEquals("http://apache.org/hello_world_doc_lit", ns);
+ OperationInfo greetMeOp = intf.getOperation(new QName(ns, "greetMe"));
+ assertNotNull(greetMeOp);
+
+ assertEquals("greetMe", greetMeOp.getInput().getName().getLocalPart());
+ assertEquals("http://apache.org/hello_world_doc_lit",
greetMeOp.getInput().getName()
+ .getNamespaceURI());
+
+ List<MessagePartInfo> messageParts =
greetMeOp.getInput().getMessageParts();
+ assertEquals(1, messageParts.size());
+
+ MessagePartInfo inMessagePart = messageParts.get(0);
+ assertEquals("http://apache.org/hello_world_doc_lit",
inMessagePart.getName().getNamespaceURI());
+ assertEquals("http://apache.org/hello_world_doc_lit/types",
inMessagePart.getElementQName()
+ .getNamespaceURI());
+
+
+ // test output
+ messageParts = greetMeOp.getOutput().getMessageParts();
+ assertEquals(1, messageParts.size());
+ assertEquals("greetMeResponse",
greetMeOp.getOutput().getName().getLocalPart());
+
+ MessagePartInfo outMessagePart = messageParts.get(0);
+ assertEquals("greetMeResponse",
outMessagePart.getName().getLocalPart());
+ assertEquals("http://apache.org/hello_world_doc_lit",
outMessagePart.getName().getNamespaceURI());
+ assertEquals("http://apache.org/hello_world_doc_lit/types",
outMessagePart.getElementQName()
+ .getNamespaceURI());
+
+
+ OperationInfo greetMeOneWayOp = si.getInterface().getOperation(new
QName(ns, "greetMeOneWay"));
+ assertEquals(1, greetMeOneWayOp.getInput().getMessageParts().size());
+
+ //FIXME: CXF-533
+ //assertEquals(0,
greetMeOneWayOp.getOutput().getMessageParts().size());
+ }
+
}
Modified:
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java?view=diff&rev=528981&r1=528980&r2=528981
==============================================================================
---
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
(original)
+++
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
Sun Apr 15 07:04:09 2007
@@ -144,7 +144,15 @@
public QName getEndpointName() {
return null;
}
-
+
+ public QName getRequestWrapperName(OperationInfo op, Method method) {
+ return null;
+ }
+
+ public QName getResponseWrapperName(OperationInfo op, Method method) {
+ return null;
+ }
+
public Class getResponseWrapper(Method selected) {
return null;
}
Modified:
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?view=diff&rev=528981&r1=528980&r2=528981
==============================================================================
---
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Sun Apr 15 07:04:09 2007
@@ -214,10 +214,6 @@
getDataBinding().initialize(service);
if (isWrapped()) {
- initializeWrappedElementNames(serviceInfo);
- }
-
- if (isWrapped()) {
initializeWrappedSchema(serviceInfo);
}
}
@@ -342,7 +338,9 @@
if (uOp.hasInput()) {
MessageInfo msg = new MessageInfo(op,
uOp.getInput().getName());
op.setInput(uOp.getInputName(), msg);
- msg.addMessagePart(uOp.getInput().getName());
+
+ createInputWrappedMessageParts(uOp, m, msg);
+ //msg.addMessagePart(uOp.getInput().getName());
for (MessagePartInfo p : uOp.getInput().getMessageParts()) {
p.setConcreteName(p.getName());
@@ -355,8 +353,11 @@
MessageInfo msg = new MessageInfo(op, name);
op.setOutput(uOp.getOutputName(), msg);
- MessagePartInfo part = msg.addMessagePart(name);
- part.setIndex(-1);
+ createOutputWrappedMessageParts(uOp, m, msg);
+ /*
+ MessagePartInfo part =
msg.addMessagePart(name);
+ part.setIndex(-1);
+ */
for (MessagePartInfo p : uOp.getOutput().getMessageParts()) {
p.setConcreteName(p.getName());
@@ -372,26 +373,6 @@
return op;
}
- private void initializeWrappedElementNames(ServiceInfo serviceInfo) {
- for (OperationInfo op : serviceInfo.getInterface().getOperations()) {
- if (op.hasInput()) {
- setElementNameOnPart(op.getInput());
- }
- if (op.hasOutput()) {
- setElementNameOnPart(op.getOutput());
- }
- }
- }
-
- private void setElementNameOnPart(MessageInfo m) {
- List<MessagePartInfo> parts = m.getMessageParts();
- if (parts.size() == 1) {
- MessagePartInfo p = parts.get(0);
- p.setElement(true);
- p.setElementQName(m.getName());
- }
- }
-
protected void initializeWrappedSchema(ServiceInfo serviceInfo) {
XmlSchemaCollection col = new XmlSchemaCollection();
XmlSchema schema = new XmlSchema(getServiceNamespace(), col);
@@ -515,7 +496,39 @@
initializeFaults(intf, op, method);
}
-
+
+ protected void createInputWrappedMessageParts(OperationInfo op, Method
method, MessageInfo inMsg) {
+ MessagePartInfo part = inMsg.addMessagePart(op.getInputName());
+ part.setElement(true);
+ for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
+ AbstractServiceConfiguration c =
(AbstractServiceConfiguration)itr.next();
+ QName q = c.getRequestWrapperName(op, method);
+ if (q != null) {
+ part.setElementQName(q);
+ }
+ }
+ if (part.getElementQName() == null) {
+ part.setElementQName(inMsg.getName());
+ }
+ }
+
+ protected void createOutputWrappedMessageParts(OperationInfo op, Method
method, MessageInfo inMsg) {
+ MessagePartInfo part = inMsg.addMessagePart(op.getOutputName());
+ part.setElement(true);
+ part.setIndex(-1);
+ for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
+ AbstractServiceConfiguration c =
(AbstractServiceConfiguration)itr.next();
+ QName q = c.getResponseWrapperName(op, method);
+ if (q != null) {
+ part.setElementQName(q);
+ }
+ }
+
+ if (part.getElementQName() == null) {
+ part.setElementQName(inMsg.getName());
+ }
+ }
+
// TODO: Remove reference to JAX-WS holder if possible
// We do need holder support in the simple frontend though as Aegis has
its own
// holder class. I'll tackle refactoring this into a more generic way of
handling
Modified:
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java?view=diff&rev=528981&r1=528980&r2=528981
==============================================================================
---
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
(original)
+++
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
Sun Apr 15 07:04:09 2007
@@ -115,7 +115,7 @@
}
- //FIXME: CXF-519
+ //FIXME: CXF-519, CXF-533
@Test
@Ignore
public void testDocLit() throws Exception {