Author: dandiep
Date: Sat Jul 14 10:34:31 2007
New Revision: 556305
URL: http://svn.apache.org/viewvc?view=rev&rev=556305
Log:
CXF-781: Fix a problem with Aegis whereby it didn't detect that both an
ArrayType and
a ListType represented the same schema type, and the schema was duplicated
inside the
WSDL. (Amazingly, this is a bug with XFire too - I can't believe that no one
has run
into it before! I guess people just don't mix arrays and Lists together very
often?)
Many thanks to Benson Margulies for the excellent unit test that he provided
CXF-784: Set the content-type on the outgoing fault chain inside the HTTP
Binding.
Add in a StaxDataBinding implementation which makes it possible to write
services
which read straight from the XMLStreamReader. You can also return an
XMLStreamReader
or an XMLStreamWriterCallback to write the response. This is still kind of
hackish,
I'd like to see if I could make this work without removing the
DocLiteral/Bare/Wrapper
Interceptors. But I need to start a discussion on how to do that on the mailing
list.
Added:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/Messages.properties
(with props)
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBinding.java
(with props)
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingFeature.java
(with props)
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingInterceptor.java
(with props)
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/XMLStreamWriterCallback.java
(with props)
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.aegis.xml
(with props)
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.java
(with props)
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayService.java
(with props)
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayServiceBean.java
(with props)
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java
(with props)
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/StaxDatabindingTest.java
(with props)
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/req.xml
(with props)
Modified:
incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/HttpBindingFactory.java
incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java
Modified:
incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/HttpBindingFactory.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/HttpBindingFactory.java?view=diff&rev=556305&r1=556304&r2=556305
==============================================================================
---
incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/HttpBindingFactory.java
(original)
+++
incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/HttpBindingFactory.java
Sat Jul 14 10:34:31 2007
@@ -68,6 +68,7 @@
binding.getInFaultInterceptors().add(new XMLFaultInInterceptor());
+ binding.getOutFaultInterceptors().add(new ContentTypeOutInterceptor());
binding.getOutFaultInterceptors().add(new StaxOutInterceptor());
binding.getOutFaultInterceptors().add(new XMLFaultOutInterceptor());
Modified:
incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java?view=diff&rev=556305&r1=556304&r2=556305
==============================================================================
---
incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java
(original)
+++
incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java
Sat Jul 14 10:34:31 2007
@@ -149,6 +149,15 @@
assertEquals("text/plain", c.getContentType());
+ c.disconnect();
+
+ url = new URL("http://localhost:9001/foo/customers/bleh");
+ c = (HttpURLConnection)url.openConnection();
+ c.setRequestMethod("GET");
+
+ String ct = c.getContentType();
+ assertTrue(ct.startsWith("text/plain"));
+
svr.stop();
}
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java?view=diff&rev=556305&r1=556304&r2=556305
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java
Sat Jul 14 10:34:31 2007
@@ -65,8 +65,7 @@
}
public Class<?>[] getSupportedReaderFormats() {
- // TODO Auto-generated method stub
- return null;
+ return new Class[] {XMLStreamReader.class, Node.class};
}
@SuppressWarnings("unchecked")
Added:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/Messages.properties
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/Messages.properties?view=auto&rev=556305
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/Messages.properties
(added)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/Messages.properties
Sat Jul 14 10:34:31 2007
@@ -0,0 +1,20 @@
+#
+#
+# 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.
+#
+#
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/Messages.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/Messages.properties
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/Messages.properties
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/Messages.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBinding.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBinding.java?view=auto&rev=556305
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBinding.java
(added)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBinding.java
Sat Jul 14 10:34:31 2007
@@ -0,0 +1,142 @@
+/**
+ * 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.databinding.stax;
+
+import java.util.Collection;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.validation.Schema;
+
+import org.w3c.dom.Node;
+
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Attachment;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.staxutils.StaxUtils;
+
+/**
+ * A simple databinding implementation which reads and writes Source objects.
+ * This will not work with the standard databinding interceptors.
+ */
+public class StaxDataBinding implements DataBinding {
+
+ private XMLStreamDataReader xsrReader;
+ private XMLStreamDataWriter xswWriter;
+
+ public StaxDataBinding() {
+ super();
+ this.xsrReader = new XMLStreamDataReader();
+ this.xswWriter = new XMLStreamDataWriter();
+ }
+
+ public void initialize(Service service) {
+ // do nothing
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> DataReader<T> createReader(Class<T> cls) {
+ if (cls == XMLStreamReader.class) {
+ return (DataReader<T>) xsrReader;
+ } else {
+ throw new UnsupportedOperationException("The type " +
cls.getName() + " is not supported.");
+ }
+ }
+
+ public Class<?>[] getSupportedReaderFormats() {
+ return new Class[] {XMLStreamReader.class};
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> DataWriter<T> createWriter(Class<T> cls) {
+ if (cls == XMLStreamWriter.class) {
+ return (DataWriter<T>) xswWriter;
+ } else {
+ throw new UnsupportedOperationException("The type " +
cls.getName() + " is not supported.");
+ }
+ }
+
+ public Class<?>[] getSupportedWriterFormats() {
+ return new Class[] {XMLStreamWriter.class, Node.class};
+ }
+
+ public static class XMLStreamDataReader implements
DataReader<XMLStreamReader> {
+
+ public Object read(MessagePartInfo part, XMLStreamReader input) {
+ return read(null, input, part.getTypeClass());
+ }
+
+ public Object read(QName name, XMLStreamReader input, Class type) {
+ return input;
+ }
+
+ public Object read(XMLStreamReader reader) {
+ return reader;
+ }
+
+ public void setSchema(Schema s) {
+ }
+
+ public void setAttachments(Collection<Attachment> attachments) {
+ }
+
+ public void setProperty(String prop, Object value) {
+ }
+ }
+
+ public static class XMLStreamDataWriter implements
DataWriter<XMLStreamWriter> {
+ private static final Logger LOG =
LogUtils.getL7dLogger(XMLStreamDataWriter.class);
+
+ public void write(Object obj, MessagePartInfo part, XMLStreamWriter
output) {
+ write(obj, output);
+ }
+
+ public void write(Object obj, XMLStreamWriter writer) {
+ try {
+ if (obj instanceof XMLStreamReader) {
+ StaxUtils.copy((XMLStreamReader) obj, writer);
+ } else if (obj instanceof XMLStreamWriterCallback) {
+ ((XMLStreamWriterCallback) obj).write(writer);
+ } else {
+ throw new UnsupportedOperationException("Data types of "
+ + obj.getClass() +
" are not supported.");
+ }
+ } catch (XMLStreamException e) {
+ throw new Fault(new Message("COULD_NOT_READ_XML_STREAM", LOG),
e);
+ }
+ }
+
+ public void setSchema(Schema s) {
+ }
+
+ public void setAttachments(Collection<Attachment> attachments) {
+
+ }
+ }
+}
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBinding.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBinding.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBinding.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingFeature.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingFeature.java?view=auto&rev=556305
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingFeature.java
(added)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingFeature.java
Sat Jul 14 10:34:31 2007
@@ -0,0 +1,69 @@
+/**
+ * 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.databinding.stax;
+
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.interceptor.BareInInterceptor;
+import org.apache.cxf.interceptor.DocLiteralInInterceptor;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.WrappedInInterceptor;
+import org.apache.cxf.phase.PhaseInterceptor;
+
+public class StaxDataBindingFeature extends AbstractFeature {
+
+
+ @Override
+ public void initialize(Client client, Bus bus) {
+
removeDatabindingInterceptor(client.getEndpoint().getBinding().getInInterceptors());
+ }
+
+ @Override
+ public void initialize(Server server, Bus bus) {
+
removeDatabindingInterceptor(server.getEndpoint().getBinding().getInInterceptors());
+ }
+
+ private void removeDatabindingInterceptor(List<Interceptor>
inInterceptors) {
+ removeInterceptor(inInterceptors,
DocLiteralInInterceptor.class.getName());
+ removeInterceptor(inInterceptors, BareInInterceptor.class.getName());
+ removeInterceptor(inInterceptors,
WrappedInInterceptor.class.getName());
+
+
+ inInterceptors.add(new StaxDataBindingInterceptor());
+ }
+
+ private void removeInterceptor(List<Interceptor> inInterceptors, String
name) {
+
+ for (Interceptor i : inInterceptors) {
+ if (i instanceof PhaseInterceptor) {
+ PhaseInterceptor p = (PhaseInterceptor)i;
+
+ if (p.getId().equals(name)) {
+ inInterceptors.remove(p);
+ return;
+ }
+ }
+ }
+ }
+
+}
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingFeature.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingFeature.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingFeature.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingInterceptor.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingInterceptor.java?view=auto&rev=556305
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingInterceptor.java
(added)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingInterceptor.java
Sat Jul 14 10:34:31 2007
@@ -0,0 +1,81 @@
+/**
+ * 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.databinding.stax;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor;
+import org.apache.cxf.interceptor.DocLiteralInInterceptor;
+import org.apache.cxf.interceptor.URIMappingInterceptor;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.staxutils.DepthXMLStreamReader;
+import org.apache.cxf.staxutils.StaxUtils;
+
+public class StaxDataBindingInterceptor extends
AbstractInDatabindingInterceptor {
+ private static final Logger LOG =
Logger.getLogger(DocLiteralInInterceptor.class.getName());
+
+ public StaxDataBindingInterceptor() {
+ super(Phase.UNMARSHAL);
+ addAfter(URIMappingInterceptor.class.getName());
+ }
+
+ public void handleMessage(Message message) {
+ if (isGET(message) && message.getContent(List.class) != null) {
+ LOG.info("DocLiteralInInterceptor skipped in HTTP GET method");
+ return;
+ }
+
+ DepthXMLStreamReader xmlReader = getXMLStreamReader(message);
+ DataReader<XMLStreamReader> dr = getDataReader(message);
+ List<Object> parameters = new ArrayList<Object>();
+
+ Exchange exchange = message.getExchange();
+ BindingOperationInfo bop = exchange.get(BindingOperationInfo.class);
+
+ //if body is empty and we have BindingOperationInfo, we do not need to
match
+ //operation anymore, just return
+ if (!StaxUtils.toNextElement(xmlReader) && bop != null) {
+ // body may be empty for partial response to decoupled request
+ return;
+ }
+
+ parameters.add(dr.read(xmlReader));
+
+ if (bop == null) {
+ Endpoint ep = exchange.get(Endpoint.class);
+ bop =
ep.getBinding().getBindingInfo().getOperations().iterator().next();
+ }
+
+ message.getExchange().put(BindingOperationInfo.class, bop);
+
+ if (parameters.size() > 0) {
+ message.setContent(List.class, parameters);
+ }
+ }
+}
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingInterceptor.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBindingInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/XMLStreamWriterCallback.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/XMLStreamWriterCallback.java?view=auto&rev=556305
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/XMLStreamWriterCallback.java
(added)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/XMLStreamWriterCallback.java
Sat Jul 14 10:34:31 2007
@@ -0,0 +1,29 @@
+/**
+ * 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.databinding.stax;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.cxf.interceptor.Fault;
+
+public interface XMLStreamWriterCallback {
+ void write(XMLStreamWriter writer) throws Fault, XMLStreamException;
+}
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/XMLStreamWriterCallback.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/XMLStreamWriterCallback.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/XMLStreamWriterCallback.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java?view=diff&rev=556305&r1=556304&r2=556305
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java
(original)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ArrayType.java
Sat Jul 14 10:34:31 2007
@@ -22,6 +22,8 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import javax.xml.namespace.QName;
@@ -38,6 +40,7 @@
import org.apache.cxf.aegis.xml.MessageWriter;
import org.jdom.Attribute;
import org.jdom.Element;
+import org.jdom.Namespace;
/**
* An ArrayType.
@@ -258,6 +261,10 @@
@Override
public void writeSchema(Element root) {
try {
+ if (hasDefinedArray(root)) {
+ return;
+ }
+
Element complex = new Element("complexType",
XmlConstants.XSD_PREFIX, XmlConstants.XSD);
complex.setAttribute(new Attribute("name",
getSchemaType().getLocalPart()));
root.addContent(complex);
@@ -292,6 +299,25 @@
} catch (IllegalArgumentException e) {
throw new DatabindingException("Illegal argument.", e);
}
+ }
+
+ /**
+ * Since both an Array and a List can have the same type definition,
double check
+ * that there isn't already a defined type already.
+ * @param root
+ * @return
+ */
+ private boolean hasDefinedArray(Element root) {
+ List children = root.getChildren("complexType",
Namespace.getNamespace(XmlConstants.XSD));
+ for (Iterator itr = children.iterator(); itr.hasNext();) {
+ Element e = (Element) itr.next();
+
+
+ if
(e.getAttributeValue("name").equals(getSchemaType().getLocalPart())) {
+ return true;
+ }
+ }
+ return false;
}
/**
Added:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.aegis.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.aegis.xml?view=auto&rev=556305
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.aegis.xml
(added)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.aegis.xml
Sat Jul 14 10:34:31 2007
@@ -0,0 +1,4 @@
+<mappings xmlns:oacat="urn:org.apache.cxf.aegis.type">
+ <mapping name="oacat:DuplicateArrayReturnItem">
+ </mapping>
+</mappings>
\ No newline at end of file
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.aegis.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.aegis.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.aegis.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.aegis.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.java?view=auto&rev=556305
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.java
(added)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.java
Sat Jul 14 10:34:31 2007
@@ -0,0 +1,38 @@
+/**
+ * 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.aegis.type.array;
+
+public class DuplicateArrayReturnItem implements Comparable {
+
+ String name;
+
+ public int compareTo(Object arg0) {
+ return 0;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayReturnItem.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayService.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayService.java?view=auto&rev=556305
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayService.java
(added)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayService.java
Sat Jul 14 10:34:31 2007
@@ -0,0 +1,36 @@
+/**
+ * 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.aegis.type.array;
+
+import java.util.List;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
[EMAIL PROTECTED](name = "DuplicateArray", targetNamespace =
"urn:org.apache.cxf.aegis.type.java5")
+public interface DuplicateArrayService {
+
+ @WebMethod()
+ DuplicateArrayReturnItem[] lookup(String indexid);
+
+ @WebMethod
+ List<List<DuplicateArrayReturnItem>> lookupBatch(String indexid);
+
+}
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayService.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayServiceBean.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayServiceBean.java?view=auto&rev=556305
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayServiceBean.java
(added)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayServiceBean.java
Sat Jul 14 10:34:31 2007
@@ -0,0 +1,39 @@
+/**
+ * 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.aegis.type.array;
+
+import java.util.List;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
[EMAIL PROTECTED](name = "DuplicateArrayService")
+public class DuplicateArrayServiceBean implements DuplicateArrayService {
+
+ @WebMethod
+ public DuplicateArrayReturnItem[] lookup(String indexid) {
+ return null;
+ }
+
+ @WebMethod
+ public List<List<DuplicateArrayReturnItem>> lookupBatch(String indexid) {
+ return null;
+ }
+
+}
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayServiceBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayServiceBean.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayServiceBean.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java?view=auto&rev=556305
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java
(added)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java
Sat Jul 14 10:34:31 2007
@@ -0,0 +1,60 @@
+/**
+ * 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.aegis.type.array;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.aegis.type.Configuration;
+import org.apache.cxf.aegis.type.DefaultTypeMappingRegistry;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.junit.Test;
+
+public class DuplicateArrayTest extends AbstractAegisTest {
+
+ @Test
+ public void testServiceStart() throws Exception {
+ AegisDatabinding binder = new AegisDatabinding();
+
+ JaxWsServerFactoryBean serviceFactory = new JaxWsServerFactoryBean();
+ serviceFactory.getServiceFactory().setDataBinding(binder);
+
+ DefaultTypeMappingRegistry tmr =
(DefaultTypeMappingRegistry)binder.getTypeMappingRegistry();
+ Configuration configuration = tmr.getConfiguration();
+ configuration.setDefaultMinOccurs(1);
+ configuration.setDefaultNillable(false);
+
+ // Create a properties hashmap
+ Map<String, Object> props = new HashMap<String, Object>();
+
+ // Enable the writing of xsi:type attributes
+ props.put(AegisDatabinding.WRITE_XSI_TYPE_KEY, Boolean.TRUE);
+
+ serviceFactory.setAddress("local:://DuplicateArrayService");
+ serviceFactory.setServiceBean(new DuplicateArrayServiceBean());
+ serviceFactory.setServiceClass(DuplicateArrayService.class);
+ serviceFactory.setProperties(props);
+ serviceFactory.create();
+
+ }
+
+}
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/StaxDatabindingTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/StaxDatabindingTest.java?view=auto&rev=556305
==============================================================================
---
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/StaxDatabindingTest.java
(added)
+++
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/StaxDatabindingTest.java
Sat Jul 14 10:34:31 2007
@@ -0,0 +1,99 @@
+/**
+ * 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.service.stax;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.w3c.dom.Node;
+
+import org.apache.cxf.databinding.stax.StaxDataBinding;
+import org.apache.cxf.databinding.stax.StaxDataBindingFeature;
+import org.apache.cxf.databinding.stax.XMLStreamWriterCallback;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.staxutils.FragmentStreamReader;
+import org.apache.cxf.test.AbstractCXFTest;
+import org.apache.cxf.transport.local.LocalTransportFactory;
+import org.junit.Test;
+
+public class StaxDatabindingTest extends AbstractCXFTest {
+ @Test
+ public void testCallback() throws Exception {
+ String address = "local://foo";
+
+ ServerFactoryBean sf = new ServerFactoryBean();
+ sf.setServiceBean(new CallbackService());
+ sf.setAddress(address);
+ sf.setDataBinding(new StaxDataBinding());
+ sf.getFeatures().add(new StaxDataBindingFeature());
+
+ sf.create();
+
+ Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID,
"req.xml");
+
+ assertValid("//bleh", res);
+ }
+
+ @Test
+ public void testCopy() throws Exception {
+ String address = "local://foo";
+
+ ServerFactoryBean sf = new ServerFactoryBean();
+ sf.setServiceBean(new CopyService());
+ sf.setAddress(address);
+ sf.setDataBinding(new StaxDataBinding());
+ sf.getFeatures().add(new StaxDataBindingFeature());
+
+ sf.create();
+
+ Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID,
"req.xml");
+
+ DOMUtils.writeXml(res, System.out);
+ addNamespace("a", "http://stax.service.cxf.apache.org/");
+ assertValid("//a:bleh", res);
+ }
+
+ public static class CallbackService {
+ public XMLStreamWriterCallback invoke(final XMLStreamReader reader) {
+ try {
+ reader.nextTag();
+ } catch (XMLStreamException e) {
+ throw new Fault(e);
+ }
+
+ return new XMLStreamWriterCallback() {
+
+ public void write(XMLStreamWriter writer) throws Fault,
XMLStreamException {
+ writer.writeEmptyElement("bleh");
+ }
+
+ };
+ }
+ }
+
+ public static class CopyService {
+ public XMLStreamReader invoke(final XMLStreamReader reader) {
+ return new FragmentStreamReader(reader);
+ }
+ }
+}
Propchange:
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/StaxDatabindingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/StaxDatabindingTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/StaxDatabindingTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/req.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/req.xml?view=auto&rev=556305
==============================================================================
---
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/req.xml
(added)
+++
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/req.xml
Sat Jul 14 10:34:31 2007
@@ -0,0 +1,10 @@
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <invokeWithCallback
+ xmlns="http://stax.service.cxf.apache.org/">
+ <reader>
+ <bleh>foo</bleh>
+ </reader>
+ </invokeWithCallback>
+ </soap:Body>
+</soap:Envelope>
Propchange:
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/req.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/req.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange:
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/req.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
incubator/cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/stax/req.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml