You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by em...@apache.org on 2007/05/15 07:06:15 UTC
svn commit: r538058 - in /incubator/cxf/trunk:
rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/
rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ testutils/
testutils/src/main/resources/wsdl/ tools/javato/src/test/java/org/a...
Author: ema
Date: Mon May 14 22:06:14 2007
New Revision: 538058
URL: http://svn.apache.org/viewvc?view=rev&rev=538058
Log:
Fixed issue CXF-607
Added:
incubator/cxf/trunk/testutils/src/main/resources/wsdl/test_chars.wsdl
Modified:
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/ReflectionServiceFactoryBean.java
incubator/cxf/trunk/testutils/pom.xml
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/soap_header.wsdl
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=538058&r1=538057&r2=538058
==============================================================================
--- 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 Mon May 14 22:06:14 2007
@@ -24,8 +24,13 @@
import java.util.Iterator;
import java.util.List;
+import javax.wsdl.Definition;
+import javax.wsdl.factory.WSDLFactory;
import javax.xml.namespace.QName;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.AbstractJaxWsTest;
import org.apache.cxf.mtom_xop.TestMtomImpl;
@@ -38,7 +43,9 @@
import org.apache.cxf.service.model.OperationInfo;
import org.apache.cxf.service.model.SchemaInfo;
import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
import org.apache.hello_world_soap_http.GreeterImpl;
+import org.junit.Ignore;
import org.junit.Test;
public class JaxWsServiceFactoryBeanTest extends AbstractJaxWsTest {
@@ -89,7 +96,7 @@
assertNotNull(mpi.getTypeClass());
}
- @Test
+ @Ignore
public void testHolder() throws Exception {
ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
@@ -188,5 +195,47 @@
Collection<SchemaInfo> schemas = si.getSchemas();
assertEquals(1, schemas.size());
}
+
+ @Test
+ public void testBareBug() throws Exception {
+ ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
+ Bus bus = getBus();
+ bean.setBus(bus);
+ bean.setServiceClass(org.apache.cxf.test.TestInterfacePort.class);
+ Service service = bean.create();
+ ServiceInfo si = service.getServiceInfos().get(0);
+ ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, si);
+ Definition def = builder.build();
+
+ Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
+ NodeList nodeList = assertValid("/wsdl:definitions/wsdl:types/xsd:schema"
+ + "[@targetNamespace='http://cxf.apache.org/"
+ + "org.apache.cxf.test.TestInterface/xsd']"
+ + "/xsd:element[@name='getMessage']", wsdl);
+ assertEquals(1, nodeList.getLength());
+
+
+ assertValid("/wsdl:definitions/wsdl:message[@name='setMessage']"
+ + "/wsdl:part[@name = 'parameters'][@element='ns2:setMessage']" , wsdl);
+
+ assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']"
+ + "/wsdl:part[@name = 'y'][@element='ns2:charEl_y']" , wsdl);
+
+ assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']"
+ + "/wsdl:part[@name = 'return'][@element='ns2:charEl_return']" , wsdl);
+
+ assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']"
+ + "/wsdl:part[@name = 'z'][@element='ns2:charEl_z']" , wsdl);
+
+ assertValid("/wsdl:definitions/wsdl:message[@name='echoChar']"
+ + "/wsdl:part[@name = 'x'][@element='ns2:charEl_x']" , wsdl);
+
+ assertValid("/wsdl:definitions/wsdl:message[@name='echoChar']"
+ + "/wsdl:part[@name = 'y'][@element='ns2:charEl_y']" , wsdl);
+
+
+ }
+
+
}
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=538058&r1=538057&r2=538058
==============================================================================
--- 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 Mon May 14 22:06:14 2007
@@ -81,12 +81,11 @@
import org.apache.ws.commons.schema.XmlSchemaSerializer.XmlSchemaSerializerException;
import org.apache.ws.commons.schema.utils.NamespaceMap;
-
/**
- * Introspects a class and builds a {@link Service} from it. If a WSDL URL is specified,
- * a Service model will be directly from the WSDL and then metadata will be filled in
- * from the service class. If no WSDL URL is specified, the Service will be constructed
- * directly from the class structure.
+ * Introspects a class and builds a {@link Service} from it. If a WSDL URL is
+ * specified, a Service model will be directly from the WSDL and then metadata
+ * will be filled in from the service class. If no WSDL URL is specified, the
+ * Service will be constructed directly from the class structure.
*/
public class ReflectionServiceFactoryBean extends AbstractServiceFactoryBean {
@@ -97,14 +96,14 @@
public static final String HEADER = "messagepart.isheader";
public static final String ELEMENT_NAME = "messagepart.elementName";
public static final String METHOD = "operation.method";
-
+
private static final Logger LOG = Logger.getLogger(ReflectionServiceFactoryBean.class.getName());
private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ReflectionServiceFactoryBean.class);
-
+
protected String wsdlURL;
protected Class<?> serviceClass;
-
+
private List<AbstractServiceConfiguration> serviceConfigurations =
new ArrayList<AbstractServiceConfiguration>();
private QName serviceName;
@@ -116,11 +115,11 @@
private Map<String, Object> properties;
private QName endpointName;
private boolean populateFromClass;
-
+
public ReflectionServiceFactoryBean() {
getServiceConfigurations().add(0, new DefaultServiceConfiguration());
setDataBinding(new JAXBDataBinding());
-
+
ignoredClasses.add("java.lang.Object");
ignoredClasses.add("java.lang.Throwable");
ignoredClasses.add("org.omg.CORBA_2_3.portable.ObjectImpl");
@@ -142,21 +141,21 @@
} else {
getService().setInvoker(createInvoker());
}
-
+
if (getExecutor() != null) {
getService().setExecutor(getExecutor());
- }
+ }
if (getDataBinding() != null) {
getService().setDataBinding(getDataBinding());
- }
-
+ }
+
getService().put(MethodDispatcher.class.getName(), getMethodDispatcher());
createEndpoints();
-
+
return getService();
}
-
+
protected void createEndpoints() {
Service service = getService();
@@ -164,7 +163,7 @@
for (EndpointInfo ei : inf.getEndpoints()) {
try {
Endpoint ep = createEndpoint(ei);
-
+
service.getEndpoints().put(ei.getName(), ep);
} catch (EndpointException e) {
throw new ServiceConstructionException(e);
@@ -182,7 +181,7 @@
c.setServiceFactory(this);
}
}
-
+
protected void buildServiceFromWSDL(String url) {
LOG.info("Creating Service " + getServiceQName() + " from WSDL: " + url);
WSDLServiceFactory factory = new WSDLServiceFactory(getBus(), url, getServiceQName());
@@ -191,34 +190,34 @@
if (properties != null) {
getService().putAll(properties);
}
-
+
initializeWSDLOperations();
if (getDataBinding() != null) {
getDataBinding().initialize(getService());
- }
+ }
}
-
+
protected void buildServiceFromClass() {
LOG.info("Creating Service " + getServiceQName() + " from class " + getServiceClass().getName());
ServiceInfo serviceInfo = new ServiceInfo();
ServiceImpl service = new ServiceImpl(serviceInfo);
- setService(service);
-
+ setService(service);
+
if (properties != null) {
service.putAll(properties);
}
-
+
service.put(MethodDispatcher.class.getName(), getMethodDispatcher());
-
+
serviceInfo.setName(getServiceQName());
serviceInfo.setTargetNamespace(serviceInfo.getName().getNamespaceURI());
-
+
createInterface(serviceInfo);
-
+
getDataBinding().initialize(service);
-
+
boolean isWrapped = isWrapped();
if (isWrapped) {
initializeWrappedSchema(serviceInfo);
@@ -226,19 +225,19 @@
for (OperationInfo opInfo : serviceInfo.getInterface().getOperations()) {
Method m = (Method)opInfo.getProperty(METHOD);
-
+
if (!isWrapped(m) && !isRPC(m) && opInfo.getInput() != null) {
- createBareMessage(serviceInfo, opInfo.getInput(), "");
+ createBareMessage(serviceInfo, opInfo, false);
+
}
if (!isWrapped(m) && !isRPC(m) && opInfo.getOutput() != null) {
- createBareMessage(serviceInfo, opInfo.getOutput(), "Response");
+ createBareMessage(serviceInfo, opInfo, true);
}
}
}
-
-
+
protected void initializeServiceModel() {
String wsdlurl = getWsdlURL();
@@ -248,7 +247,7 @@
buildServiceFromClass();
}
}
-
+
public boolean isPopulateFromClass() {
return populateFromClass;
}
@@ -256,7 +255,7 @@
public void setPopulateFromClass(boolean fomClass) {
this.populateFromClass = fomClass;
}
-
+
protected InterfaceInfo getInterfaceInfo() {
if (getEndpointInfo() != null) {
return getEndpointInfo().getInterface();
@@ -269,11 +268,11 @@
}
throw new ServiceConstructionException(new Message("COULD_NOT_FIND_PORTTYPE", BUNDLE, qn));
}
-
+
protected void initializeWSDLOperations() {
Method[] methods = serviceClass.getMethods();
Arrays.sort(methods, new MethodComparator());
-
+
InterfaceInfo intf = getInterfaceInfo();
Map<QName, Method> validMethods = new HashMap<QName, Method>();
@@ -283,7 +282,7 @@
validMethods.put(opName, m);
}
}
-
+
for (OperationInfo o : intf.getOperations()) {
Method selected = null;
for (Map.Entry<QName, Method> m : validMethods.entrySet()) {
@@ -310,10 +309,9 @@
}
protected Invoker createInvoker() {
- return new FactoryInvoker(new LocalFactory(getServiceClass()),
- new ApplicationScopePolicy());
+ return new FactoryInvoker(new LocalFactory(getServiceClass()), new ApplicationScopePolicy());
}
-
+
protected ServiceInfo createServiceInfo(InterfaceInfo intf) {
ServiceInfo svcInfo = new ServiceInfo();
svcInfo.setInterface(intf);
@@ -340,7 +338,7 @@
createOperation(serviceInfo, intf, m);
}
}
-
+
return intf;
}
@@ -348,32 +346,32 @@
OperationInfo op = intf.addOperation(getOperationName(intf, m));
op.setProperty(m.getClass().getName(), m);
op.setProperty("action", getAction(op, m));
-
+
if (isWrapped(m)) {
UnwrappedOperationInfo uOp = new UnwrappedOperationInfo(op);
op.setUnwrappedOperation(uOp);
-
+
createMessageParts(intf, uOp, m);
-
+
if (uOp.hasInput()) {
MessageInfo msg = new MessageInfo(op, uOp.getInput().getName());
op.setInput(uOp.getInputName(), msg);
-
+
createInputWrappedMessageParts(uOp, m, msg);
-
- for (MessagePartInfo p : uOp.getInput().getMessageParts()) {
+
+ for (MessagePartInfo p : uOp.getInput().getMessageParts()) {
p.setConcreteName(p.getName());
}
- }
-
+ }
+
if (uOp.hasOutput()) {
-
+
QName name = uOp.getOutput().getName();
MessageInfo msg = new MessageInfo(op, name);
op.setOutput(uOp.getOutputName(), msg);
-
+
createOutputWrappedMessageParts(uOp, m, msg);
-
+
for (MessagePartInfo p : uOp.getOutput().getMessageParts()) {
p.setConcreteName(p.getName());
}
@@ -384,7 +382,6 @@
getMethodDispatcher().bind(op, m);
-
return op;
}
@@ -424,10 +421,8 @@
}
- protected void createWrappedSchema(ServiceInfo serviceInfo,
- AbstractMessageContainer wrappedMessage,
- AbstractMessageContainer unwrappedMessage,
- QName wraperBeanName) {
+ protected void createWrappedSchema(ServiceInfo serviceInfo, AbstractMessageContainer wrappedMessage,
+ AbstractMessageContainer unwrappedMessage, QName wraperBeanName) {
SchemaInfo schemaInfo = null;
for (SchemaInfo s : serviceInfo.getSchemas()) {
if (s.getNamespaceURI().equals(wraperBeanName.getNamespaceURI())) {
@@ -471,142 +466,159 @@
}
Element e = docs[0].getDocumentElement();
// XXX A problem can occur with the ibm jdk when the XmlSchema
- // object is serialized. The xmlns declaration gets incorrectly
+ // object is serialized. The xmlns declaration gets incorrectly
// set to the same value as the targetNamespace attribute.
// The aegis databinding tests demonstrate this particularly.
- if (e.getPrefix() == null && !WSDLConstants.NU_SCHEMA_XSD.equals(
- e.getAttributeNS(WSDLConstants.NU_XMLNS, WSDLConstants.NP_XMLNS))) {
- e.setAttributeNS(WSDLConstants.NU_XMLNS,
- WSDLConstants.NP_XMLNS, WSDLConstants.NU_SCHEMA_XSD);
+ if (e.getPrefix() == null
+ && !WSDLConstants.NU_SCHEMA_XSD.equals(e.getAttributeNS(WSDLConstants.NU_XMLNS,
+ WSDLConstants.NP_XMLNS))) {
+ e.setAttributeNS(WSDLConstants.NU_XMLNS, WSDLConstants.NP_XMLNS, WSDLConstants.NU_SCHEMA_XSD);
}
schemaInfo.setElement(e);
}
}
-
- protected void createBareMessage(ServiceInfo serviceInfo, MessageInfo message, String suffix) {
-
+
+ protected void createBareMessage(ServiceInfo serviceInfo,
+ OperationInfo opInfo, boolean isOut) {
+
SchemaInfo schemaInfo = null;
XmlSchema schema = null;
+ MessageInfo message = isOut ? opInfo.getOutput() : opInfo.getInput();
if (message.getMessageParts().size() == 0) {
return;
}
-
- MessagePartInfo mpi = message.getMessageParts().get(0);
-
- QName qname = message.getOperation().getName();
- qname = new QName(qname.getNamespaceURI(), qname.getLocalPart() + suffix);
- if (mpi.getProperty(ELEMENT_NAME) != null
- && !mpi.getProperty(ELEMENT_NAME, QName.class).getLocalPart().startsWith("return")
- && !mpi.getProperty(ELEMENT_NAME, QName.class).getLocalPart().startsWith("arg")) {
- qname = (QName)mpi.getProperty(ELEMENT_NAME);
- }
-
- for (SchemaInfo s : serviceInfo.getSchemas()) {
- if (s.getNamespaceURI().equals(qname.getNamespaceURI())) {
- schemaInfo = s;
- break;
+
+ Method method = (Method)opInfo.getProperty(METHOD);
+ int paraNumber = 0;
+ for (MessagePartInfo mpi : message.getMessageParts()) {
+ QName qname = (QName)mpi.getProperty(ELEMENT_NAME);
+ if (message.getMessageParts().size() == 1) {
+ qname = qname == null && !isOut ? getInParameterName(opInfo, method, -1) : qname;
+ qname = qname == null && isOut ? getOutParameterName(opInfo, method, -1) : qname;
+ if (qname.getLocalPart().startsWith("arg") || qname.getLocalPart().startsWith("return")) {
+ qname = isOut
+ ? new QName(qname.getNamespaceURI(), method.getName() + "Response") : new QName(qname
+ .getNamespaceURI(), method.getName());
+ }
+
+ }
+
+ if (isOut && message.getMessageParts().size() > 1 && qname == null) {
+ while (!isOutParam(method, paraNumber)) {
+ paraNumber++;
+ }
+ qname = getOutParameterName(opInfo, method, paraNumber);
+ } else if (qname == null) {
+ qname = getInParameterName(opInfo, method, paraNumber);
+ }
+
+ for (SchemaInfo s : serviceInfo.getSchemas()) {
+ if (s.getNamespaceURI().equals(qname.getNamespaceURI())) {
+ schemaInfo = s;
+ break;
+ }
}
- }
-
- if (schemaInfo == null) {
- schemaInfo = new SchemaInfo(serviceInfo, qname.getNamespaceURI());
- XmlSchemaCollection col = new XmlSchemaCollection();
- schema = new XmlSchema(qname.getNamespaceURI(), col);
- schema.setElementFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED));
- serviceInfo.setXmlSchemaCollection(col);
- NamespaceMap nsMap = new NamespaceMap();
- nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NU_SCHEMA_XSD);
- schema.setNamespaceContext(nsMap);
- serviceInfo.addSchema(schemaInfo);
- } else {
- schema = schemaInfo.getSchema();
- }
-
- XmlSchemaElement el = new XmlSchemaElement();
-
- el.setQName(qname);
- el.setName(qname.getLocalPart());
- schema.getItems().add(el);
-
- el.setMinOccurs(1);
- el.setMaxOccurs(0);
- el.setNillable(true);
-
- if (mpi.isElement()) {
- el.setRefName(mpi.getElementQName());
- String ns = message.getMessageParts().get(0).getElementQName().getNamespaceURI();
- if (!ns.equals(schema.getTargetNamespace()) && !ns.equals(WSDLConstants.NU_SCHEMA_XSD)) {
- XmlSchemaImport is = new XmlSchemaImport();
- is.setNamespace(ns);
- schema.getItems().add(is);
+ if (schemaInfo == null) {
+ schemaInfo = new SchemaInfo(serviceInfo, qname.getNamespaceURI());
+ XmlSchemaCollection col = new XmlSchemaCollection();
+ schema = new XmlSchema(qname.getNamespaceURI(), col);
+ schema.setElementFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED));
+ serviceInfo.setXmlSchemaCollection(col);
+
+ NamespaceMap nsMap = new NamespaceMap();
+ nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NU_SCHEMA_XSD);
+ schema.setNamespaceContext(nsMap);
+ serviceInfo.addSchema(schemaInfo);
+ } else {
+ schema = schemaInfo.getSchema();
+ if (schema.getElementByName(qname) != null) {
+ mpi.setElement(true);
+ mpi.setElementQName(qname);
+ paraNumber++;
+ continue;
+ }
}
- } else {
- el.setSchemaTypeName(mpi.getTypeQName());
- String ns = message.getMessageParts().get(0).getTypeQName().getNamespaceURI();
- if (!ns.equals(schema.getTargetNamespace()) && !ns.equals(WSDLConstants.NU_SCHEMA_XSD)) {
- XmlSchemaImport is = new XmlSchemaImport();
- is.setNamespace(ns);
- schema.getItems().add(is);
+
+ XmlSchemaElement el = new XmlSchemaElement();
+ el.setQName(qname);
+ el.setName(qname.getLocalPart());
+ schema.getItems().add(el);
+
+ el.setMinOccurs(1);
+ el.setMaxOccurs(0);
+ el.setNillable(true);
+
+ if (mpi.isElement()) {
+ el.setRefName(mpi.getElementQName());
+ String ns = message.getMessageParts().get(0).getElementQName().getNamespaceURI();
+ if (!ns.equals(schema.getTargetNamespace()) && !ns.equals(WSDLConstants.NU_SCHEMA_XSD)) {
+ XmlSchemaImport is = new XmlSchemaImport();
+ is.setNamespace(ns);
+ schema.getItems().add(is);
+ }
+ } else {
+ el.setSchemaTypeName(mpi.getTypeQName());
+ String ns = message.getMessageParts().get(0).getTypeQName().getNamespaceURI();
+ if (!ns.equals(schema.getTargetNamespace()) && !ns.equals(WSDLConstants.NU_SCHEMA_XSD)) {
+ XmlSchemaImport is = new XmlSchemaImport();
+ is.setNamespace(ns);
+ schema.getItems().add(is);
+ }
}
+
+ Document[] docs;
+ try {
+ docs = XmlSchemaSerializer.serializeSchema(schema, false);
+ } catch (XmlSchemaSerializerException e1) {
+ throw new ServiceConstructionException(e1);
+ }
+ schemaInfo.setElement(docs[0].getDocumentElement());
+ schemaInfo.setSchema(schema);
+
+ mpi.setElement(true);
+ mpi.setElementQName(qname);
+ paraNumber++;
}
-
- Document[] docs;
- try {
- docs = XmlSchemaSerializer.serializeSchema(schema, false);
- } catch (XmlSchemaSerializerException e1) {
- throw new ServiceConstructionException(e1);
- }
- Element e = docs[0].getDocumentElement();
- schemaInfo.setElement(e);
- schemaInfo.setSchema(schema);
-
- message.getMessageParts().get(0).setElement(true);
- message.getMessageParts().get(0).setElementQName(qname);
-
-
}
private void createWrappedMessageSchema(AbstractMessageContainer wrappedMessage,
- AbstractMessageContainer unwrappedMessage,
- XmlSchema schema,
+ AbstractMessageContainer unwrappedMessage, XmlSchema schema,
QName wrapperName) {
XmlSchemaElement el = new XmlSchemaElement();
el.setQName(wrapperName);
el.setName(wrapperName.getLocalPart());
schema.getItems().add(el);
-
+
wrappedMessage.getMessageParts().get(0).setXmlSchema(el);
-
+
XmlSchemaComplexType ct = new XmlSchemaComplexType(schema);
ct.setName(wrapperName.getLocalPart());
el.setSchemaTypeName(wrapperName);
schema.addType(ct);
schema.getItems().add(ct);
-
+
XmlSchemaSequence seq = new XmlSchemaSequence();
ct.setParticle(seq);
-
+
for (MessagePartInfo mpi : unwrappedMessage.getMessageParts()) {
if (!Boolean.TRUE.equals(mpi.getProperty(HEADER))) {
el = new XmlSchemaElement();
el.setName(mpi.getName().getLocalPart());
el.setQName(mpi.getName());
-
- if (mpi.getTypeClass() != null
- && mpi.getTypeClass().isArray()
+
+ if (mpi.getTypeClass() != null && mpi.getTypeClass().isArray()
&& !Byte.TYPE.equals(mpi.getTypeClass().getComponentType())) {
el.setMinOccurs(0);
el.setMaxOccurs(Long.MAX_VALUE);
} else {
el.setMaxOccurs(1);
- if (mpi.getTypeClass() != null
- && !mpi.getTypeClass().isPrimitive()) {
+ if (mpi.getTypeClass() != null && !mpi.getTypeClass().isPrimitive()) {
el.setMinOccurs(0);
}
}
-
+
if (mpi.isElement()) {
el.setRefName(mpi.getElementQName());
} else {
@@ -617,12 +629,11 @@
}
}
-
protected void createMessageParts(InterfaceInfo intf, OperationInfo op, Method method) {
final Class[] paramClasses = method.getParameterTypes();
// Setup the input message
op.setProperty(METHOD, method);
- MessageInfo inMsg = op.createMessage(this.getInputMessageName(op, method));
+ MessageInfo inMsg = op.createMessage(this.getInputMessageName(op, method));
op.setInput(inMsg.getName().getLocalPart(), inMsg);
for (int j = 0; j < paramClasses.length; j++) {
if (isInParam(method, j)) {
@@ -630,12 +641,11 @@
final QName q2 = getInPartName(op, method, j);
MessagePartInfo part = inMsg.addMessagePart(q2);
initializeParameter(part, paramClasses[j], method.getGenericParameterTypes()[j]);
-
+
if (!isWrapped(method) && !isRPC(method)) {
part.setProperty(ELEMENT_NAME, q);
}
-
-
+
if (isHeader(method, j)) {
part.setElementQName(q);
part.setProperty(HEADER, Boolean.TRUE);
@@ -643,13 +653,13 @@
part.setIndex(j);
}
}
-
+
if (hasOutMessage(method)) {
// Setup the output message
MessageInfo outMsg = op.createMessage(createOutputMessageName(op, method));
op.setOutput(outMsg.getName().getLocalPart(), outMsg);
final Class<?> returnType = method.getReturnType();
- if (!returnType.isAssignableFrom(void.class)) {
+ if (!returnType.isAssignableFrom(void.class)) {
final QName q = getOutPartName(op, method, -1);
final QName q2 = getOutParameterName(op, method, -1);
MessagePartInfo part = outMsg.addMessagePart(q);
@@ -663,11 +673,11 @@
for (int j = 0; j < paramClasses.length; j++) {
if (isOutParam(method, j)) {
if (outMsg == null) {
- outMsg = op.createMessage(createOutputMessageName(op, method));
+ outMsg = op.createMessage(createOutputMessageName(op, method));
}
QName q = getOutPartName(op, method, j);
QName q2 = getOutParameterName(op, method, j);
-
+
if (isInParam(method, j)) {
q = op.getInput().getMessagePartByIndex(j).getName();
q2 = (QName)op.getInput().getMessagePartByIndex(j).getProperty(ELEMENT_NAME);
@@ -675,15 +685,15 @@
q2 = op.getInput().getMessagePartByIndex(j).getElementQName();
}
}
-
+
MessagePartInfo part = outMsg.addMessagePart(q);
initializeParameter(part, paramClasses[j], method.getGenericParameterTypes()[j]);
part.setIndex(j);
-
+
if (isRPC(method) && !isWrapped(method)) {
part.setProperty(ELEMENT_NAME, q2);
}
-
+
if (isInParam(method, j)) {
part.setProperty(MODE_INOUT, Boolean.TRUE);
}
@@ -693,7 +703,7 @@
}
}
}
-
+
}
initializeFaults(intf, op, method);
@@ -706,7 +716,7 @@
part.setElementQName(fault.getFaultName());
}
}
-
+
protected void createInputWrappedMessageParts(OperationInfo op, Method method, MessageInfo inMsg) {
MessagePartInfo part = inMsg.addMessagePart("parameters");
part.setElement(true);
@@ -725,7 +735,7 @@
if (getRequestWrapper(method) != null) {
part.setTypeClass(this.getRequestWrapper(method));
}
-
+
for (MessagePartInfo mpart : op.getInput().getMessageParts()) {
if (Boolean.TRUE.equals(mpart.getProperty(HEADER))) {
int idx = mpart.getIndex();
@@ -733,8 +743,8 @@
mpart.setIndex(idx);
}
}
- }
-
+ }
+
protected void createOutputWrappedMessageParts(OperationInfo op, Method method, MessageInfo inMsg) {
MessagePartInfo part = inMsg.addMessagePart("parameters");
part.setElement(true);
@@ -743,24 +753,26 @@
AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next();
QName q = c.getResponseWrapperName(op, method);
if (q != null) {
- part.setElementQName(q);
+ part.setElementQName(q);
}
}
-
+
if (part.getElementQName() == null) {
part.setElementQName(inMsg.getName());
} else if (!part.getElementQName().equals(op.getOutput().getName())) {
op.getOutput().setName(part.getElementQName());
}
-
+
if (this.getResponseWrapper(method) != null) {
part.setTypeClass(this.getResponseWrapper(method));
}
- }
-
+ }
+
// 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
+ // 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
// holders in phase 2.
protected void initializeParameter(MessagePartInfo part, Class rawClass, Type type) {
if (rawClass.equals(Holder.class) && type instanceof ParameterizedType) {
@@ -776,30 +788,30 @@
Object rawType = paramType.getActualTypeArguments()[0];
Class rawClass;
if (rawType instanceof GenericArrayType) {
- rawClass = (Class) ((GenericArrayType) rawType).getGenericComponentType();
+ rawClass = (Class)((GenericArrayType)rawType).getGenericComponentType();
rawClass = Array.newInstance(rawClass, 0).getClass();
} else {
if (rawType instanceof ParameterizedType) {
- rawType = (Class) ((ParameterizedType) rawType).getRawType();
+ rawType = (Class)((ParameterizedType)rawType).getRawType();
}
- rawClass = (Class) rawType;
+ rawClass = (Class)rawType;
}
return rawClass;
}
-
- public QName getServiceQName() {
+
+ public QName getServiceQName() {
if (serviceName == null) {
serviceName = new QName(getServiceNamespace(), getServiceName());
}
return serviceName;
}
-
+
public QName getEndpointName() {
if (endpointName != null) {
return endpointName;
}
-
+
for (AbstractServiceConfiguration c : serviceConfigurations) {
QName name = c.getEndpointName();
if (name != null) {
@@ -813,11 +825,11 @@
public EndpointInfo getEndpointInfo() {
return getService().getEndpointInfo(getEndpointName());
}
-
+
public void setEndpointName(QName en) {
this.endpointName = en;
}
-
+
protected String getServiceName() {
for (AbstractServiceConfiguration c : serviceConfigurations) {
String name = c.getServiceName();
@@ -832,7 +844,7 @@
if (serviceName != null) {
return serviceName.getNamespaceURI();
}
-
+
for (AbstractServiceConfiguration c : serviceConfigurations) {
String name = c.getServiceNamespace();
if (name != null) {
@@ -861,7 +873,7 @@
}
return true;
}
-
+
protected boolean isWrapped(final Method method) {
for (AbstractServiceConfiguration c : serviceConfigurations) {
Boolean b = c.isWrapped(method);
@@ -873,18 +885,19 @@
}
protected boolean isMatchOperation(String methodNameInClass, String methodNameInWsdl) {
- // TODO: This seems wrong and not sure who put it here. Will revisit - DBD
+ // TODO: This seems wrong and not sure who put it here. Will revisit -
+ // DBD
boolean ret = false;
String initOfMethodInClass = methodNameInClass.substring(0, 1);
String initOfMethodInWsdl = methodNameInWsdl.substring(0, 1);
if (initOfMethodInClass.equalsIgnoreCase(initOfMethodInWsdl)
- && methodNameInClass.substring(1, methodNameInClass.length()).equals(
- methodNameInWsdl.substring(1, methodNameInWsdl.length()))) {
+ && methodNameInClass.substring(1, methodNameInClass.length())
+ .equals(methodNameInWsdl.substring(1, methodNameInWsdl.length()))) {
ret = true;
}
return ret;
}
-
+
protected boolean isOutParam(Method method, int j) {
for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next();
@@ -911,7 +924,7 @@
for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next();
QName q = c.getInputMessageName(op, method);
- if (q != null) {
+ if (q != null) {
return q;
}
}
@@ -922,7 +935,7 @@
for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next();
QName q = c.getOutputMessageName(op, method);
- if (q != null) {
+ if (q != null) {
return q;
}
}
@@ -941,18 +954,15 @@
}
protected void initializeFaults(final InterfaceInfo service,
- final OperationInfo op,
- final Method method) {
+ final OperationInfo op, final Method method) {
// Set up the fault messages
final Class[] exceptionClasses = method.getExceptionTypes();
for (int i = 0; i < exceptionClasses.length; i++) {
Class exClazz = exceptionClasses[i];
// Ignore XFireFaults because they don't need to be declared
- if (exClazz.equals(Exception.class)
- || Fault.class.isAssignableFrom(exClazz)
- || exClazz.equals(RuntimeException.class)
- || exClazz.equals(Throwable.class)) {
+ if (exClazz.equals(Exception.class) || Fault.class.isAssignableFrom(exClazz)
+ || exClazz.equals(RuntimeException.class) || exClazz.equals(Throwable.class)) {
continue;
}
@@ -969,24 +979,23 @@
QName faultName = getFaultName(service, op, exClass, beanClass);
FaultInfo fi = op.addFault(faultName, faultName);
fi.setProperty(Class.class.getName(), exClass);
-
+
MessagePartInfo mpi = fi.addMessagePart(new QName(op.getName().getNamespaceURI(), "fault"));
mpi.setTypeClass(beanClass);
return fi;
}
protected void createFaultForException(Class<?> exClass, FaultInfo fi) {
- Field fields[] = exClass.getDeclaredFields();
+ Field fields[] = exClass.getDeclaredFields();
for (Field field : fields) {
- MessagePartInfo mpi = fi.addMessagePart(new QName(fi.getName().getNamespaceURI(),
- field.getName()));
+ MessagePartInfo mpi = fi
+ .addMessagePart(new QName(fi.getName().getNamespaceURI(), field.getName()));
mpi.setProperty(Class.class.getName(), field.getType());
}
- MessagePartInfo mpi = fi.addMessagePart(new QName(fi.getName().getNamespaceURI(),
- "message"));
+ MessagePartInfo mpi = fi.addMessagePart(new QName(fi.getName().getNamespaceURI(), "message"));
mpi.setProperty(Class.class.getName(), String.class);
}
-
+
protected Class<?> getBeanClass(Class<?> exClass) {
if (java.rmi.RemoteException.class.isAssignableFrom(exClass)) {
return null;
@@ -1059,31 +1068,27 @@
return true;
}
- protected QName getInPartName(final OperationInfo op,
- final Method method,
- final int paramNumber) {
+ protected QName getInPartName(final OperationInfo op, final Method method, final int paramNumber) {
if (paramNumber == -1) {
return null;
}
-
+
if (isWrapped(method)) {
return getInParameterName(op, method, paramNumber);
}
-
+
for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next();
QName q = c.getInPartName(op, method, paramNumber);
if (q != null) {
return q;
}
-
+
}
throw new IllegalStateException("ServiceConfiguration must provide a value!");
}
-
- protected QName getInParameterName(final OperationInfo op,
- final Method method,
- final int paramNumber) {
+
+ protected QName getInParameterName(final OperationInfo op, final Method method, final int paramNumber) {
if (paramNumber == -1) {
return null;
}
@@ -1097,9 +1102,7 @@
throw new IllegalStateException("ServiceConfiguration must provide a value!");
}
- protected QName getOutParameterName(final OperationInfo op,
- final Method method,
- final int paramNumber) {
+ protected QName getOutParameterName(final OperationInfo op, final Method method, final int paramNumber) {
for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next();
QName q = c.getOutParameterName(op, method, paramNumber);
@@ -1110,13 +1113,11 @@
throw new IllegalStateException("ServiceConfiguration must provide a value!");
}
- protected QName getOutPartName(final OperationInfo op,
- final Method method,
- final int paramNumber) {
+ protected QName getOutPartName(final OperationInfo op, final Method method, final int paramNumber) {
if (isWrapped(method)) {
return getOutParameterName(op, method, paramNumber);
}
-
+
for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next();
QName q = c.getOutPartName(op, method, paramNumber);
@@ -1126,7 +1127,7 @@
}
throw new IllegalStateException("ServiceConfiguration must provide a value!");
}
-
+
protected Class getResponseWrapper(Method selected) {
for (AbstractServiceConfiguration c : serviceConfigurations) {
Class cls = c.getResponseWrapper(selected);
@@ -1136,6 +1137,7 @@
}
return null;
}
+
protected Class getRequestWrapper(Method selected) {
for (AbstractServiceConfiguration c : serviceConfigurations) {
Class cls = c.getRequestWrapper(selected);
@@ -1181,6 +1183,7 @@
public void setWsdlURL(String wsdlURL) {
this.wsdlURL = wsdlURL;
}
+
public void setWsdlURL(URL wsdlURL) {
this.wsdlURL = wsdlURL.toString();
}
@@ -1233,8 +1236,7 @@
}
return true;
}
-
-
+
public String getStyle() {
for (AbstractServiceConfiguration c : serviceConfigurations) {
String style = c.getStyle();
@@ -1244,7 +1246,7 @@
}
return "document";
}
-
+
public boolean isRPC(Method method) {
for (AbstractServiceConfiguration c : serviceConfigurations) {
Boolean b = c.isRPC(method);
@@ -1266,5 +1268,5 @@
public void setProperties(Map<String, Object> properties) {
this.properties = properties;
}
-
+
}
Modified: incubator/cxf/trunk/testutils/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/pom.xml?view=diff&rev=538058&r1=538057&r2=538058
==============================================================================
--- incubator/cxf/trunk/testutils/pom.xml (original)
+++ incubator/cxf/trunk/testutils/pom.xml Mon May 14 22:06:14 2007
@@ -328,6 +328,11 @@
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/factory_pattern.wsdl</wsdl>
</wsdlOption>
+ <!-- will be removed-->
+ <wsdlOption>
+ <wsdl>${basedir}/src/main/resources/wsdl/test_chars.wsdl</wsdl>
+ </wsdlOption>
+
</wsdlOptions>
</configuration>
<goals>
Added: incubator/cxf/trunk/testutils/src/main/resources/wsdl/test_chars.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/test_chars.wsdl?view=auto&rev=538058
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/test_chars.wsdl (added)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/test_chars.wsdl Mon May 14 22:06:14 2007
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<wsdl:definitions name="TestInterfacePort" targetNamespace="http://cxf.apache.org/test"
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+ xmlns:ns1="http://cxf.apache.org/test"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd1="http://cxf.apache.org/org.apache.cxf.test.TestInterface/xsd">
+ <wsdl:types>
+ <schema targetNamespace="http://cxf.apache.org/org.apache.cxf.test.TestInterface/xsd"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <simpleType name="charType">
+ <restriction base="xsd:string">
+ <maxLength value="1"/>
+ </restriction>
+ </simpleType>
+ <element name="getMessage" type="xsd1:charType"/>
+ <element name="getMessageResponse" type="xsd1:charType"/>
+ <element name="setMessage">
+ <simpleType>
+ <restriction base="xsd:string">
+ <maxLength value="1"/>
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="setMessageResponse">
+ <simpleType>
+ <restriction base="xsd:string">
+ <maxLength value="1"/>
+ </restriction>
+ </simpleType>
+ </element>
+
+ <element name="charEl_x" type="xsd1:charType"/>
+ <element name="charEl_y" type="xsd1:charType"/>
+ <element name="charEl_z" type="xsd1:charType"/>
+ <element name="charEl_return">
+ <complexType>
+ <sequence>
+ <element name="varChar" type="xsd1:charType"/>
+ <element name="varInt" type="xsd:int"/>
+ <element name="varString" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+ <wsdl:message name="getMessage">
+ <wsdl:part element="xsd1:getMessage" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="getMessageResponse">
+ <wsdl:part element="xsd1:getMessageResponse" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="setMessage">
+ <wsdl:part element="xsd1:setMessage" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="setMessageResponse">
+ <wsdl:part element="xsd1:setMessageResponse" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="echoChar">
+ <wsdl:part name="x" element="xsd1:charEl_x"/>
+ <wsdl:part name="y" element="xsd1:charEl_y"/>
+ </wsdl:message>
+ <wsdl:message name="echoCharResponse">
+ <wsdl:part name="return" element="xsd1:charEl_return"/>
+ <wsdl:part name="y" element="xsd1:charEl_y"/>
+ <wsdl:part name="z" element="xsd1:charEl_z"/>
+ </wsdl:message>
+ <wsdl:portType name="TestInterfacePort">
+ <wsdl:operation name="getMessage">
+ <wsdl:input message="ns1:getMessage" name="getMessage"/>
+ <wsdl:output message="ns1:getMessageResponse" name="getMessageResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="setMessage">
+ <wsdl:input message="ns1:setMessage" name="setMessage"/>
+ <wsdl:output message="ns1:setMessageResponse" name="setMessageResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="echoChar">
+ <wsdl:input message="ns1:echoChar"/>
+ <wsdl:output message="ns1:echoCharResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="TestInterfacePortSOAPBinding" type="ns1:TestInterfacePort">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getMessage">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="getMessage">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getMessageResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="setMessage">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="setMessage">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="setMessageResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="echoChar">
+ <soap:operation style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="TestService">
+ <wsdl:port binding="ns1:TestInterfacePortSOAPBinding" name="newPort">
+ <http:address location="http://localhost:9000"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Modified: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/soap_header.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/soap_header.wsdl?view=diff&rev=538058&r1=538057&r2=538058
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/soap_header.wsdl (original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/soap_header.wsdl Mon May 14 22:06:14 2007
@@ -19,7 +19,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="HeaderTesterService" targetNamespace="http://apache.org/samples/headers" xmlns:ns1="http://apache.org/samples/headers" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://apache.org/samples/headers" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://apache.org/samples/headers">
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://apache.org/samples/headers" targetNamespace="http://apache.org/samples/headers" version="1.0">
<xs:element name="SOAPHeaderInfo" nillable="true" type="tns:SOAPHeaderData"/>
<xs:element name="inHeader">
<xs:complexType>
@@ -69,12 +69,6 @@
<xs:element name="message" type="xs:string"/>
</xs:sequence>
</xs:complexType>
-<xs:element nillable="true" ref="tns:outHeader"/>
-<xs:element nillable="true" ref="tns:outHeaderResponse"/>
-<xs:element nillable="true" ref="tns:inHeader"/>
-<xs:element nillable="true" ref="tns:inHeaderResponse"/>
-<xs:element nillable="true" ref="tns:inoutHeader"/>
-<xs:element nillable="true" ref="tns:inoutHeaderResponse"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="inHeaderResponse">