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 de...@apache.org on 2006/09/04 11:22:15 UTC
svn commit: r439991 - in /webservices/axis2/trunk/java/modules:
adb/src/org/apache/axis2/databinding/utils/
codegen/src/org/apache/axis2/rpc/receivers/
integration/test/org/apache/axis2/rpc/
java2wsdl/src/org/apache/ws/java2wsdl/ java2wsdl/src/org/apac...
Author: deepal
Date: Mon Sep 4 02:22:12 2006
New Revision: 439991
URL: http://svn.apache.org/viewvc?view=rev&rev=439991
Log:
fixing AXIS2-831
Modified:
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCInOutAsyncMessageReceiver.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/TypeTable.java
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java?view=diff&rev=439991&r1=439990&r2=439991
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java Mon Sep 4 02:22:12 2006
@@ -23,6 +23,7 @@
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
+import org.apache.axiom.om.util.Base64;
import org.apache.axis2.AxisFault;
import org.apache.axis2.databinding.typemapping.SimpleTypeMapper;
import org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl;
@@ -392,7 +393,12 @@
boolean done = true;
ArrayList valueList = new ArrayList();
Class arrayClassType = classType.getComponentType();
- valueList.add(processObject(omElement, arrayClassType, helper));
+ if ("byte".equals(arrayClassType.getName())) {
+ retObjs[count] = processObject(omElement, arrayClassType, helper, true);
+ return null;
+ } else {
+ valueList.add(processObject(omElement, arrayClassType, helper, true));
+ }
while (parts.hasNext()) {
objValue = parts.next();
if (objValue instanceof OMElement) {
@@ -405,7 +411,7 @@
break;
}
Object o = processObject(omElement, arrayClassType,
- helper);
+ helper, true);
valueList.add(o);
}
retObjs[count] = ConverterUtil.convertToArray(arrayClassType,
@@ -415,14 +421,14 @@
}
} else {
//handling refs
- retObjs[count] = processObject(omElement, classType, helper);
+ retObjs[count] = processObject(omElement, classType, helper, false);
}
return null;
}
public static Object processObject(OMElement omElement,
Class classType,
- MultirefHelper helper) throws AxisFault {
+ MultirefHelper helper, boolean isArrayType) throws AxisFault {
boolean hasRef = false;
OMAttribute omatribute = MultirefHelper.processRefAtt(omElement);
String ref = null;
@@ -454,7 +460,12 @@
return null;
}
if (SimpleTypeMapper.isSimpleType(classType)) {
- return SimpleTypeMapper.getSimpleTypeObject(classType, omElement);
+ if (isArrayType && "byte".equals(classType.getName())) {
+ String value = omElement.getText();
+ return Base64.decode(value);
+ } else {
+ return SimpleTypeMapper.getSimpleTypeObject(classType, omElement);
+ }
} else if (SimpleTypeMapper.isArrayList(classType)) {
return SimpleTypeMapper.getArrayList(omElement);
} else {
@@ -533,6 +544,8 @@
wrappingElement.addChild((OMElement) arg);
}
objects.add(wrappingElement);
+ } else if (arg instanceof byte[]) {
+ objects.add(Base64.encode((byte[]) arg));
} else {
objects.add(arg);
}
@@ -554,7 +567,8 @@
/**
* @deprecated Please use getUniquePrefix
*/
- public static String getUniquePrifix() {
+ public static String getUniquePrifix
+ () {
return "ns" + nsCount++;
}
@@ -563,7 +577,8 @@
*
* @return unique prefix
*/
- public static String getUniquePrefix() {
+ public static String getUniquePrefix
+ () {
return "ns" + nsCount++;
}
@@ -575,7 +590,9 @@
* @param wrongName
* @return the right name, using english as the locale for case conversion
*/
- private static String getCorrectName(String wrongName) {
+ private static String getCorrectName
+ (String
+ wrongName) {
if (wrongName.length() > 1) {
return wrongName.substring(0, 1).toLowerCase(Locale.ENGLISH)
+ wrongName.substring(1, wrongName.length());
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCInOutAsyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCInOutAsyncMessageReceiver.java?view=diff&rev=439991&r1=439990&r2=439991
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCInOutAsyncMessageReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCInOutAsyncMessageReceiver.java Mon Sep 4 02:22:12 2006
@@ -2,6 +2,7 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.util.Base64;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.AxisFault;
@@ -133,9 +134,15 @@
} else {
if (resObject.getClass().isArray()) {
int length = Array.getLength(resObject);
- Object objArray [] = new Object[length];
- for (int i = 0; i < length; i++) {
- objArray[i] = Array.get(resObject, i);
+ Object objArray [];
+ if (resObject instanceof byte[]) {
+ objArray = new Object[1];
+ objArray[0] = Base64.encode((byte[]) resObject);
+ } else {
+ objArray = new Object[length];
+ for (int i = 0; i < length; i++) {
+ objArray[i] = Array.get(resObject, i);
+ }
}
QName resName = new QName(service.getSchematargetNamespace(),
method.getName() + "Response",
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java?view=diff&rev=439991&r1=439990&r2=439991
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java Mon Sep 4 02:22:12 2006
@@ -23,6 +23,7 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.util.Base64;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.AxisFault;
@@ -147,10 +148,17 @@
} else {
if (resObject.getClass().isArray()) {
int length = Array.getLength(resObject);
- Object objArray [] = new Object[length];
- for (int i = 0; i < length; i++) {
- objArray[i] = Array.get(resObject, i);
+ Object objArray [];
+ if (resObject instanceof byte[]) {
+ objArray = new Object[1];
+ objArray[0] = Base64.encode((byte[]) resObject);
+ } else {
+ objArray = new Object[length];
+ for (int i = 0; i < length; i++) {
+ objArray[i] = Array.get(resObject, i);
+ }
}
+
QName resName = new QName(service.getSchematargetNamespace(),
method.getName() + "Response",
service.getSchematargetNamespacePrefix());
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java?view=diff&rev=439991&r1=439990&r2=439991
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java Mon Sep 4 02:22:12 2006
@@ -87,11 +87,12 @@
protected void setUp() throws Exception {
String className = "org.apache.axis2.rpc.RPCServiceClass";
+ UtilServer.start();
service = AxisService.createService(
className, UtilServer.getConfigurationContext().getAxisConfiguration());
service.setName("EchoXMLService");
service.setClassLoader(Thread.currentThread().getContextClassLoader());
- UtilServer.start();
+
UtilServer.deployService(service);
}
@@ -262,6 +263,26 @@
OMElement response = sender.invokeBlocking(operationName, args.toArray());
assertEquals(Integer.parseInt(response.getFirstElement().getText()), 300);
}
+
+ public void testByteArray() throws AxisFault {
+ configureSystem("testByteArray");
+ ConfigurationContext configContext =
+ ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
+ RPCServiceClient sender = new RPCServiceClient(configContext, null);
+
+ Options options = new Options();
+ options.setTo(targetEPR);
+ options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ sender.setOptions(options);
+ ArrayList args = new ArrayList();
+ String hello = "hello";
+ args.add(hello.getBytes());
+
+ OMElement response = sender.invokeBlocking(operationName, args.toArray());
+ assertEquals(response.getFirstElement().getText(), hello);
+ }
+
+ //
public void testDivide() throws AxisFault {
configureSystem("divide");
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java?view=diff&rev=439991&r1=439990&r2=439991
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java Mon Sep 4 02:22:12 2006
@@ -36,6 +36,7 @@
return bean;
}
+
public MyBean echoBean(MyBean bean) {
return bean;
}
@@ -71,7 +72,7 @@
// child.addChild(fac.createOMText(child, b.getText()));
// bodyContent.addChild(child);
//// bodyContent.addChild(b);
- return (OMElement)b.detach();
+ return (OMElement) b.detach();
}
public double divide(double a, double b) {
@@ -190,7 +191,11 @@
return mail;
}
- public int multiArrays(String [] a, String b [],String d [], int c) {
- return a.length + b.length + d.length+ c;
+ public int multiArrays(String [] a, String b [], String d [], int c) {
+ return a.length + b.length + d.length + c;
+ }
+
+ public String testByteArray(byte [] value) {
+ return new String(value);
}
}
Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java?view=diff&rev=439991&r1=439990&r2=439991
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java (original)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java Mon Sep 4 02:22:12 2006
@@ -1,31 +1,12 @@
package org.apache.ws.java2wsdl;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
-import org.apache.ws.commons.schema.XmlSchemaComplexType;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.XmlSchemaForm;
-import org.apache.ws.commons.schema.XmlSchemaImport;
-import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.*;
import org.apache.ws.java2wsdl.bytecode.MethodTable;
import org.apache.ws.java2wsdl.utils.TypeTable;
-import org.codehaus.jam.JClass;
-import org.codehaus.jam.JMethod;
-import org.codehaus.jam.JParameter;
-import org.codehaus.jam.JProperty;
-import org.codehaus.jam.JamClassIterator;
-import org.codehaus.jam.JamService;
-import org.codehaus.jam.JamServiceFactory;
-import org.codehaus.jam.JamServiceParams;
+import org.codehaus.jam.*;
import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Locale;
-import java.util.Map;
+import java.util.*;
/*
* Copyright 2004,2005 The Apache Software Foundation.
@@ -78,7 +59,7 @@
private String elementFormDefault = null;
private ArrayList excludeMethods = new ArrayList();
-
+
private ArrayList extraClasses = null;
public SchemaGenerator(ClassLoader loader, String className,
@@ -121,13 +102,12 @@
//it can posible to add the classLoader as well
jam_service_parms.addClassLoader(classLoader);
jam_service_parms.includeClass(className);
-
- for ( int count = 0 ; count < getExtraClasses().size() ; ++count )
- {
- jam_service_parms.includeClass((String)getExtraClasses().get(count));
+
+ for (int count = 0; count < getExtraClasses().size(); ++count) {
+ jam_service_parms.includeClass((String) getExtraClasses().get(count));
}
JamService service = factory.createService(jam_service_parms);
- QName extraSchemaTypeName ;
+ QName extraSchemaTypeName;
JamClassIterator jClassIter = service.getClasses();
//all most all the time the ittr will have only one class in it
while (jClassIter.hasNext()) {
@@ -135,9 +115,8 @@
// serviceName = jclass.getSimpleName();
//todo in the future , when we support annotation we can use this
//JAnnotation[] annotations = jclass.getAnnotations();
-
- if ( jclass.getQualifiedName().equals(className) )
- {
+
+ if (jclass.getQualifiedName().equals(className)) {
/**
* Schema genertaion done in two stage 1. Load all the methods and
* create type for methods parameters (if the parameters are Bean
@@ -149,12 +128,12 @@
methods = jclass.getDeclaredMethods();
//short the elements in the array
Arrays.sort(methods);
-
+
// since we do not support overload
HashMap uniqueMethods = new HashMap();
XmlSchemaComplexType methodSchemaType;
XmlSchemaSequence sequence = null;
-
+
for (int i = 0; i < methods.length; i++) {
JMethod jMethod = methods[i];
String methodName = methods[i].getSimpleName();
@@ -163,30 +142,30 @@
if (excludeMethods.contains(jMethod.getSimpleName())) {
continue;
}
-
+
if (uniqueMethods.get(jMethod.getSimpleName()) != null) {
throw new Exception(
" Sorry we don't support methods overloading !!!! ");
}
-
+
if (!jMethod.isPublic()) {
// no need to generate Schema for non public methods
continue;
}
uniqueMethods.put(jMethod.getSimpleName(), jMethod);
//create the schema type for the method wrapper
-
+
uniqueMethods.put(jMethod.getSimpleName(), jMethod);
JParameter [] paras = jMethod.getParameters();
String parameterNames [] = null;
if (paras.length > 0) {
parameterNames = methodTable.getParameterNames(methodName);
sequence = new XmlSchemaSequence();
-
+
methodSchemaType = createSchemaTypeForMethodPart(jMethod.getSimpleName());
methodSchemaType.setParticle(sequence);
}
-
+
for (int j = 0; j < paras.length; j++) {
JParameter methodParameter = paras[j];
JClass paraType = methodParameter.getType();
@@ -195,7 +174,7 @@
}
// for its return type
JClass returnType = jMethod.getReturnType();
-
+
if (!returnType.isVoidType()) {
methodSchemaType = createSchemaTypeForMethodPart(jMethod.getSimpleName() + RESPONSE);
sequence = new XmlSchemaSequence();
@@ -203,13 +182,10 @@
generateSchemaForType(sequence, returnType, "return");
}
}
- }
- else
- {
+ } else {
//generate the schema type for extra classes
extraSchemaTypeName = typeTable.getSimpleSchemaTypeName(jclass.getQualifiedName());
- if (extraSchemaTypeName == null)
- {
+ if (extraSchemaTypeName == null) {
generateSchema(jclass);
}
}
@@ -323,6 +299,10 @@
}
String classTypeName = type.getQualifiedName();
+ if (isArrayType && "byte".equals(classTypeName)) {
+ classTypeName = "base64Binary";
+ isArrayType = false;
+ }
QName schemaTypeName = typeTable.getSimpleSchemaTypeName(classTypeName);
if (schemaTypeName == null) {
@@ -473,8 +453,7 @@
}
public ArrayList getExtraClasses() {
- if ( extraClasses == null )
- {
+ if (extraClasses == null) {
extraClasses = new ArrayList();
}
return extraClasses;
Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/TypeTable.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/TypeTable.java?view=diff&rev=439991&r1=439990&r2=439991
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/TypeTable.java (original)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/TypeTable.java Mon Sep 4 02:22:12 2006
@@ -4,11 +4,7 @@
import org.apache.ws.java2wsdl.Java2WSDLConstants;
import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
+import java.util.*;
/*
* Copyright 2004,2005 The Apache Software Foundation.
*
@@ -90,6 +86,9 @@
new QName(Java2WSDLConstants.URI_2001_SCHEMA_XSD, "anyType", "xs"));
simpleTypetoxsd.put(List.class.getName(),
new QName(Java2WSDLConstants.URI_2001_SCHEMA_XSD, "anyType", "xs"));
+ //byteArrat
+ simpleTypetoxsd.put("base64Binary",
+ new QName(Java2WSDLConstants.URI_2001_SCHEMA_XSD, "base64Binary", "xs"));
}
public QName getSimpleSchemaTypeName(String typename) {
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org