You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sc...@apache.org on 2009/10/24 03:46:15 UTC
svn commit: r829296 [1/3] - in /webservices/axis2/trunk/java/modules:
jaxws-integration/ jaxws-integration/test/org/apache/axis2/jaxws/sample/
jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/
jaxws/src/org/apache/axis2/datasource/jaxb...
Author: scheu
Date: Sat Oct 24 01:46:13 2009
New Revision: 829296
URL: http://svn.apache.org/viewvc?rev=829296&view=rev
Log:
AXIS2-3341
Contributor: Rich Scheuerle
Added code to support arrays/lists for the Document Literal Wrapped "Minimal" scenarios.
"Minimal" means that the JAX-WS service lacks wrapper beans.
The use of JAX-WS services that lack wrapper beans is not recommended.
Also added verification tests to validate the code.
Added:
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DLWMinArrayTests.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/ComplexArrayResponse.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/ComplexListResponse.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/GenericService.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/IGenericService.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/SimpleArrayResponse.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/SimpleListResponse.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/WSUser.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/XMLStreamWriterArrayFilter.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/OccurrenceArray.java
Modified:
webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DLWMinTests.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMinimalMethodMarshaller.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/MarshalServiceRuntimeDescription.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/impl/ArtifactProcessor.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/impl/MarshalServiceRuntimeDescriptionBuilder.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/impl/MarshalServiceRuntimeDescriptionImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/impl/PackageSetBuilder.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBDSContextTests.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/JavaUtils.java
Modified: webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml?rev=829296&r1=829295&r2=829296&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml Sat Oct 24 01:46:13 2009
@@ -964,6 +964,22 @@
basedir="${pom.basedir}/target/test-classes/servicejars/GreeterService"
/>
<delete dir="target/test-classes/servicejars/GreeterService"/>
+
+ <copy toDir="target/test-classes/servicejars/GenericService/">
+ <fileset dir="target/test-classes">
+ <include name="org/apache/axis2/jaxws/sample/dlwminArrays/**"/>
+ <exclude name="org/apache/axis2/jaxws/sample/dlwminArrays/META-INF/services.xml"/>
+ </fileset>
+ <fileset dir="test/org/apache/axis2/jaxws/sample/dlwminArrays">
+ <include name="META-INF/**"/>
+ <exclude name="META-INF/services.xml"/>
+ </fileset>
+ </copy>
+
+ <zip destfile="target/test-classes/servicejars/GenericService.jar"
+ basedir="${pom.basedir}/target/test-classes/servicejars/GenericService"
+ />
+ <delete dir="target/test-classes/servicejars/GenericService"/>
<copy toDir="target/test-classes/servicejars/AsyncService/">
<fileset dir="target/test-classes">
@@ -1360,6 +1376,7 @@
<include>**/HeadersHandlerTests.java</include>
<include>**/AddNumbersTests.java</include>
<include>**/DLWMinTests.java</include>
+ <include>**/DLWMinArrayTests.java</include>
<include>**/FaultsServiceTests.java</include>
<include>**/WrapTests.java</include>
<include>**/SoapMessageProviderTests.java</include>
@@ -1403,7 +1420,7 @@
<include>**/SoapMessageProviderTests.java</include>
<include>**/StringProviderTests.java</include>
<include>**/OMProviderTests.java</include>
-
+
</includes>
<systemProperties>
<property>
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DLWMinArrayTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DLWMinArrayTests.java?rev=829296&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DLWMinArrayTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DLWMinArrayTests.java Sat Oct 24 01:46:13 2009
@@ -0,0 +1,434 @@
+/*
+ * 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.axis2.jaxws.sample;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.axis2.jaxws.TestLogger;
+import org.apache.axis2.jaxws.framework.AbstractTestCase;
+import org.apache.axis2.jaxws.sample.dlwminArrays.IGenericService;
+import org.apache.axis2.jaxws.sample.dlwminArrays.WSUser;
+
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Holder;
+import javax.xml.ws.Service;
+
+/**
+ *
+ * Tests to verify Document/Literal Wrapped Minimal Scenarios
+ * Document/Literal Wrapped is a JAX-WS style.
+ * "Minimal" indicates that no wrapper beans are associated with the JAX-WS method.
+ * In most enterprise scenarios, wrapper beans are packaged with the JAX-WS application.
+ */
+public class DLWMinArrayTests extends AbstractTestCase {
+
+ private static final String NAMESPACE = "http://apache.org/axis2/jaxws/sample/dlwminArrays";
+ private static final QName QNAME_SERVICE = new QName(
+ NAMESPACE, "GenericService");
+ private static final QName QNAME_PORT = new QName(
+ NAMESPACE, "GenericServicePort");
+ private static final String URL_ENDPOINT = "http://localhost:6060/axis2/services/GenericService.GenericServicePort";
+
+ private static String FIRST = "first";
+ private static String SECOND = "second";
+
+ public static Test suite() {
+ return getTestSetup(new TestSuite(DLWMinArrayTests.class));
+ }
+
+ private IGenericService getProxy(String action) {
+ Service service = Service.create(QNAME_SERVICE);
+ IGenericService proxy = service.getPort(QNAME_PORT, IGenericService.class);
+ BindingProvider p = (BindingProvider) proxy;
+ p.getRequestContext().put(
+ BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
+ p.getRequestContext().put(
+ BindingProvider.SOAPACTION_URI_PROPERTY, action);
+ p.getRequestContext().put(
+ BindingProvider.ENDPOINT_ADDRESS_PROPERTY, URL_ENDPOINT);
+ return proxy;
+ }
+
+ /**
+ * Test sayHello method
+ */
+ public void testHello() throws Exception {
+
+ IGenericService proxy = getProxy("sayHello");
+
+ String me = "Scheu";
+ String response = proxy.sayHello(me);
+ assertTrue("Hello Scheu".equals(response));
+
+ // Try the call again
+ response = proxy.sayHello(me);
+ assertTrue("Hello Scheu".equals(response));
+ }
+
+ /**
+ * Test method that returns a String[]
+ */
+ public void testGetSimpleArray() throws Exception {
+
+ IGenericService proxy = getProxy("getSimpleArray");
+
+ String[] response = proxy.getSimpleArray();
+ assertTrue(response != null);
+ assertTrue("Expected 2, Received " + response.length, response.length == 2);
+ assertTrue("The first response is: " + response[0], response.length == 2);
+ assertTrue(FIRST.equals(response[0]));
+ assertTrue(SECOND.equals(response[1]));
+
+ // Try the call again
+ response = proxy.getSimpleArray();
+ assertTrue(response != null);
+ assertTrue(response.length == 2);
+ assertTrue(FIRST.equals(response[0]));
+ assertTrue(SECOND.equals(response[1]));
+ }
+
+ /**
+ * Test method that returns a List<String>
+ */
+ public void testGetSimpleList() throws Exception {
+
+ IGenericService proxy = getProxy("getSimpleList");
+
+ List<String> response = proxy.getSimpleList();
+ assertTrue(response != null);
+ assertTrue(response.size() == 2);
+ assertTrue(FIRST.equals(response.get(0)));
+ assertTrue(SECOND.equals(response.get(1)));
+
+ // Try the call again
+ response = proxy.getSimpleList();
+ assertTrue(response != null);
+ assertTrue(response.size() == 2);
+ assertTrue(FIRST.equals(response.get(0)));
+ assertTrue(SECOND.equals(response.get(1)));
+ }
+
+ /**
+ * Test method that returns a bean array (WSUser[])
+ */
+ public void testGetComplexArray() throws Exception {
+
+ IGenericService proxy = getProxy("getComplexArray");
+
+ WSUser[] response = proxy.getComplexArray();
+ assertTrue(response != null);
+ assertTrue("Expected 2, Received " + response.length, response.length == 2);
+ assertTrue(FIRST.equals(response[0].getUserID()));
+ assertTrue(SECOND.equals(response[1].getUserID()));
+
+ // Try the call again
+ response = proxy.getComplexArray();
+ assertTrue(response != null);
+ assertTrue(response.length == 2);
+ assertTrue(FIRST.equals(response[0].getUserID()));
+ assertTrue(SECOND.equals(response[1].getUserID()));
+ }
+
+ /**
+ * Test method that returns a List of beans (List<WSUser>)
+ */
+ public void testGetComplexList() throws Exception {
+
+ IGenericService proxy = getProxy("getComplexList");
+
+ List<WSUser> response = proxy.getComplexList();
+ assertTrue(response != null);
+ assertTrue(response.size() == 2);
+ assertTrue(FIRST.equals(response.get(0).getUserID()));
+ assertTrue(SECOND.equals(response.get(1).getUserID()));
+
+ // Try the call again
+ response = proxy.getComplexList();
+ assertTrue(response != null);
+ assertTrue(response.size() == 2);
+ assertTrue(FIRST.equals(response.get(0).getUserID()));
+ assertTrue(SECOND.equals(response.get(1).getUserID()));
+ }
+
+ /**
+ * Test method that echos a List of beans (List<WSUser>)
+ * Two items are echo'd.
+ */
+ public void testEchoComplexList2() throws Exception {
+
+ IGenericService proxy = getProxy("echoComplexList");
+
+ List<WSUser> in = new ArrayList<WSUser>();
+ WSUser wsUser = new WSUser();
+ wsUser.setUserID("Hello");
+ in.add(wsUser);
+ wsUser = new WSUser();
+ wsUser.setUserID("World");
+ in.add(wsUser);
+
+ List<WSUser> response = proxy.echoComplexList(in);
+ assertTrue(response != null);
+ assertTrue(response.size() == 2);
+ assertTrue("Hello".equals(response.get(0).getUserID()));
+ assertTrue("World".equals(response.get(1).getUserID()));
+
+ // Try the call again
+ response = proxy.echoComplexList(in);
+ assertTrue(response != null);
+ assertTrue(response.size() == 2);
+ assertTrue("Hello".equals(response.get(0).getUserID()));
+ assertTrue("World".equals(response.get(1).getUserID()));
+ }
+
+ /**
+ * Test method that echos a List of beans (List<WSUser>)
+ * One item is echo'd.
+ */
+ public void testEchoComplexList1() throws Exception {
+
+ IGenericService proxy = getProxy("echoComplexList");
+
+ List<WSUser> in = new ArrayList<WSUser>();
+ WSUser wsUser = new WSUser();
+ wsUser.setUserID("Hello");
+ in.add(wsUser);
+
+ List<WSUser> response = proxy.echoComplexList(in);
+ assertTrue(response != null);
+ assertTrue(response.size() == 1);
+ assertTrue("Hello".equals(response.get(0).getUserID()));
+
+
+ // Try the call again
+ response = proxy.echoComplexList(in);
+ assertTrue(response != null);
+ assertTrue(response.size() == 1);
+ assertTrue("Hello".equals(response.get(0).getUserID()));
+ }
+
+ /**
+ * Test method that echos a List of beans (List<WSUser>)
+ * The list contains no items.
+ */
+ public void testEchoComplexList0() throws Exception {
+
+ IGenericService proxy = getProxy("echoComplexList");
+
+ List<WSUser> in = new ArrayList<WSUser>();
+
+ List<WSUser> response = proxy.echoComplexList(in);
+ assertTrue(response != null);
+ assertTrue(response.size() == 0);
+
+ // Try the call again
+ response = proxy.echoComplexList(in);
+ assertTrue(response != null);
+ assertTrue(response.size() == 0);
+
+ }
+
+ /**
+ * Test method that echos a List of beans (List<WSUser>)
+ * and echos a List<String> as an inout parameter.
+ * 2 WSUsers are echo'd
+ * 2 Strings are echo'd
+ */
+ public void testEcho22() throws Exception {
+
+ IGenericService proxy = getProxy("echo");
+
+ List<WSUser> in = new ArrayList<WSUser>();
+ WSUser wsUser = new WSUser();
+ wsUser.setUserID("James Bond");
+ in.add(wsUser);
+ wsUser = new WSUser();
+ wsUser.setUserID("Dr. Evil");
+ in.add(wsUser);
+
+ List<String> id_in = new ArrayList<String>();
+ id_in.add("jbond");
+ id_in.add("evil");
+ Holder<List<String>> inout = new Holder<List<String>>(id_in);
+
+ List<WSUser> response = proxy.echo(in, inout);
+ assertTrue(response != null);
+ assertTrue(response.size() == 2);
+ assertTrue("James Bond".equals(response.get(0).getUserID()));
+ assertTrue("Dr. Evil".equals(response.get(1).getUserID()));
+ List<String> id_out = inout.value;
+ assertTrue(id_out.size() == 2);
+ assertTrue("JBOND".equals(id_out.get(0)));
+ assertTrue("EVIL".equals(id_out.get(1)));
+
+ // Try the call again
+ inout = new Holder<List<String>>(id_in);
+ response = proxy.echo(in, inout);
+ assertTrue(response != null);
+ assertTrue(response.size() == 2);
+ assertTrue("James Bond".equals(response.get(0).getUserID()));
+ assertTrue("Dr. Evil".equals(response.get(1).getUserID()));
+ id_out = inout.value;
+ assertTrue(id_out.size() == 2);
+ assertTrue("JBOND".equals(id_out.get(0)));
+ assertTrue("EVIL".equals(id_out.get(1)));
+ }
+
+ /**
+ * Test method that echos a List of beans (List<WSUser>)
+ * and echos a List<String> as an inout parameter.
+ * 1 WSUsers is echo'd
+ * 1 Strings is echo'd
+ */
+ public void testEcho11() throws Exception {
+
+ IGenericService proxy = getProxy("echo");
+
+ List<WSUser> in = new ArrayList<WSUser>();
+ WSUser wsUser = new WSUser();
+ wsUser.setUserID("James Bond");
+ in.add(wsUser);
+
+
+ List<String> id_in = new ArrayList<String>();
+ id_in.add("jbond");
+ Holder<List<String>> inout = new Holder<List<String>>(id_in);
+
+ List<WSUser> response = proxy.echo(in, inout);
+ assertTrue(response != null);
+ assertTrue(response.size() == 1);
+ assertTrue("James Bond".equals(response.get(0).getUserID()));
+ List<String> id_out = inout.value;
+ assertTrue(id_out.size() == 1);
+ assertTrue("JBOND".equals(id_out.get(0)));
+
+ // Try the call again
+ inout = new Holder<List<String>>(id_in);
+ response = proxy.echo(in, inout);
+ assertTrue(response != null);
+ assertTrue(response.size() == 1);
+ assertTrue("James Bond".equals(response.get(0).getUserID()));
+ id_out = inout.value;
+ assertTrue(id_out.size() == 1);
+ assertTrue("JBOND".equals(id_out.get(0)));
+ }
+
+ /**
+ * Test method that echos a List of beans (List<WSUser>)
+ * and echos a List<String> as an inout parameter.
+ * 1 WSUsers is echo'd
+ * 0 Strings are echo'd
+ */
+ public void testEcho10() throws Exception {
+
+ IGenericService proxy = getProxy("echo");
+
+ List<WSUser> in = new ArrayList<WSUser>();
+ WSUser wsUser = new WSUser();
+ wsUser.setUserID("James Bond");
+ in.add(wsUser);
+
+ List<String> id_in = new ArrayList<String>();
+ Holder<List<String>> inout = new Holder<List<String>>(id_in);
+
+ List<WSUser> response = proxy.echo(in, inout);
+ assertTrue(response != null);
+ assertTrue(response.size() == 1);
+ assertTrue("James Bond".equals(response.get(0).getUserID()));
+ List<String> id_out = inout.value;
+ assertTrue(id_out.size() == 0);
+
+ // Try the call again
+ inout = new Holder<List<String>>(id_in);
+ response = proxy.echo(in, inout);
+ assertTrue(response != null);
+ assertTrue(response.size() == 1);
+ assertTrue("James Bond".equals(response.get(0).getUserID()));
+ id_out = inout.value;
+ assertTrue(id_out.size() == 0);
+ }
+
+ /**
+ * Test method that echos a List of beans (List<WSUser>)
+ * and echos a List<String> as an inout parameter.
+ * 0 WSUsers are echo'd
+ * 1 Strings is echo'd
+ */
+ public void testEcho01() throws Exception {
+
+ IGenericService proxy = getProxy("echo");
+
+ List<WSUser> in = new ArrayList<WSUser>();
+
+ List<String> id_in = new ArrayList<String>();
+ id_in.add("jbond");
+ Holder<List<String>> inout = new Holder<List<String>>(id_in);
+
+ List<WSUser> response = proxy.echo(in, inout);
+ assertTrue(response != null);
+ assertTrue(response.size() == 0);
+ List<String> id_out = inout.value;
+ assertTrue(id_out.size() == 1);
+ assertTrue("JBOND".equals(id_out.get(0)));
+
+ // Try the call again
+ inout = new Holder<List<String>>(id_in);
+ response = proxy.echo(in, inout);
+ assertTrue(response != null);
+ assertTrue(response.size() == 0);
+ id_out = inout.value;
+ assertTrue(id_out.size() == 1);
+ assertTrue("JBOND".equals(id_out.get(0)));
+ }
+
+ /**
+ * Test method that echos a List of beans (List<WSUser>)
+ * and echos a List<String> as an inout parameter.
+ * 0 WSUsers are echo'd
+ * 0 Strings are echo'd
+ */
+ public void testEcho00() throws Exception {
+
+ IGenericService proxy = getProxy("echo");
+
+ List<WSUser> in = new ArrayList<WSUser>();
+
+ List<String> id_in = new ArrayList<String>();
+ Holder<List<String>> inout = new Holder<List<String>>(id_in);
+
+ List<WSUser> response = proxy.echo(in, inout);
+ assertTrue(response != null);
+ assertTrue(response.size() == 0);
+ List<String> id_out = inout.value;
+ assertTrue(id_out.size() == 0);
+
+ // Try the call again
+ inout = new Holder<List<String>>(id_in);
+ response = proxy.echo(in, inout);
+ assertTrue(response != null);
+ assertTrue(response.size() == 0);
+ id_out = inout.value;
+ assertTrue(id_out.size() == 0);
+ }
+}
Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DLWMinTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DLWMinTests.java?rev=829296&r1=829295&r2=829296&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DLWMinTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/DLWMinTests.java Sat Oct 24 01:46:13 2009
@@ -35,6 +35,13 @@
import javax.xml.ws.Service;
import javax.xml.ws.WebServiceException;
+/**
+ *
+ * Tests to verify Document/Literal Wrapped Minimal Scenarios
+ * Document/Literal Wrapped is a JAX-WS style.
+ * "Minimal" indicates that no wrapper beans are associated with the JAX-WS method.
+ * In most enterprise scenarios, wrapper beans are packaged with the JAX-WS application.
+ */
public class DLWMinTests extends AbstractTestCase {
private static final String NAMESPACE = "http://apache.org/axis2/jaxws/sample/dlwmin";
@@ -126,7 +133,7 @@
}
/**
- * Test simple greetMe method
+ * Test simpleTest method
* with style doc/lit wrapped without the presence of wrapper classes.
*/
public void testSimpleTest() {
@@ -134,22 +141,25 @@
Greeter proxy = getProxy("simpleTest");
String name = "user1";
- byte[] bytes = new byte[100];
+ byte[] bytes = new byte[5];
+ for (int i=0; i< bytes.length; i++) {
+ bytes[i] = (byte) i;
+ }
String response = proxy.simpleTest(name, bytes);
System.out.println(response);
assertTrue(response.contains("name=user1"));
- assertTrue(response.contains("numbytes=100"));
+ assertTrue(response.contains("numbytes=5"));
// Try the call again
response = proxy.simpleTest(name, bytes);
System.out.println(response);
assertTrue(response.contains("name=user1"));
- assertTrue(response.contains("numbytes=100"));
+ assertTrue(response.contains("numbytes=5"));
}
/**
- * Test simple greetMe method
+ * Test simpleTest method
* with style doc/lit wrapped without the presence of wrapper classes.
*/
public void testSimpleTestNoName() {
@@ -173,7 +183,7 @@
}
/**
- * Test simple greetMe method with dispatch
+ * Test simpleTest method with dispatch
* with style doc/lit wrapped without the presence of wrapper classes.
*/
public void testSimple_Dispatch() {
@@ -183,7 +193,9 @@
String request =
"<pre:simpleTest xmlns:pre='http://apache.org/axis2/jaxws/sample/dlwmin'>" +
"<pre:name>user1</pre:name>" +
- "<pre:bytes>AAAAAA</pre:bytes>" +
+ "<pre:bytes>1</pre:bytes>" +
+ "<pre:bytes>2</pre:bytes>" +
+ "<pre:bytes>3</pre:bytes>" +
"</pre:simpleTest>";
TestLogger.logger.debug("Doc/Lit Wrapped Minimal Request =" + request);
String response = dispatch.invoke(request);
@@ -205,7 +217,7 @@
}
/**
- * Test simple greetMe method with dispatch
+ * Test simpleTest method with dispatch
* with style doc/lit wrapped without the presence of wrapper classes.
*/
public void testSimpleNoName_Dispatch() {
@@ -214,7 +226,9 @@
String request =
"<pre:simpleTest xmlns:pre='http://apache.org/axis2/jaxws/sample/dlwmin'>" +
- "<pre:bytes>AAAAAA</pre:bytes>" +
+ "<pre:bytes>1</pre:bytes>" +
+ "<pre:bytes>2</pre:bytes>" +
+ "<pre:bytes>3</pre:bytes>" +
"</pre:simpleTest>";
TestLogger.logger.debug("Doc/Lit Wrapped Minimal Request =" + request);
String response = dispatch.invoke(request);
@@ -237,7 +251,7 @@
/**
- * Test simple greetMe method
+ * Test simpleUnqualified method
* with style doc/lit wrapped without the presence of wrapper classes.
*/
public void testUnqualified() {
@@ -254,7 +268,7 @@
}
/**
- * Test simple greetMe method with dispatch
+ * Test simpleUnqualified method with dispatch
* with style doc/lit wrapped without the presence of wrapper classes.
*/
public void testUnqualified_Dispatch() {
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/ComplexArrayResponse.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/ComplexArrayResponse.java?rev=829296&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/ComplexArrayResponse.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/ComplexArrayResponse.java Sat Oct 24 01:46:13 2009
@@ -0,0 +1,45 @@
+/*
+ * 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.axis2.jaxws.sample.dlwminArrays;
+
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "complexArrayReturn"
+})
+@XmlRootElement(name = "complexArrayResponse")
+public class ComplexArrayResponse {
+ @XmlElement(name="complexArrayReturn", namespace="http://apache.org/axis2/jaxws/sample/dlwminArrays", required=false)
+ protected WSUser[] complexArrayReturn;
+
+ public WSUser[] getComplexArrayReturn() {
+ return complexArrayReturn;
+ }
+
+ public void setComplexArrayReturn(WSUser[] complexArrayReturn) {
+ this.complexArrayReturn = complexArrayReturn;
+ }
+
+}
\ No newline at end of file
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/ComplexListResponse.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/ComplexListResponse.java?rev=829296&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/ComplexListResponse.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/ComplexListResponse.java Sat Oct 24 01:46:13 2009
@@ -0,0 +1,47 @@
+/*
+ * 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.axis2.jaxws.sample.dlwminArrays;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "complexListReturn"
+})
+@XmlRootElement(name = "complexListResponse")
+public class ComplexListResponse {
+ @XmlElement(name="complexListReturn", namespace="http://apache.org/axis2/jaxws/sample/dlwminArrays", required=false)
+ protected List<WSUser> complexListReturn;
+
+ public List<WSUser> getComplexListReturn() {
+ return complexListReturn;
+ }
+
+ public void setComplexListReturn(List<WSUser> complexListReturn) {
+ this.complexListReturn = complexListReturn;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/GenericService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/GenericService.java?rev=829296&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/GenericService.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/GenericService.java Sat Oct 24 01:46:13 2009
@@ -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.axis2.jaxws.sample.dlwminArrays;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.ws.Holder;
+
+
+@javax.jws.WebService (endpointInterface="org.apache.axis2.jaxws.sample.dlwminArrays.IGenericService",
+ targetNamespace="http://apache.org/axis2/jaxws/sample/dlwminArrays",
+ serviceName="GenericService",
+ portName="GenericServicePort")
+public class GenericService implements IGenericService {
+
+ public String sayHello(String text) {
+ return "Hello " + text;
+ }
+
+ public WSUser[] getComplexArray() {
+ WSUser[] result = new WSUser[2];
+ result[0] = new WSUser("first");
+ result[1] = new WSUser("second");
+ return result;
+ }
+
+ public List<WSUser> getComplexList() {
+ List<WSUser> result = new ArrayList<WSUser>();
+ result.add(new WSUser("first"));
+ result.add(new WSUser("second"));
+ return result;
+ }
+
+ public String[] getSimpleArray() {
+ String[] result = new String[2];
+ result[0] = "first";
+ result[1] = "second";
+ return result;
+ }
+
+ public List<String> getSimpleList() {
+ List<String> result = new ArrayList<String>();
+ result.add("first");
+ result.add("second");
+ return result;
+ }
+
+ public List<WSUser> echoComplexList(List<WSUser> in ) {
+ return in;
+ }
+
+ public List<WSUser> echo(List<WSUser> in, Holder<List<String>> ids) {
+ List<String> l = ids.value;
+ if (l != null) {
+ for (int i=0; i< l.size(); i++) {
+ String text = l.get(i).toUpperCase();
+ l.set(i, text);
+ }
+ }
+ return in;
+ }
+}
+
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/IGenericService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/IGenericService.java?rev=829296&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/IGenericService.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/IGenericService.java Sat Oct 24 01:46:13 2009
@@ -0,0 +1,63 @@
+/*
+ * 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.axis2.jaxws.sample.dlwminArrays;
+
+import java.util.List;
+
+import javax.jws.WebMethod;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+import javax.xml.ws.ResponseWrapper;
+
+@WebService(name = "GenericService", targetNamespace = "http://apache.org/axis2/jaxws/sample/dlwminArrays")
+public interface IGenericService {
+
+ @WebMethod
+ public String sayHello(String text);
+
+ @WebMethod
+ @WebResult(name = "simpleArrayReturn", targetNamespace = "http://apache.org/axis2/jaxws/sample/dlwminArrays")
+ @ResponseWrapper(className = "org.apache.axis2.jaxws.sample.dlwminArrays.SimpleArrayResponse")
+ public String[] getSimpleArray();
+
+ @WebResult(name = "complexArrayReturn", targetNamespace = "http://apache.org/axis2/jaxws/sample/dlwminArrays")
+ @ResponseWrapper(className = "org.apache.axis2.jaxws.sample.dlwminArrays.ComplexArrayResponse")
+ public WSUser[] getComplexArray();
+
+ @WebResult(name = "simpleListReturn", targetNamespace = "http://apache.org/axis2/jaxws/sample/dlwminArrays")
+ @ResponseWrapper(className = "org.apache.axis2.jaxws.sample.dlwminArrays.SimpleListResponse")
+ public List<String> getSimpleList();
+
+ @WebResult(name = "complexListReturn", targetNamespace = "http://apache.org/axis2/jaxws/sample/dlwminArrays")
+ @ResponseWrapper(className = "org.apache.axis2.jaxws.sample.dlwminArrays.ComplexListResponse" ,
+ localName="complexListResponse",
+ targetNamespace="http://apache.org/axis2/jaxws/sample/dlwminArrays")
+ public List<WSUser> getComplexList();
+
+ @WebResult(name = "echoComplexListReturn", targetNamespace = "http://apache.org/axis2/jaxws/sample/dlwminArrays")
+ public List<WSUser> echoComplexList(List<WSUser> in );
+
+ @WebResult(name = "echo", targetNamespace = "http://apache.org/axis2/jaxws/sample/dlwminArrays")
+ public List<WSUser> echo(List<WSUser> in, Holder<List<String>> ids);
+
+
+
+}
\ No newline at end of file
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/SimpleArrayResponse.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/SimpleArrayResponse.java?rev=829296&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/SimpleArrayResponse.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/SimpleArrayResponse.java Sat Oct 24 01:46:13 2009
@@ -0,0 +1,45 @@
+/*
+ * 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.axis2.jaxws.sample.dlwminArrays;
+
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "simpleArrayReturn"
+})
+@XmlRootElement(name = "simpleArrayResponse")
+public class SimpleArrayResponse {
+ @XmlElement(name="simpleArrayReturn", namespace="http://apache.org/axis2/jaxws/sample/dlwminArrays", required=false)
+ protected String[] simpleArrayReturn;
+
+ public String[] getSimpleArrayReturn() {
+ return simpleArrayReturn;
+ }
+
+ public void setSimpleArrayReturn(String[] simpleArrayReturn) {
+ this.simpleArrayReturn = simpleArrayReturn;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/SimpleListResponse.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/SimpleListResponse.java?rev=829296&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/SimpleListResponse.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/SimpleListResponse.java Sat Oct 24 01:46:13 2009
@@ -0,0 +1,47 @@
+/*
+ * 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.axis2.jaxws.sample.dlwminArrays;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "simpleListReturn"
+})
+@XmlRootElement(name = "simpleListResponse")
+public class SimpleListResponse {
+ @XmlElement(name="simpleListReturn", namespace="http://apache.org/axis2/jaxws/sample/dlwminArrays", required=false)
+ protected List<String> simpleListReturn = new java.util.ArrayList<String>();
+
+ public List<String> getSimpleListReturn() {
+ return simpleListReturn;
+ }
+
+ public void setSimpleListReturn(List<String> simpleListReturn) {
+ this.simpleListReturn = simpleListReturn;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/WSUser.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/WSUser.java?rev=829296&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/WSUser.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/dlwminArrays/WSUser.java Sat Oct 24 01:46:13 2009
@@ -0,0 +1,52 @@
+/*
+ * 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.axis2.jaxws.sample.dlwminArrays;
+
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "WSUser", namespace = "http://apache.org/axis2/jaxws/sample/dlwminArrays", propOrder = {
+ "userID"
+})
+
+public class WSUser {
+ @XmlElement(required = true, nillable = true)
+ protected String userID;
+
+ public WSUser() {
+ }
+
+ public WSUser(String uid) {
+ userID = uid;
+ }
+
+ public java.lang.String getUserID() {
+ return userID;
+ }
+
+ public void setUserID(String userID) {
+ this.userID = userID;
+ }
+
+
+}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java?rev=829296&r1=829295&r2=829296&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java Sat Oct 24 01:46:13 2009
@@ -23,6 +23,7 @@
import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.java.security.AccessController;
+import org.apache.axis2.jaxws.message.OccurrenceArray;
import org.apache.axis2.jaxws.message.databinding.JAXBUtils;
import org.apache.axis2.jaxws.message.util.XMLStreamWriterWithOS;
import org.apache.axis2.jaxws.spi.Constants;
@@ -32,6 +33,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import com.ibm.keymanager.audit.m;
+
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
@@ -139,6 +142,7 @@
}
public JAXBContext getJAXBContext() throws JAXBException {
+
return getJAXBContext(null);
}
@@ -147,6 +151,16 @@
* @throws JAXBException
*/
public JAXBContext getJAXBContext(ClassLoader cl) throws JAXBException {
+ return getJAXBContext(null, false);
+ }
+
+ /**
+ * @param ClassLoader
+ * @param forceArrays boolean (if true, then JAXBContext will automatically contain arrays)
+ * @return get the JAXBContext
+ * @throws JAXBException
+ */
+ public JAXBContext getJAXBContext(ClassLoader cl, boolean forceArrays) throws JAXBException {
if (customerJAXBContext != null) {
return customerJAXBContext;
}
@@ -157,10 +171,19 @@
jc = autoJAXBContext.get();
}
+ if (forceArrays &&
+ jc != null &&
+ constructionType != JAXBUtils.CONSTRUCTION_TYPE.BY_CLASS_ARRAY_PLUS_ARRAYS) {
+ if (log.isDebugEnabled()) {
+ log.debug("A JAXBContext exists but it was not constructed with array class. " +
+ "The JAXBContext will be rebuilt.");
+ }
+ jc = null;
+ }
+
if (jc == null) {
if (log.isDebugEnabled()) {
- log.debug(
- "A JAXBContext did not exist, creating a new one with the context packages.");
+ log.debug("Creating a JAXBContext with the context packages.");
}
Holder<JAXBUtils.CONSTRUCTION_TYPE> constructType =
new Holder<JAXBUtils.CONSTRUCTION_TYPE>();
@@ -168,7 +191,7 @@
/*
* We set the default namespace to the web service namespace to fix an
- * obscur bug.
+ * obscure bug.
*
* If the class representing a JAXB data object does not define a namespace
* (via an annotation like @XmlType or via ObjectFactory or schema gen information)
@@ -187,7 +210,7 @@
properties = new HashMap<String, Object>();
properties.put(JAXBUtils.DEFAULT_NAMESPACE_REMAP, this.webServiceNamespace);
}
- jc = JAXBUtils.getJAXBContext(contextPackages, constructType,
+ jc = JAXBUtils.getJAXBContext(contextPackages, constructType, forceArrays,
contextPackagesKey, cl, properties);
constructionType = constructType.value;
autoJAXBContext = new WeakReference<JAXBContext>(jc);
@@ -321,13 +344,17 @@
*/
public void marshal(Object obj,
XMLStreamWriter writer) throws JAXBException {
+ if (log.isDebugEnabled()) {
+ log.debug("enter marshal");
+ }
// There may be a preferred classloader that should be used
ClassLoader cl = getClassLoader();
// Very easy, use the Context to get the Marshaller.
// Use the marshaller to write the object.
- Marshaller m = JAXBUtils.getJAXBMarshaller(getJAXBContext(cl));
+ JAXBContext jbc = getJAXBContext(cl);
+ Marshaller m = JAXBUtils.getJAXBMarshaller(jbc);
if (writer instanceof MTOMXMLStreamWriter && ((MTOMXMLStreamWriter) writer).getOutputFormat() != null) {
String encoding = ((MTOMXMLStreamWriter) writer).getOutputFormat().getCharSetEncoding();
if (encoding != null && !"UTF-8".equalsIgnoreCase(encoding)) {
@@ -364,9 +391,12 @@
getConstructionType(),
true); // Attempt to optimize by writing to OutputStream
}
-
- // Successfully marshalled the data
- JAXBUtils.releaseJAXBMarshaller(getJAXBContext(cl), m);
+
+ JAXBUtils.releaseJAXBMarshaller(jbc, m);
+
+ if (log.isDebugEnabled()) {
+ log.debug("exit marshal");
+ }
}
@@ -416,8 +446,17 @@
}});
}
+ /**
+ * Print out the name of the class of the specified object
+ * @param o Object
+ * @return text to use for debugging
+ */
private static String getDebugName(Object o) {
- return (o == null) ? "null" : o.getClass().getCanonicalName();
+ String name = (o == null) ? "null" : o.getClass().getCanonicalName();
+ if (o instanceof JAXBElement) {
+ name += " containing " + getDebugName(((JAXBElement) o).getValue());
+ }
+ return name;
}
/**
@@ -671,7 +710,7 @@
if (DEBUG_ENABLED) {
- log.debug("Invoking unmarshaArray");
+ log.debug("Invoking unmarshalAsListOrArray");
}
// If this is an xsd:list, we need to return the appropriate
@@ -722,6 +761,11 @@
return obj;
}
+ private static boolean isOccurrenceArray(Object obj) {
+ return (obj instanceof JAXBElement) &&
+ (((JAXBElement)obj).getValue() instanceof OccurrenceArray);
+
+ }
/**
* Marshal objects by type
*
@@ -735,12 +779,26 @@
* @param optimize boolean set to true if optimization directly to
* outputstream should be attempted.
*/
- private static void marshalByType(final Object b, final Marshaller m,
+ private void marshalByType(final Object b, final Marshaller m,
final XMLStreamWriter writer, final Class type,
final boolean isList,
final JAXBUtils.CONSTRUCTION_TYPE ctype,
final boolean optimize)
throws WebServiceException {
+ if (log.isDebugEnabled()) {
+ log.debug("Enter marshalByType b=" + getDebugName(b) +
+ " type=" + type +
+ " marshaller=" + m +
+ " writer=" + writer +
+ " isList=" + isList +
+ " ctype=" + ctype +
+ " optimize=" + optimize);
+
+ }
+ if (isOccurrenceArray(b)) {
+ marshalOccurrenceArray((JAXBElement) b, m, writer);
+ return;
+ }
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
@@ -772,7 +830,7 @@
// <foo>1 2 3</foo>
Object jbo = b;
if(DEBUG_ENABLED){
- log.debug("check if marshalling type list or array object type = "+ (( b!=null )? b.getClass().getName():"null"));
+ log.debug("check if marshalling list or array object, type = "+ (( b!=null )? b.getClass().getName():"null"));
}
if (isList) {
if (DEBUG_ENABLED) {
@@ -861,6 +919,85 @@
}
/**
+ * Marshal array objects by type
+ *
+ * Invoke marshalByType for each element in the array
+ *
+ * @param jaxb_in JAXBElement containing a value that is a List or array
+ * @param m_in Marshaller
+ * @param writer_in XMLStreamWriter
+ */
+ private void marshalOccurrenceArray(
+ final JAXBElement jbe_in,
+ final Marshaller m_in,
+ final XMLStreamWriter writer_in) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Enter marshalOccurrenceArray");
+ log.debug(" Marshaller = " + JavaUtils.getObjectIdentity(m_in));
+ }
+
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ try {
+
+ Marshaller m = m_in;
+ JAXBContext newJBC = null;
+ if (getConstructionType() != JAXBUtils.CONSTRUCTION_TYPE.BY_CLASS_ARRAY_PLUS_ARRAYS) {
+ // Rebuild JAXBContext
+ // There may be a preferred classloader that should be used
+ if (log.isDebugEnabled()) {
+ log.debug("Building a JAXBContext with array capability");
+ }
+ ClassLoader cl = getClassLoader();
+ newJBC = getJAXBContext(cl, true);
+ m = JAXBUtils.getJAXBMarshaller(newJBC);
+ if (log.isDebugEnabled()) {
+ log.debug("The new JAXBContext was constructed with " + getConstructionType());
+ }
+ }
+
+
+ OccurrenceArray occurArray = (OccurrenceArray) jbe_in.getValue();
+
+ // Create a new JAXBElement.
+ // The name is the name of the individual occurence elements
+ // Type type is Object[]
+ // The value is the array of Object[] representing each element
+ JAXBElement jbe = new JAXBElement(jbe_in.getName(),
+ Object[].class,
+ occurArray.getAsArray());
+
+ // The jaxb marshal command cannot write out a list/array
+ // of occurence elements. So we marshal it as a single
+ // element containing items...and then put a filter on the
+ // writer to transform it into a stream of occurence elements
+ XMLStreamWriterArrayFilter writer = new XMLStreamWriterArrayFilter(writer_in);
+
+
+ m.marshal(jbe, writer);
+
+ if (newJBC != null) {
+ JAXBUtils.releaseJAXBMarshaller(newJBC, m);
+ }
+
+ return null;
+ } catch (OMException e) {
+ throw e;
+ } catch (Throwable t) {
+ throw new OMException(t);
+ }
+ }
+ });
+
+
+ if (log.isDebugEnabled()) {
+ log.debug("Exit marshalOccurrenceArray");
+ }
+
+ }
+
+ /**
* Preferred way to unmarshal objects
*
* @param u Unmarshaller
Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/XMLStreamWriterArrayFilter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/XMLStreamWriterArrayFilter.java?rev=829296&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/XMLStreamWriterArrayFilter.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/XMLStreamWriterArrayFilter.java Sat Oct 24 01:46:13 2009
@@ -0,0 +1,453 @@
+/*
+ * 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.axis2.datasource.jaxb;
+
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * In some cases, we want to marshal an array of objects as a series
+ * of elements instead of a single element containing items.
+ *
+ * Unfortunately there is no way to tell the JAXB marshal method to
+ * marshal an array or List as a series of elements.
+ *
+ * Instead, we use the JAXB marshal method to output a single element
+ * with items and then filter the write events to transform it into
+ * a series of elements.
+ *
+ * Thus
+ * <myElement>
+ * <item>Hello</item>
+ * <item>World</item>
+ * </myElement>
+ * Becomes
+ * <myElement>Hello</myElement>
+ * <myElement>World</myElement>
+ *
+ * Special care is taken to ensure that namespace declarations are property preserved.
+ */
+public class XMLStreamWriterArrayFilter implements XMLStreamWriter {
+ private static final Log log = LogFactory.getLog(XMLStreamWriterArrayFilter.class);
+ XMLStreamWriter writer;
+ int depth = 0;
+ boolean isBuffering = true;
+ List<List<String>> bufferedCommands = new ArrayList<List<String>>();
+
+ // The extensive debug was used during development but is not necessary in production.
+ // Change DEBUG_ENABLED = log.isDebugEnabled();
+ // to get extensive debug output.
+ private static boolean DEBUG_ENABLED = false;
+
+ private static final String XSI_URI = "http://www.w3.org/2001/XMLSchema-instance";
+
+
+ public XMLStreamWriterArrayFilter(XMLStreamWriter writer)
+ throws XMLStreamException {
+ super();
+ if (DEBUG_ENABLED) {
+ log.debug("XMLStreamWriterArrayFilter " + writer);
+ }
+ this.writer = writer;
+ }
+
+ public void close() throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("close");
+ }
+ if (writer != null) {
+ writer.close();
+ }
+ }
+
+ public void flush() throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("flush");
+ }
+ if (writer != null) {
+ writer.flush();
+ }
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ if (DEBUG_ENABLED) {
+ log.debug("getNamespaceContext");
+ }
+ return writer.getNamespaceContext();
+ }
+
+ public String getPrefix(String arg0) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("getPrefix " + arg0);
+ }
+ return writer.getPrefix(arg0);
+ }
+
+ public Object getProperty(String arg0) throws IllegalArgumentException {
+ if (DEBUG_ENABLED) {
+ log.debug("getProperty " + arg0);
+ }
+ return writer.getProperty(arg0);
+ }
+
+ public void setDefaultNamespace(String arg0) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("setDefaultNamespace " + arg0);
+ }
+ writer.setDefaultNamespace(arg0);
+ }
+
+ public void setNamespaceContext(NamespaceContext arg0) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("setNamespaceContext " + arg0);
+ }
+ writer.setNamespaceContext(arg0);
+ }
+
+ public void setPrefix(String arg0, String arg1) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("setPrefix " + arg0 + " " + arg1);
+ }
+ writer.setPrefix(arg0, arg1);
+ }
+
+ public void writeAttribute(String prefix, String uri, String localName, String value)
+ throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeAttribute " + prefix + " " + uri + " " + localName + " " + value);
+ }
+ writer.writeAttribute(prefix, uri, localName, value);
+ }
+
+ public void writeAttribute(String arg0, String arg1, String arg2)
+ throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeAttribute " + arg0 + " " + arg1 + " " + arg2 );
+ }
+ writer.writeAttribute(arg0, arg1, arg2);
+ }
+
+ public void writeAttribute(String arg0, String arg1) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeAttribute " + arg0 + " " + arg1);
+ }
+ writer.writeAttribute(arg0, arg1);
+ }
+
+ public void writeCData(String arg0) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeCData " + arg0 );
+ }
+ writer.writeCData(arg0);
+ }
+
+ public void writeCharacters(char[] arg0, int arg1, int arg2)
+ throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeCharacters " + arg0 + " " + arg1 + " " + arg2 );
+ }
+ writer.writeCharacters(arg0, arg1, arg2);
+ }
+
+ public void writeCharacters(String arg0) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeCharacters " + arg0);
+ }
+ writer.writeCharacters(arg0);
+ }
+
+ public void writeComment(String arg0) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeComment " + arg0 );
+ }
+ writer.writeComment(arg0);
+ }
+
+ public void writeDefaultNamespace(String uri) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeDefaultNamespace (" + uri + ")" );
+ }
+
+ if (isBuffering) {
+ if (DEBUG_ENABLED) {
+ log.debug(" Supress writeDefaultNamespace on top element");
+ }
+ } else if (depth >= 2) {
+ writer.writeDefaultNamespace(uri);
+ }
+ }
+
+ public void writeDTD(String arg0) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeDTD " + arg0 );
+ }
+ writer.writeDTD(arg0);
+ }
+
+ public void writeEmptyElement(String arg0, String arg1, String arg2)
+ throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeEmptyElement" + arg0 + " " + arg1 + " " + arg2 );
+ }
+ writeStartElement(arg0, arg1, arg2);
+ writeEndElement();
+ }
+
+ public void writeEmptyElement(String arg0, String arg1) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeEmptyElement " + arg0 + " " + arg1);
+ }
+ writeStartElement(arg0, arg1);
+ writeEndElement();
+ }
+
+ public void writeEmptyElement(String arg0) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeEmptyElement " + arg0 );
+ }
+ writeStartElement(arg0);
+ writeEndElement();
+ }
+
+ public void writeEndDocument() throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeEndDocument " );
+ }
+ writer.writeEndDocument();
+ }
+
+ public void writeEndElement() throws XMLStreamException {
+ depth--;
+ if (DEBUG_ENABLED) {
+ log.debug("writeEndElement " );
+ }
+ if (depth != 0) {
+ writer.writeEndElement();
+ } else {
+ if (DEBUG_ENABLED) {
+ log.debug(" Suppress writeEndElement for the top element..but performing a flush");
+ }
+ writer.flush();
+ }
+ }
+
+ public void writeEntityRef(String arg0) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeEntityRef " + arg0 );
+ }
+ writer.writeEntityRef(arg0);
+ }
+
+ public void writeNamespace(String prefix, String uri) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeNamespace (" + prefix + ") (" + uri + ")" );
+ }
+
+ // The namespaces are buffered while reading the root element.
+ // They will be written out by writeCommands when the child
+ // elements are encountered.
+ if (isBuffering) {
+ if ("".equals(prefix)) {
+ if (DEBUG_ENABLED) {
+ log.debug(" Supress default write namespace on top element to avoid collision");
+ }
+ } else {
+ List<String> command = new ArrayList<String>();
+ command.add("writeNamespace");
+ command.add(prefix);
+ command.add(uri);
+ bufferCommand(command);
+ }
+ } else if (depth == 2 && XSI_URI.equals(uri) && "xsi".equals(prefix)) {
+ // The operation element already has an xsi namespace declaration;
+ // thus this one is redundant and only makes the message larger.
+ if (DEBUG_ENABLED) {
+ log.debug(" Supressing xsi namespace declaration on array item");
+ }
+ } else if (depth >= 2) {
+ writer.writeNamespace(prefix, uri);
+ }
+ }
+
+ public void writeProcessingInstruction(String arg0, String arg1)
+ throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeProcessingInstruction " + arg0 + " " + arg1 );
+ }
+ writer.writeProcessingInstruction(arg0, arg1);
+ }
+
+ public void writeProcessingInstruction(String arg0) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeProcessingInstruction " + arg0);
+ }
+ writer.writeProcessingInstruction(arg0);
+ }
+
+ public void writeStartDocument() throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeStartDocument " );
+ }
+ writer.writeStartDocument();
+ }
+
+ public void writeStartDocument(String arg0, String arg1) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeStartDocument " + arg0 + " " + arg1 );
+ }
+ writer.writeStartDocument(arg0, arg1);
+ }
+
+ public void writeStartDocument(String arg0) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeStartDocument " + arg0 );
+ }
+ writer.writeStartDocument(arg0);
+ }
+
+ public void writeStartElement(String arg0, String arg1, String arg2)
+ throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeStartElement " + arg0 + " " + arg1 + " " + arg2 );
+ }
+ depth++;
+ if (depth > 1) {
+ isBuffering = false;
+ }
+
+ // The start element is buffered when we encounter the
+ // outermost element. The buffered event is written
+ // (instead of the child element tag).
+ if (isBuffering) {
+ List<String> command = new ArrayList<String>();
+ command.add("writeStartElement");
+ command.add(arg0);
+ command.add(arg1);
+ command.add(arg2);
+ bufferCommand(command);
+ } else if (depth == 2) {
+ writeCommands();
+ } else {
+ writer.writeStartElement(arg0, arg1, arg2);
+ }
+
+ }
+
+ public void writeStartElement(String arg0, String arg1) throws XMLStreamException {
+ if (DEBUG_ENABLED) {
+ log.debug("writeStartElement " + arg0 + " " + arg1);
+ }
+ depth++;
+ if (depth > 1) {
+ isBuffering = false;
+ }
+
+ // The start element is buffered when we encounter the
+ // outermost element. The buffered event is written
+ // (instead of the child element tag).
+ if (isBuffering) {
+ List<String> command = new ArrayList<String>();
+ command.add("writeStartElement");
+ command.add(arg0);
+ command.add(arg1);
+ bufferCommand(command);
+ } else if (depth == 2) {
+ writeCommands();
+ } else {
+ writer.writeStartElement(arg0, arg1);
+ }
+ }
+
+ public void writeStartElement(String arg0) throws XMLStreamException {
+
+ if (DEBUG_ENABLED) {
+ log.debug("writeStartElement " + arg0 );
+ }
+ depth++;
+ if (depth > 1) {
+ isBuffering = false;
+ }
+
+
+ // The start element is buffered when we encounter the
+ // outermost element. The buffered event is written
+ // (instead of the child element tag).
+ if (isBuffering) {
+ List<String> command = new ArrayList<String>();
+ command.add("writeStartElement");
+ command.add(arg0);
+ bufferCommand(command);
+ } else if (depth == 2) {
+ writeCommands();
+ } else {
+ writer.writeStartElement(arg0);
+ }
+ }
+
+ void bufferCommand(List<String> command) {
+ if (DEBUG_ENABLED) {
+ log.debug(" Buffering command " + command);
+ }
+ bufferedCommands.add(command);
+ }
+
+ void writeCommands() throws XMLStreamException {
+ for (int i=0;i<bufferedCommands.size(); i++) {
+ List<String> command = bufferedCommands.get(i);
+ String m = command.get(0);
+ if ("writeNamespace".equals(m)) {
+ if (DEBUG_ENABLED) {
+ log.debug(" Sending buffered writeNamespace " + command.get(1) +
+ " " + command.get(2));
+ }
+ writer.writeNamespace(command.get(1), command.get(2));
+ } else if ("writeStartElement".equals(m)) {
+ int len = command.size();
+ if (len == 2) {
+ if (DEBUG_ENABLED) {
+ log.debug(" Sending buffered writeStartElement " + command.get(1));
+ }
+ writer.writeStartElement(command.get(1));
+ } else if (len ==3) {
+ if (DEBUG_ENABLED) {
+ log.debug(" Sending buffered writeStartElement " + command.get(1) +
+ " " + command.get(2));
+ }
+ writer.writeStartElement(command.get(1), command.get(2));
+ } else if (len == 4) {
+ if (DEBUG_ENABLED) {
+ log.debug(" Sending buffered writeStartElement " + command.get(1) +
+ " " + command.get(2) + " " + command.get(3));
+ }
+ writer.writeStartElement(command.get(1), command.get(2), command.get(3));
+ }
+ }
+ }
+ }
+
+}