dims 2002/10/24 15:13:23
Modified: java/src/org/apache/axis/client Call.java Service.java
java/samples/client DynamicInvoker.java
java/test/dynamic TestDynamicInvoker.java
Log:
Checking in initial implementation and test case for Bug 13883 - DII WSDL processing
doesn't deal with wrapped mode
Revision Changes Path
1.190 +92 -63 xml-axis/java/src/org/apache/axis/client/Call.java
Index: Call.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Call.java,v
retrieving revision 1.189
retrieving revision 1.190
diff -u -r1.189 -r1.190
--- Call.java 21 Oct 2002 02:13:47 -0000 1.189
+++ Call.java 24 Oct 2002 22:13:23 -0000 1.190
@@ -62,6 +62,11 @@
import org.apache.axis.InternalException;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
+import org.apache.axis.wsdl.symbolTable.Parameters;
+import org.apache.axis.wsdl.symbolTable.BindingEntry;
+import org.apache.axis.wsdl.symbolTable.Parameter;
+import org.apache.axis.wsdl.symbolTable.SymbolTable;
+import org.apache.axis.wsdl.toJava.Utils;
import org.apache.axis.soap.SOAPConstants;
import org.apache.axis.description.OperationDesc;
import org.apache.axis.description.ParameterDesc;
@@ -88,6 +93,7 @@
import org.apache.axis.transport.http.HTTPTransport;
import org.apache.axis.utils.JavaUtils;
import org.apache.axis.utils.Messages;
+import org.apache.axis.utils.ClassUtils;
import org.apache.axis.components.logger.LogFactory;
import org.apache.commons.logging.Log;
@@ -239,6 +245,11 @@
*/
private static Hashtable transports = new Hashtable();
+ static ParameterMode [] modes = new ParameterMode [] { null,
+ ParameterMode.IN,
+ ParameterMode.OUT,
+ ParameterMode.INOUT };
+
/************************************************************************/
/* Start of core JAX-RPC stuff */
/************************************************************************/
@@ -1187,6 +1198,7 @@
// Get the SOAPAction
////////////////////////////////////////////////////////////////////
+ String opStyle = null;
BindingOperation bop = binding.getBindingOperation(opName,
null, null);
if ( bop == null )
@@ -1197,6 +1209,7 @@
Object obj = list.get(i);
if ( obj instanceof SOAPOperation ) {
SOAPOperation sop = (SOAPOperation) obj ;
+ opStyle = ((SOAPOperation) obj).getStyle();
String action = sop.getSoapActionURI();
if ( action != null ) {
setUseSOAPAction(true);
@@ -1249,71 +1262,87 @@
}
}
- // Get the parameters
- ////////////////////////////////////////////////////////////////////
- List paramOrder = op.getParameterOrdering();
- Input input = op.getInput();
- javax.wsdl.Message message = null ;
- List parts = null ;
-
- if ( input != null ) message = input.getMessage();
- if ( message != null ) parts = message.getOrderedParts( paramOrder );
- if ( parts != null ) {
- for ( int i = 0 ; i < parts.size() ; i++ ) {
- Part part = (Part) parts.get(i);
- if ( part == null ) continue ;
-
- String name = part.getName();
- QName type = part.getTypeName();
-
- if ( type == null ) {
- type = part.getElementName();
- if ( type != null )
- type = new QName("java","org.w3c.dom.Element");
- else
- throw new JAXRPCException(
- Messages.getMessage("typeNotSet00", name) );
- }
-
- QName qname = new QName(type.getNamespaceURI(),
- type.getLocalPart());
- ParameterMode mode = ParameterMode.IN;
- this.addParameter( name, qname, mode );
+ Service service = this.getService();
+ SymbolTable symbolTable = service.getWSDLParser().getSymbolTable();
+ BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
+ Parameters parameters = bEntry.getParameters(bop.getOperation());
+
+ // loop over paramters and set up in/out params
+ for (int j = 0; j < parameters.list.size(); ++j) {
+ Parameter p = (Parameter) parameters.list.get(j);
+ // Get the QName representing the parameter type
+ QName paramType = Utils.getXSIType(p);
+ this.addParameter( p.getQName(), paramType, modes[p.getMode()]);
+ }
+
+ // set output type
+ if (parameters.returnParam != null) {
+ // Get the QName for the return Type
+ QName returnType = Utils.getXSIType(parameters.returnParam);
+ QName returnQName = parameters.returnParam.getQName();
+
+ // Get the javaType
+ String javaType = null;
+ if (parameters.returnParam.getMIMEType() != null) {
+ javaType = "javax.activation.DataHandler";
+ }
+ else {
+ javaType = parameters.returnParam.getType().getName();
+ }
+ if (javaType == null) {
+ javaType = "";
+ }
+ else {
+ javaType = javaType + ".class";
+ }
+ this.setReturnType(returnType);
+ try {
+ this.setReturnClass(ClassUtils.forName(javaType));
+ } catch (Exception e){
+ //TODO: ???
}
+ this.setReturnQName(returnQName);
}
-
-
- // Get the return type
- ////////////////////////////////////////////////////////////////////
- Output output = op.getOutput();
- message = null ;
-
- if ( output != null ) message = output.getMessage();
- if ( message != null ) parts = message.getOrderedParts(null);
-
- // attachments may have no parameters.
- if (operation != null && operation.getNumParams() > 0)
- this.setReturnType( XMLType.AXIS_VOID );
- if ( parts != null ) {
- for( int i = 0 ;i < parts.size() ; i++ ) {
- Part part = (Part) parts.get( i );
-
- if (paramOrder != null && paramOrder.contains(part.getName()))
- continue ;
-
- QName type = part.getTypeName();
- if ( type == null ) {
- type = part.getElementName();
- if ( type != null )
- type = new QName("java","org.w3c.dom.Element");
- else
- throw new JAXRPCException(
- Messages.getMessage("typeNotSet00", "<return>") );
- }
- QName qname = new QName(type.getNamespaceURI(),
- type.getLocalPart());
- this.setReturnType( qname );
- break ;
+ else {
+ this.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID);
+ }
+
+ boolean hasMIME = Utils.hasMIME(bEntry, bop);
+ Use use = bEntry.getInputBodyType(bop.getOperation());
+ Style style = Style.getStyle(opStyle, bEntry.getBindingStyle());
+ if (use == Use.LITERAL) {
+ // Turn off encoding
+ setEncodingStyle(null);
+ // turn off XSI types
+ setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
+ }
+ if (hasMIME || use == Use.LITERAL) {
+ // If it is literal, turn off multirefs.
+ //
+ // If there are any MIME types, turn off multirefs.
+ // I don't know enough about the guts to know why
+ // attachments don't work with multirefs, but they don't.
+ setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
+ }
+
+ if (style == Style.DOCUMENT && symbolTable.isWrapped()) {
+ style = Style.WRAPPED;
+ }
+
+ // Operation name
+ if (style == Style.WRAPPED) {
+ // We need to make sure the operation name, which is what we
+ // wrap the elements in, matches the Qname of the parameter
+ // element.
+ Map partsMap = bop.getOperation().getInput().getMessage().getParts();
+ Part p = (Part)partsMap.values().iterator().next();
+ QName q = p.getElementName();
+ setOperationName(q);
+ } else {
+ QName elementQName =
+ Utils.getOperationQName(bop, bEntry, symbolTable);
+ if (elementQName != null) {
+ setOperationName(elementQName);
}
}
1.80 +1 -1 xml-axis/java/src/org/apache/axis/client/Service.java
Index: Service.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Service.java,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- Service.java 24 Oct 2002 18:03:10 -0000 1.79
+++ Service.java 24 Oct 2002 22:13:23 -0000 1.80
@@ -132,7 +132,7 @@
return( wsdlService );
}
- protected Parser getWSDLParser() {
+ public Parser getWSDLParser() {
return( wsdlParser );
}
1.3 +54 -22 xml-axis/java/samples/client/DynamicInvoker.java
Index: DynamicInvoker.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/client/DynamicInvoker.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DynamicInvoker.java 13 Oct 2002 19:36:38 -0000 1.2
+++ DynamicInvoker.java 24 Oct 2002 22:13:23 -0000 1.3
@@ -56,6 +56,12 @@
package samples.client;
import org.apache.axis.utils.XMLUtils;
+import org.apache.axis.wsdl.gen.Parser;
+import org.apache.axis.wsdl.symbolTable.Type;
+import org.apache.axis.wsdl.symbolTable.Element;
+import org.apache.axis.wsdl.symbolTable.Utils;
+import org.apache.axis.wsdl.symbolTable.SymbolTable;
+import org.apache.axis.wsdl.symbolTable.TypeEntry;
import org.w3c.dom.Document;
import javax.wsdl.Binding;
@@ -82,6 +88,7 @@
import java.util.Set;
import java.util.StringTokenizer;
import java.util.Vector;
+import java.util.HashSet;
/**
* This sample shows how to use Axis for completely dynamic invocations
@@ -190,7 +197,7 @@
PortType portType = selectPortType(def, portTypeNS, portTypeName);
ServiceFactory factory = ServiceFactory.newInstance();
- javax.xml.rpc.Service dpf = factory.createService(new URL(wsdlLocation),
service.getQName());
+ org.apache.axis.client.Service dpf =
(org.apache.axis.client.Service)factory.createService(new URL(wsdlLocation),
service.getQName());
if (inputName == null && outputName == null) {
// retrieve list of operations
@@ -256,7 +263,7 @@
int count = parts.size();
inNames = new String[count];
inTypes = new Class[count];
- retrieveSignature(parts, inNames, inTypes);
+ retrieveSignature(dpf, parts, inNames, inTypes);
}
// now prepare out parameters
@@ -287,7 +294,7 @@
int count = parts.size();
outNames = new String[count];
outTypes = new Class[count];
- retrieveSignature(parts, outNames, outTypes);
+ retrieveSignature(dpf, parts, outNames, outTypes);
}
}
@@ -316,6 +323,7 @@
}
private static void retrieveSignature(
+ org.apache.axis.client.Service service,
List parts,
String[] names,
Class[] types) {
@@ -323,27 +331,51 @@
for (int i = 0; i < names.length; ++i) {
Part part = (Part) parts.get(i);
names[i] = part.getName();
- QName partType = part.getTypeName();
- if (partType == null) {
- throw new RuntimeException(
- "part " + names[i] + " must have type name declared");
- }
- // only limited number of types is supported
- // cheerfully ignoring schema namespace ...
- String s = partType.getLocalPart();
- if ("string".equals(s)) {
- types[i] = String.class;
- } else if ("double".equals(s)) {
- types[i] = Integer.TYPE;
- } else if ("float".equals(s)) {
- types[i] = Float.TYPE;
- } else if ("int".equals(s)) {
- types[i] = Integer.TYPE;
- } else if ("boolean".equals(s)) {
- types[i] = Boolean.TYPE;
+ QName partTypeName = part.getTypeName();
+ QName partElementName = part.getElementName();
+ Type partType = null;
+ Element partElement = null;
+ if (partTypeName != null) {
+ partType =
service.getWSDLParser().getSymbolTable().getType(partTypeName);
+ // only limited number of types is supported
+ // cheerfully ignoring schema namespace ...
+ String s = partTypeName.getLocalPart();
+ if ("string".equals(s)) {
+ types[i] = String.class;
+ } else if ("double".equals(s)) {
+ types[i] = Integer.TYPE;
+ } else if ("float".equals(s)) {
+ types[i] = Float.TYPE;
+ } else if ("int".equals(s)) {
+ types[i] = Integer.TYPE;
+ } else if ("boolean".equals(s)) {
+ types[i] = Boolean.TYPE;
+ }
+ } else if (partElementName != null) {
+ SymbolTable symbolTable = service.getWSDLParser().getSymbolTable();
+ partElement = symbolTable.getElement(partElementName);
+ HashSet nestedTypes =
Utils.getNestedTypes(partElement.getRefType(), symbolTable, true);
+ Iterator it = nestedTypes.iterator();
+ if (it.hasNext()) {
+ TypeEntry nestedType = (TypeEntry) it.next();
+ // only limited number of types is supported
+ // cheerfully ignoring schema namespace ...
+ String s = nestedType.getQName().getLocalPart();
+ if ("string".equals(s)) {
+ types[i] = String.class;
+ } else if ("double".equals(s)) {
+ types[i] = Integer.TYPE;
+ } else if ("float".equals(s)) {
+ types[i] = Float.TYPE;
+ } else if ("int".equals(s)) {
+ types[i] = Integer.TYPE;
+ } else if ("boolean".equals(s)) {
+ types[i] = Boolean.TYPE;
+ }
+ }
} else {
throw new RuntimeException(
- "part type " + partType + " not supported in this sample");
+ "part " + names[i] + " must have type or element name
declared");
}
}
}
1.3 +18 -0 xml-axis/java/test/dynamic/TestDynamicInvoker.java
Index: TestDynamicInvoker.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/dynamic/TestDynamicInvoker.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestDynamicInvoker.java 19 Oct 2002 15:24:38 -0000 1.2
+++ TestDynamicInvoker.java 24 Oct 2002 22:13:23 -0000 1.3
@@ -101,4 +101,22 @@
throw new junit.framework.AssertionFailedError("Remote Exception
caught: " + re);
}
}
+
+ public void test3() throws Exception {
+ try {
+ String[] args = new
String[]{"http://mssoapinterop.org/asmx/xsd/round4XSD.wsdl",
"echoString(Round4XSDTestSoap)", "Hello World!!!"};
+ DynamicInvoker invoker = new DynamicInvoker();
+ invoker.main(args);
+ } catch (java.rmi.RemoteException re) {
+ if (re instanceof AxisFault) {
+ AxisFault fault = (AxisFault) re;
+ if (fault.detail instanceof ConnectException ||
+ fault.getFaultCode().getLocalPart().equals("HTTP")) {
+ System.err.println("TerraService HTTP error: " + fault);
+ return;
+ }
+ }
+ throw new junit.framework.AssertionFailedError("Remote Exception
caught: " + re);
+ }
+ }
}