You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2007/10/17 04:16:41 UTC
svn commit: r585329 - in /incubator/cxf/trunk:
api/src/main/java/org/apache/cxf/service/model/
common/common/src/main/java/org/apache/cxf/common/util/ parent/
rt/core/src/main/java/org/apache/cxf/databinding/source/
rt/core/src/main/java/org/apache/cxf...
Author: dkulp
Date: Tue Oct 16 19:16:38 2007
New Revision: 585329
URL: http://svn.apache.org/viewvc?rev=585329&view=rev
Log:
Fix for schemas not getting the mime extensors
Added:
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/FixedExtensionDeserializer.java (with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/model/ExtendedWidgetWithMime.java (with props)
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java
incubator/cxf/trunk/parent/pom.xml
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/wsdl11/ServiceWSDLBuilder.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/TestServiceTest.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/model/jaxb.index
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rmwsdl.xml
incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ValidatorUtil.java
incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java
Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java?rev=585329&r1=585328&r2=585329&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java Tue Oct 16 19:16:38 2007
@@ -21,8 +21,12 @@
import javax.xml.namespace.QName;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.wsdl.WSDLConstants;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaElement;
@@ -68,6 +72,31 @@
}
public Element getElement() {
+ if (element == null && getSchema() != null) {
+ CachedOutputStream cout = new CachedOutputStream();
+ getSchema().write(cout);
+ Document sdoc = null;
+ try {
+ sdoc = XMLUtils.parse(cout.getInputStream());
+ cout.close();
+ } catch (Exception e1) {
+ return null;
+ }
+
+ Element e = sdoc.getDocumentElement();
+ // XXX A problem can occur with the ibm jdk when the XmlSchema
+ // 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);
+ }
+ setElement(e);
+ }
return element;
}
Added: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/FixedExtensionDeserializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/FixedExtensionDeserializer.java?rev=585329&view=auto
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/FixedExtensionDeserializer.java (added)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/FixedExtensionDeserializer.java Tue Oct 16 19:16:38 2007
@@ -0,0 +1,80 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.common.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Node;
+
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.constants.Constants;
+import org.apache.ws.commons.schema.extensions.ExtensionDeserializer;
+
+
+/**
+ * Workaround a bug in XmlSchema
+ *
+ * In XmlSchema, the default deserializer will only allow a single extension per element. The
+ * last one wipes out the earlier recorded extensions.
+ */
+@SuppressWarnings("unchecked")
+public class FixedExtensionDeserializer implements ExtensionDeserializer {
+
+ public void deserialize(XmlSchemaObject schemaObject, QName name, Node node) {
+
+ // we just attach the raw node either to the meta map of
+ // elements or the attributes
+ Map metaInfoMap = schemaObject.getMetaInfoMap();
+ if (metaInfoMap == null) {
+ metaInfoMap = new HashMap();
+ }
+
+ if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
+ if (name.getNamespaceURI().equals(Constants.XMLNS_ATTRIBUTE_NS_URI)) {
+ return;
+ }
+ Map attribMap;
+ if (metaInfoMap.containsKey(Constants.MetaDataConstants.EXTERNAL_ATTRIBUTES)) {
+ attribMap = (Map)metaInfoMap.get(Constants.MetaDataConstants.EXTERNAL_ATTRIBUTES);
+ } else {
+ attribMap = new HashMap();
+ metaInfoMap.put(Constants.MetaDataConstants.EXTERNAL_ATTRIBUTES, attribMap);
+ }
+ attribMap.put(name, node);
+ } else if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Map elementMap;
+ if (metaInfoMap.containsKey(Constants.MetaDataConstants.EXTERNAL_ELEMENTS)) {
+ elementMap = (Map)metaInfoMap.get(Constants.MetaDataConstants.EXTERNAL_ELEMENTS);
+ } else {
+ elementMap = new HashMap();
+ metaInfoMap.put(Constants.MetaDataConstants.EXTERNAL_ELEMENTS, elementMap);
+ }
+ elementMap.put(name, node);
+ }
+
+ //subsequent processing takes place only if this map is not empty
+ if (!metaInfoMap.isEmpty() && schemaObject.getMetaInfoMap() == null) {
+ schemaObject.setMetaInfoMap(metaInfoMap);
+ }
+ }
+}
Propchange: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/FixedExtensionDeserializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/FixedExtensionDeserializer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/parent/pom.xml?rev=585329&r1=585328&r2=585329&view=diff
==============================================================================
--- incubator/cxf/trunk/parent/pom.xml (original)
+++ incubator/cxf/trunk/parent/pom.xml Tue Oct 16 19:16:38 2007
@@ -432,7 +432,7 @@
<dependency>
<groupId>org.apache.ws.commons.schema</groupId>
<artifactId>XmlSchema</artifactId>
- <version>1.2</version>
+ <version>1.3.2</version>
</dependency>
<dependency>
<groupId>javax.xml.soap</groupId>
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=585329&r1=585328&r2=585329&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 Tue Oct 16 19:16:38 2007
@@ -28,6 +28,7 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.apache.cxf.common.util.FixedExtensionDeserializer;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.service.model.SchemaInfo;
import org.apache.cxf.service.model.ServiceInfo;
@@ -66,10 +67,9 @@
}
}
}
-
SchemaInfo schema = new SchemaInfo(serviceInfo, ns);
- schema.setElement(d.getDocumentElement());
schema.setSystemId(systemId);
+ col.getExtReg().setDefaultExtensionDeserializer(new FixedExtensionDeserializer());
XmlSchema xmlSchema = col.read(d.getDocumentElement());
schema.setSchema(xmlSchema);
serviceInfo.addSchema(schema);
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java?rev=585329&r1=585328&r2=585329&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java Tue Oct 16 19:16:38 2007
@@ -52,11 +52,11 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+
import com.ibm.wsdl.extensions.schema.SchemaImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.XMLUtils;
-import org.apache.cxf.service.factory.ServiceConstructionException;
import org.apache.cxf.service.model.AbstractMessageContainer;
import org.apache.cxf.service.model.AbstractPropertiesHolder;
import org.apache.cxf.service.model.BindingFaultInfo;
@@ -72,8 +72,6 @@
import org.apache.cxf.service.model.ServiceInfo;
import org.apache.cxf.wsdl.WSDLConstants;
import org.apache.cxf.wsdl.WSDLManager;
-import org.apache.ws.commons.schema.XmlSchemaSerializer;
-import org.apache.ws.commons.schema.XmlSchemaSerializer.XmlSchemaSerializerException;
public final class ServiceWSDLBuilder {
@@ -191,28 +189,6 @@
doc.appendChild(nd);
for (SchemaInfo schemaInfo : schemas) {
-
- if (schemaInfo.getSchema() != null) {
- Document[] docs;
- try {
- docs = XmlSchemaSerializer.serializeSchema(schemaInfo.getSchema(), false);
- } catch (XmlSchemaSerializerException e1) {
- throw new ServiceConstructionException(e1);
- }
- 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
- // 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);
- }
- schemaInfo.setElement(e);
- }
if (!useSchemaImports) {
SchemaImpl schemaImpl = new SchemaImpl();
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?rev=585329&r1=585328&r2=585329&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java Tue Oct 16 19:16:38 2007
@@ -62,6 +62,7 @@
import org.apache.cxf.catalog.CatalogXmlSchemaURIResolver;
import org.apache.cxf.catalog.OASISCatalogManager;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.FixedExtensionDeserializer;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.service.model.AbstractMessageContainer;
import org.apache.cxf.service.model.AbstractPropertiesHolder;
@@ -273,6 +274,8 @@
private XmlSchemaCollection getSchemas(Definition def, ServiceInfo serviceInfo) {
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
serviceInfo.setXmlSchemaCollection(schemaCol);
+ schemaCol.getExtReg().setDefaultExtensionDeserializer(
+ new FixedExtensionDeserializer());
List<Definition> defList = new ArrayList<Definition>();
parseImports(def, defList);
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/TestServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/TestServiceTest.java?rev=585329&r1=585328&r2=585329&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/TestServiceTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/TestServiceTest.java Tue Oct 16 19:16:38 2007
@@ -19,6 +19,9 @@
package org.apache.cxf.systest.jaxb;
+import java.net.URL;
+
+import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.systest.jaxb.model.ExtendedWidget;
import org.apache.cxf.systest.jaxb.model.Widget;
import org.apache.cxf.systest.jaxb.service.TestService;
@@ -37,13 +40,18 @@
@Test
public void testExtraSubClassWithJaxb() throws Throwable {
-
Widget expected = new ExtendedWidget(42, "blah", "blah", true, true);
Widget widgetFromService = testClient.getWidgetById((long)42);
assertEquals(expected, widgetFromService);
-
+ }
+
+ @Test
+ public void testSchema() throws Exception {
+ URL url = new URL("http://localhost:7081/service/TestService?wsdl");
+ String s = IOUtils.toString(url.openStream());
+ assertTrue(s, s.contains("application/octet-stream"));
}
/*
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/model/ExtendedWidgetWithMime.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/model/ExtendedWidgetWithMime.java?rev=585329&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/model/ExtendedWidgetWithMime.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/model/ExtendedWidgetWithMime.java Tue Oct 16 19:16:38 2007
@@ -0,0 +1,53 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.systest.jaxb.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+@XmlType(name = "extendedwidgetWithMime", namespace = "http://cxf.org.apache/model")
+@XmlRootElement(name = "extendedwidgetWithMime", namespace = "http://cxf.org.apache/model")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ExtendedWidgetWithMime extends Widget {
+
+
+ @XmlMimeType("application/octet-stream")
+ private byte[] xmlData;
+
+
+ /**
+ * @return the extended
+ */
+ public byte[] getXmlData() {
+ return xmlData;
+ }
+
+ /**
+ * @param extended the extended to set
+ */
+ public void setXmlData(byte[] xmlData) {
+ this.xmlData = xmlData;
+ }
+
+}
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/model/ExtendedWidgetWithMime.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/model/ExtendedWidgetWithMime.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/model/jaxb.index
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/model/jaxb.index?rev=585329&r1=585328&r2=585329&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/model/jaxb.index (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxb/model/jaxb.index Tue Oct 16 19:16:38 2007
@@ -15,4 +15,5 @@
# specific language governing permissions and limitations
# under the License.
Widget
-ExtendedWidget
\ No newline at end of file
+ExtendedWidget
+ExtendedWidgetWithMime
\ No newline at end of file
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rmwsdl.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rmwsdl.xml?rev=585329&r1=585328&r2=585329&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rmwsdl.xml (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/rmwsdl.xml Tue Oct 16 19:16:38 2007
@@ -26,7 +26,7 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<http:conduit name="{http://cxf.apache.org/greeter_control}GreeterPort.http-conduit">
- <http:client DecoupledEndpoint="http://localhost:9999/decoupled_endpoint"/>
+ <http:client DecoupledEndpoint="http://localhost:9998/decoupled_endpoint"/>
</http:conduit>
<bean id="org.apache.cxf.ws.policy.PolicyEngine" class="org.apache.cxf.ws.policy.spring.InitializingPolicyEngine">
Modified: incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ValidatorUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ValidatorUtil.java?rev=585329&r1=585328&r2=585329&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ValidatorUtil.java (original)
+++ incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ValidatorUtil.java Tue Oct 16 19:16:38 2007
@@ -77,6 +77,7 @@
//
baseURI = baseURI.replaceAll(" ", "%20");
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ schemaCol.setBaseUri(baseURI);
NodeList nodes = document.getElementsByTagNameNS(
WSDLConstants.NU_SCHEMA_XSD, "schema");
for (int x = 0; x < nodes.getLength(); x++) {
Modified: incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java?rev=585329&r1=585328&r2=585329&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java (original)
+++ incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java Tue Oct 16 19:16:38 2007
@@ -35,6 +35,7 @@
try {
assertFalse(validator.isValid());
} catch (Exception e) {
+ e.printStackTrace();
assertTrue(e.getMessage().indexOf("Caused by {http://apache.org/hello_world/messages}"
+ "[portType:GreeterA][operation:sayHi] not exist.") != -1);
}