Author: ema
Date: Thu Sep 29 10:47:58 2011
New Revision: 1177259
URL: http://svn.apache.org/viewvc?rev=1177259&view=rev
Log:
Merged revisions 1177188,1177247-1177248 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1177188 | ema | 2011-09-29 15:32:52 +0800 (Thu, 29 Sep 2011) | 1 line
[CXF-1519]:Repspect @XmlType annotation in exceptoin class
........
r1177247 | ema | 2011-09-29 18:00:56 +0800 (Thu, 29 Sep 2011) | 1 line
[CXF-1519]:Fix jdk15 build
........
r1177248 | ema | 2011-09-29 18:05:45 +0800 (Thu, 29 Sep 2011) | 1 line
[CXF-2006]:Check UnknownExtensibilityElement when RespectBindingFeature is
enalbed
........
Added:
cxf/branches/2.4.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/
- copied from r1177248,
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/
cxf/branches/2.4.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/RespectBindingFeatureClientServerTest.java
- copied unchanged from r1177248,
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/RespectBindingFeatureClientServerTest.java
cxf/branches/2.4.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/Server.java
- copied unchanged from r1177248,
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/cxf2006/Server.java
cxf/branches/2.4.x-fixes/systests/uncategorized/src/test/resources/wsdl_systest/cxf2006.wsdl
- copied unchanged from r1177248,
cxf/trunk/systests/uncategorized/src/test/resources/wsdl_systest/cxf2006.wsdl
cxf/branches/2.4.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf1519/
- copied from r1177188,
cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf1519/
cxf/branches/2.4.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf1519/Endpoint.java
- copied unchanged from r1177188,
cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf1519/Endpoint.java
cxf/branches/2.4.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf1519/EndpointImpl.java
- copied unchanged from r1177188,
cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf1519/EndpointImpl.java
cxf/branches/2.4.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf1519/UserException.java
- copied unchanged from r1177188,
cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf1519/UserException.java
Modified:
cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
cxf/branches/2.4.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Modified:
cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java?rev=1177259&r1=1177258&r2=1177259&view=diff
==============================================================================
---
cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
(original)
+++
cxf/branches/2.4.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
Thu Sep 29 10:47:58 2011
@@ -34,6 +34,7 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlList;
+import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.namespace.QName;
@@ -42,6 +43,7 @@ import org.apache.cxf.common.WSDLConstan
import org.apache.cxf.common.i18n.Message;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.ReflectionInvokationHandler;
+import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.common.xmlschema.SchemaCollection;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.service.ServiceModelVisitor;
@@ -448,8 +450,8 @@ class JAXBSchemaInitializer extends Serv
}
}
}
-
-
+
+
private void buildExceptionType(MessagePartInfo part, Class<?> cls) {
SchemaInfo schemaInfo = null;
for (SchemaInfo s : serviceInfo.getSchemas()) {
@@ -458,44 +460,53 @@ class JAXBSchemaInitializer extends Serv
break;
}
}
- XmlSchema schema;
+ XmlType xmlTypeAnno = cls.getAnnotation(XmlType.class);
+ boolean respectXmlTypeNS = false;
+ XmlSchema faultBeanSchema = null;
+ if (xmlTypeAnno != null &&
!StringUtils.isEmpty(xmlTypeAnno.namespace())
+ &&
!xmlTypeAnno.namespace().equals(part.getElementQName().getNamespaceURI())) {
+ respectXmlTypeNS = true;
+ NamespaceMap nsMap = new NamespaceMap();
+ nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX,
xmlTypeAnno.namespace());
+ nsMap.add(WSDLConstants.NP_SCHEMA_XSD,
WSDLConstants.NS_SCHEMA_XSD);
+
+ SchemaInfo faultBeanSchemaInfo =
createSchemaIfNeeded(xmlTypeAnno.namespace(), nsMap);
+ faultBeanSchema = faultBeanSchemaInfo.getSchema();
+ }
+
+ XmlSchema schema = null;
if (schemaInfo == null) {
- schema =
schemas.newXmlSchemaInCollection(part.getElementQName().getNamespaceURI());
-
- if (qualifiedSchemas) {
- schema.setElementFormDefault(XmlSchemaForm.QUALIFIED);
- }
-
NamespaceMap nsMap = new NamespaceMap();
- nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX,
schema.getTargetNamespace());
+ nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX,
part.getElementQName().getNamespaceURI());
nsMap.add(WSDLConstants.NP_SCHEMA_XSD,
WSDLConstants.NS_SCHEMA_XSD);
- schema.setNamespaceContext(nsMap);
+ schemaInfo =
createSchemaIfNeeded(part.getElementQName().getNamespaceURI(), nsMap);
-
- schemaInfo = new
SchemaInfo(part.getElementQName().getNamespaceURI());
- schemaInfo.setSchema(schema);
- serviceInfo.addSchema(schemaInfo);
- } else {
- schema = schemaInfo.getSchema();
- }
+ }
+ schema = schemaInfo.getSchema();
+
// Before updating everything, make sure we haven't added this
// type yet. Multiple methods that throw the same exception
// types will cause duplicates.
- String partLocalName = part.getElementQName().getLocalPart();
- XmlSchemaType existingType = schema.getTypeByName(partLocalName);
+ String faultTypeName = xmlTypeAnno != null &&
!StringUtils.isEmpty(xmlTypeAnno.name())
+ ? xmlTypeAnno.name() : part.getElementQName().getLocalPart();
+ XmlSchemaType existingType = schema.getTypeByName(faultTypeName);
if (existingType != null) {
return;
}
- XmlSchemaComplexType ct = new XmlSchemaComplexType(schema, true);
- ct.setName(partLocalName);
-
XmlSchemaElement el = new XmlSchemaElement(schema, true);
- el.setName(partLocalName);
+ el.setName(part.getElementQName().getLocalPart());
part.setXmlSchema(el);
-
schemaInfo.setElement(null);
+
+ if (respectXmlTypeNS) {
+ schema = faultBeanSchema; //create complexType in the new created
schema for xmlType
+ }
+
+ XmlSchemaComplexType ct = new XmlSchemaComplexType(schema, true);
+ ct.setName(faultTypeName);
+
el.setSchemaTypeName(ct.getQName());
XmlSchemaSequence seq = new XmlSchemaSequence();
@@ -542,6 +553,7 @@ class JAXBSchemaInitializer extends Serv
seq.getItems().add(exEle);
}
+ schemas.addCrossImports();
part.setProperty(JAXBDataBinding.class.getName() +
".CUSTOM_EXCEPTION", Boolean.TRUE);
}
@@ -591,7 +603,24 @@ class JAXBSchemaInitializer extends Serv
seq.getItems().add(el);
}
+
+ private SchemaInfo createSchemaIfNeeded(String namespace, NamespaceMap
nsMap) {
+ SchemaInfo schemaInfo = serviceInfo.getSchema(namespace);
+ if (schemaInfo == null) {
+ XmlSchema xmlSchema = schemas.newXmlSchemaInCollection(namespace);
+ if (qualifiedSchemas) {
+ xmlSchema.setElementFormDefault(XmlSchemaForm.QUALIFIED);
+ }
+
+ xmlSchema.setNamespaceContext(nsMap);
+
+ schemaInfo = new SchemaInfo(namespace);
+ schemaInfo.setSchema(xmlSchema);
+ serviceInfo.addSchema(schemaInfo);
+ }
+ return schemaInfo;
+ }
private boolean isExistSchemaElement(XmlSchema schema, QName qn) {
return schema.getElementByName(qn) != null;
Modified:
cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java?rev=1177259&r1=1177258&r2=1177259&view=diff
==============================================================================
---
cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
(original)
+++
cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
Thu Sep 29 10:47:58 2011
@@ -23,6 +23,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.logging.Logger;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.ExtensionRegistry;
@@ -30,7 +31,9 @@ import javax.wsdl.extensions.UnknownExte
import javax.xml.namespace.QName;
import javax.xml.transform.dom.DOMSource;
import javax.xml.ws.Binding;
+import javax.xml.ws.RespectBindingFeature;
import javax.xml.ws.Service.Mode;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.soap.Addressing;
import javax.xml.ws.soap.AddressingFeature;
@@ -46,6 +49,7 @@ import org.apache.cxf.binding.soap.saaj.
import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
import org.apache.cxf.binding.xml.XMLBinding;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.endpoint.EndpointException;
import org.apache.cxf.endpoint.EndpointImpl;
import org.apache.cxf.feature.AbstractFeature;
@@ -95,6 +99,8 @@ import org.apache.neethi.Constants;
*
*/
public class JaxWsEndpointImpl extends EndpointImpl {
+
+ private static final Logger LOG =
LogUtils.getL7dLogger(JaxWsEndpointImpl.class);
private Binding jaxwsBinding;
private JaxWsImplementorInfo implInfo;
@@ -109,7 +115,7 @@ public class JaxWsEndpointImpl extends E
private SOAPHandlerFaultOutInterceptor soapFaultOutInterceptor;
private LogicalHandlerFaultInInterceptor logicalFaultInInterceptor;
private SOAPHandlerFaultInInterceptor soapFaultInInterceptor;
-
+
public JaxWsEndpointImpl(Bus bus, Service s, EndpointInfo ei) throws
EndpointException {
this(bus, s, ei, null, null, null, true);
}
@@ -198,6 +204,7 @@ public class JaxWsEndpointImpl extends E
= endpoint.getBinding().getExtensors(ExtensibilityElement.class);
List<ExtensibilityElement> portExtensors
= endpoint.getExtensors(ExtensibilityElement.class);
+ checkRespectBindingFeature(bindingExtensors);
if (hasUsingAddressing(bindingExtensors) ||
hasUsingAddressing(portExtensors)) {
WSAddressingFeature feature = new WSAddressingFeature();
if (addressingRequired(bindingExtensors)
@@ -209,6 +216,27 @@ public class JaxWsEndpointImpl extends E
extractWsdlEprs(endpoint);
}
+ private void checkRespectBindingFeature(List<ExtensibilityElement>
bindingExtensors) {
+ if (bindingExtensors != null) {
+ Iterator<ExtensibilityElement> extensionElements =
bindingExtensors.iterator();
+ while (extensionElements.hasNext()) {
+ ExtensibilityElement ext =
(ExtensibilityElement)extensionElements.next();
+ if (ext instanceof UnknownExtensibilityElement &&
Boolean.TRUE.equals(ext.getRequired())) {
+ for (WebServiceFeature feature : this.wsFeatures) {
+ if (feature instanceof RespectBindingFeature &&
feature.isEnabled()) {
+
+ org.apache.cxf.common.i18n.Message message =
+ new
org.apache.cxf.common.i18n.Message("UNKONW_REQUIRED_WSDL_BINDING", LOG);
+ LOG.severe(message.toString());
+ throw new WebServiceException(message.toString());
+ }
+ }
+ }
+ }
+ }
+
+ }
+
private void extractWsdlEprs(EndpointInfo endpoint) {
//parse the EPR in wsdl
List<ExtensibilityElement> portExtensors =
endpoint.getExtensors(ExtensibilityElement.class);
Modified:
cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties?rev=1177259&r1=1177258&r2=1177259&view=diff
==============================================================================
---
cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
(original)
+++
cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
Thu Sep 29 10:47:58 2011
@@ -33,4 +33,8 @@ SERVICECLASS_MUST_BE_SET = serviceClass
XMLSEEALSO_NULL_CLASS = A class listed in the XmlSeeAlso annotation of the
service class %s cannot be found on the classpath. Index: %d of XmlSeeAlso
class list.
WEBMETHOD_EXCLUDE_NOT_ALLOWED = The @javax.jws.WebMethod(exclude=true) cannot
be used on a service endpoint interface. Method: {0}
WEBSERVICE_ANNOTATIONS_IS_LOADED_BY_OTHER_CLASSLOADER = The {0} annotation was
already loaded by another classloader. Please check if there are multiple
versions of the web service annotation jar in your classpath.
+UNKONW_REQUIRED_WSDL_BINDING = RespectBindingFeature is enabled and there is
wsdl:extensions that have the required=true attribute
+attribute
+
+
Modified:
cxf/branches/2.4.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?rev=1177259&r1=1177258&r2=1177259&view=diff
==============================================================================
---
cxf/branches/2.4.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
(original)
+++
cxf/branches/2.4.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Thu Sep 29 10:47:58 2011
@@ -654,4 +654,28 @@ public class JavaToProcessorTest extends
assertTrue(wsdlContent.indexOf("<soap:fault name=\"Exception\"
use=\"literal\"/>") != -1);
}
+
+ //CXF-1509
+ @Test
+ public void testWebFaultWithXmlType() throws Exception {
+ env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() +
"/cxf1519.wsdl");
+ env.put(ToolConstants.CFG_CLASSNAME,
"org.apache.cxf.tools.fortest.cxf1519.EndpointImpl");
+ env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
+ try {
+ processor.setEnvironment(env);
+ processor.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ File wsdlFile = new File(output, "cxf1519.wsdl");
+ assertTrue(wsdlFile.exists());
+ // schema element
+ String wsdlContent = getStringFromFile(wsdlFile).replaceAll(" ", " ");
+
assertTrue(wsdlContent.indexOf("xmlns:tns=\"http://cxf.apache.org/cxf1519/exceptions\"")
!= -1);
+
assertTrue(wsdlContent.indexOf("xmlns:tns=\"http://cxf.apache.org/cxf1519/faults\"")
!= -1);
+ assertTrue(wsdlContent.indexOf("<xsd:complexType
name=\"UserException\">") != -1);
+ assertTrue(wsdlContent.indexOf("<xsd:element
name=\"UserExceptionFault\"") != -1);
+
+ }
}