Author: dkulp
Date: Fri Oct 12 18:27:52 2007
New Revision: 584358
URL: http://svn.apache.org/viewvc?rev=584358&view=rev
Log:
Make sure faults use elements, not types
Fix Aegis not reporting that it supports Nodes
Wire XmlSchema types into parts for Aegis
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/OperationInfo.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/AbstractDataBinding.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/exception/ExceptionTest.java
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/OperationInfo.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/OperationInfo.java?rev=584358&r1=584357&r2=584358&view=diff
==============================================================================
---
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/OperationInfo.java
(original)
+++
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/OperationInfo.java
Fri Oct 12 18:27:52 2007
@@ -181,6 +181,10 @@
}
return null;
}
+
+ public boolean hasFaults() {
+ return faults != null && faults.size() > 0;
+ }
/**
* Returns all faults for this operation.
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/AbstractDataBinding.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/AbstractDataBinding.java?rev=584358&r1=584357&r2=584358&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/AbstractDataBinding.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/AbstractDataBinding.java
Fri Oct 12 18:27:52 2007
@@ -46,7 +46,7 @@
}
- protected void addSchemaDocument(ServiceInfo serviceInfo,
+ protected XmlSchema addSchemaDocument(ServiceInfo serviceInfo,
XmlSchemaCollection col,
Document d,
String systemId) {
@@ -73,5 +73,6 @@
XmlSchema xmlSchema = col.read(d.getDocumentElement());
schema.setSchema(xmlSchema);
serviceInfo.addSchema(schema);
+ return xmlSchema;
}
}
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java?rev=584358&r1=584357&r2=584358&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
Fri Oct 12 18:27:52 2007
@@ -132,7 +132,7 @@
private boolean isDOMSupported(DataBinding db) {
boolean supportsDOM = false;
- for (Class c : db.getSupportedWriterFormats()) {
+ for (Class c : db.getSupportedReaderFormats()) {
if (c.equals(Node.class)) {
supportsDOM = true;
}
Modified:
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java?rev=584358&r1=584357&r2=584358&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
(original)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
Fri Oct 12 18:27:52 2007
@@ -45,9 +45,10 @@
import org.apache.cxf.aegis.type.basic.BeanType;
import org.apache.cxf.aegis.util.XmlConstants;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.apache.cxf.databinding.AbstractDataBinding;
+import org.apache.cxf.databinding.DataBinding;
import org.apache.cxf.databinding.DataReader;
import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.databinding.source.AbstractDataBinding;
import org.apache.cxf.frontend.MethodDispatcher;
import org.apache.cxf.frontend.SimpleMethodDispatcher;
import org.apache.cxf.service.Service;
@@ -56,10 +57,11 @@
import org.apache.cxf.service.model.FaultInfo;
import org.apache.cxf.service.model.MessagePartInfo;
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.wsdl.WSDLConstants;
+import org.apache.cxf.wsdl11.WSDLServiceBuilder;
import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaAnnotated;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.utils.NamespaceMap;
import org.jdom.Attribute;
@@ -74,7 +76,7 @@
* <p>
* NOTE: There is an assumed 1:1 mapping between an AegisDatabinding and a
Service!
*/
-public class AegisDatabinding extends AbstractDataBinding {
+public class AegisDatabinding extends AbstractDataBinding implements
DataBinding {
public static final String CURRENT_MESSAGE_PART = "currentMessagePart";
public static final String TYPE_MAPPING_KEY = "type.mapping";
@@ -125,7 +127,7 @@
}
public Class<?>[] getSupportedWriterFormats() {
- return new Class[] {XMLStreamWriter.class};
+ return new Class[] {XMLStreamWriter.class, Node.class};
}
public TypeMappingRegistry getTypeMappingRegistry() {
@@ -168,6 +170,15 @@
}
createSchemas(s, deps);
+ for (ServiceInfo info : s.getServiceInfos()) {
+ for (OperationInfo opInfo : info.getInterface().getOperations()) {
+ if (opInfo.isUnwrappedCapable()) {
+ initializeOperationTypes(info,
opInfo.getUnwrappedOperation());
+ } else {
+ initializeOperationTypes(info, opInfo);
+ }
+ }
+ }
}
List<Type> getAdditionalTypes(Service s, TypeMapping tm) {
@@ -220,6 +231,23 @@
throw e;
}
}
+ private void initializeOperationTypes(ServiceInfo s, OperationInfo opInfo)
{
+ try {
+ initializeMessageTypes(s, opInfo.getInput(), IN_PARAM);
+
+ if (opInfo.hasOutput()) {
+ initializeMessageTypes(s, opInfo.getOutput(), OUT_PARAM);
+ }
+
+ for (FaultInfo info : opInfo.getFaults()) {
+ initializeMessageTypes(s, info, FAULT_PARAM);
+ }
+
+ } catch (DatabindingException e) {
+ e.prepend("Error initializing parameters for operation " +
opInfo.getName());
+ throw e;
+ }
+ }
protected void initializeMessage(Service s, TypeMapping serviceTM,
AbstractMessageContainer container,
@@ -244,6 +272,21 @@
}
}
+ protected void initializeMessageTypes(ServiceInfo s,
+ AbstractMessageContainer container,
+ int partType) {
+ XmlSchemaCollection col = s.getXmlSchemaCollection();
+ for (Iterator itr = container.getMessageParts().iterator();
itr.hasNext();) {
+ MessagePartInfo part = (MessagePartInfo)itr.next();
+ if (part.isElement()) {
+ XmlSchemaAnnotated tp =
col.getElementByQName(part.getElementQName());
+ part.setXmlSchema(tp);
+ } else {
+ XmlSchemaAnnotated tp =
col.getTypeByQName(part.getTypeQName());
+ part.setXmlSchema(tp);
+ }
+ }
+ }
private void addDependencies(Set<Type> deps, Type type) {
Set<Type> typeDeps = type.getDependencies();
if (typeDeps != null) {
@@ -268,6 +311,19 @@
}
types.add(t);
}
+ for (ServiceInfo si : s.getServiceInfos()) {
+ XmlSchemaCollection col = (XmlSchemaCollection)si
+ .getProperty(WSDLServiceBuilder.WSDL_SCHEMA_LIST);
+
+ if (col != null) {
+ // someone has already filled in the types
+ continue;
+ }
+
+ col = new XmlSchemaCollection();
+ si.setProperty(WSDLServiceBuilder.WSDL_SCHEMA_LIST, col);
+ si.setXmlSchemaCollection(col);
+ }
for (Map.Entry<String, Set<Type>> entry : tns2Type.entrySet()) {
String xsdPrefix = XmlConstants.XSD_PREFIX;
@@ -305,7 +361,6 @@
}
try {
- XmlSchemaCollection col = new XmlSchemaCollection();
NamespaceMap nsMap = new NamespaceMap();
nsMap.add(xsdPrefix, XmlConstants.XSD);
@@ -319,26 +374,18 @@
nsMap.add(n.getPrefix(), n.getURI());
}
}
-
- col.setNamespaceContext(nsMap);
org.w3c.dom.Document schema = new DOMOutputter().output(new
Document(e));
for (ServiceInfo si : s.getServiceInfos()) {
- SchemaInfo info = new SchemaInfo(si, entry.getKey());
-
- info.setElement(schema.getDocumentElement());
-
- XmlSchema xmlSchema =
col.read(schema.getDocumentElement());
+ XmlSchemaCollection col = (XmlSchemaCollection)si
+ .getProperty(WSDLServiceBuilder.WSDL_SCHEMA_LIST);
+ col.setNamespaceContext(nsMap);
+ XmlSchema xmlSchema = addSchemaDocument(si, col, schema,
entry.getKey());
// Work around bug in JDOM DOMOutputter which fails to
correctly
// assign namespaces to attributes. If JDOM worked right,
// the collection object would get the prefixes for itself.
xmlSchema.setNamespaceContext(nsMap);
- info.setSchema(xmlSchema);
-
- info.setSystemId(entry.getKey());
-
- si.addSchema(info);
}
} catch (JDOMException e1) {
throw new ServiceConstructionException(e1);
@@ -455,7 +502,6 @@
* Provide explicit mappings to ReflectionServiceFactory.
* [EMAIL PROTECTED]
* */
- @Override
public Map<String, String> getDeclaredNamespaceMappings() {
return this.namespaceMap;
}
Modified:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/exception/ExceptionTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/exception/ExceptionTest.java?rev=584358&r1=584357&r2=584358&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/exception/ExceptionTest.java
(original)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/exception/ExceptionTest.java
Fri Oct 12 18:27:52 2007
@@ -18,6 +18,8 @@
*/
package org.apache.cxf.aegis.exception;
+import org.w3c.dom.Document;
+
import org.apache.cxf.aegis.AbstractAegisTest;
import org.apache.cxf.aegis.databinding.AegisDatabinding;
import org.apache.cxf.endpoint.Server;
@@ -55,6 +57,13 @@
} catch (HelloException e) {
// nothing
}
+
+ //check to make sure the fault is an element
+ Document wsdl = getWSDLDocument("ExceptionService");
+ addNamespace("tns", "http://exception.aegis.cxf.apache.org");
+ assertValid("//wsdl:[EMAIL PROTECTED]'HelloException']/wsdl:[EMAIL
PROTECTED]'HelloException']"
+ + "[EMAIL PROTECTED]'tns:String']",
+ wsdl);
}
@Test(expected = HelloException.class)
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?rev=584358&r1=584357&r2=584358&view=diff
==============================================================================
---
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
Fri Oct 12 18:27:52 2007
@@ -253,7 +253,6 @@
if (!isWrapped(m) && !isRPC(m) && opInfo.getInput() != null) {
createBareMessage(serviceInfo, opInfo, false);
-
}
if (!isWrapped(m) && !isRPC(m) && opInfo.getOutput() != null) {
@@ -447,7 +446,7 @@
mpi.setElementQName(qn);
- checkForHeaderElement(serviceInfo, mpi);
+ checkForElement(serviceInfo, mpi);
}
}
@@ -475,7 +474,19 @@
mpi.setElement(true);
mpi.setElementQName(qn);
- checkForHeaderElement(serviceInfo, mpi);
+ checkForElement(serviceInfo, mpi);
+ }
+ }
+ }
+ if (op.hasFaults()) {
+ //check to make sure the faults are elements
+ for (FaultInfo fault : op.getFaults()) {
+ QName qn = (QName)fault.getProperty("elementName");
+ MessagePartInfo part = fault.getMessagePart(0);
+ if (!part.isElement()) {
+ part.setElement(true);
+ part.setElementQName(qn);
+ checkForElement(serviceInfo, part);
}
}
}
@@ -484,7 +495,7 @@
}
- protected void checkForHeaderElement(ServiceInfo serviceInfo,
MessagePartInfo mpi) {
+ protected void checkForElement(ServiceInfo serviceInfo, MessagePartInfo
mpi) {
for (SchemaInfo s : serviceInfo.getSchemas()) {
XmlSchemaElement e = s.getElementByQName(mpi.getElementQName());
if (e != null) {
@@ -1484,7 +1495,7 @@
return b.booleanValue();
}
}
- return true;
+ return "rpc".equals(getStyle());
}
public void setWrapped(boolean style) {