gdaniels 02/03/03 06:09:08
Modified: java/src/org/apache/axis/client Call.java
java/src/org/apache/axis/deployment/wsdd WSDDConstants.java
WSDDOperation.java WSDDService.java
java/src/org/apache/axis/handlers/soap SOAPService.java
java/src/org/apache/axis/providers/java RPCProvider.java
java/src/org/apache/axis/wsdl/toJava JavaDeployWriter.java
SymbolTable.java
Log:
Allow for operations defined with "element=''" in WSDL to return the
appropriate (schema-defined) element name, instead of "<method>Result".
We introduce a new WSDD element, <operation>, which lives under
<service>, and right now has just name="" and returnQName=""
attributes. The WSDL2Java Emitter will correctly emit these for element-
style operations. This mechanism will be cleaned up soon, but it works
(and will enable our server endpoints to pass the doc/lit interop3 tests)
for now.
Also fix a bug where timeout wasn't getting propagated to the
MessageContext from the Call.
Revision Changes Path
1.85 +3 -0 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.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- Call.java 27 Feb 2002 17:32:17 -0000 1.84
+++ Call.java 3 Mar 2002 14:09:08 -0000 1.85
@@ -1631,6 +1631,9 @@
if (SOAPActionURI != null) {
msgContext.setSOAPActionURI(SOAPActionURI);
}
+ if (timeout != null) {
+ msgContext.setTimeout(timeout.intValue());
+ }
msgContext.setEncodingStyle(encodingStyle);
/**
1.13 +2 -0
xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDConstants.java
Index: WSDDConstants.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDConstants.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- WSDDConstants.java 3 Dec 2001 03:31:31 -0000 1.12
+++ WSDDConstants.java 3 Mar 2002 14:09:08 -0000 1.13
@@ -115,4 +115,6 @@
"typeMapping");
public static final QName BEANMAPPING_QNAME = new QName(WSDD_NS,
"beanMapping");
+ public static final QName OPERATION_QNAME = new QName(WSDD_NS,
+ "operation");
}
1.12 +53 -1
xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDOperation.java
Index: WSDDOperation.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDOperation.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- WSDDOperation.java 7 Nov 2001 21:04:20 -0000 1.11
+++ WSDDOperation.java 3 Mar 2002 14:09:08 -0000 1.12
@@ -58,6 +58,9 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.apache.axis.encoding.SerializationContext;
+import org.apache.axis.utils.XMLUtils;
+import org.apache.axis.description.OperationDesc;
+import org.xml.sax.helpers.AttributesImpl;
import javax.xml.rpc.namespace.QName;
import java.io.IOException;
@@ -68,6 +71,12 @@
public class WSDDOperation
extends WSDDElement
{
+ /** The operation name (String, or QName?) */
+ private String name;
+
+ /** The return QName (if it should be different from <method>Result) */
+ private QName returnQName;
+
/**
*
* @param e (Element) XXX
@@ -77,6 +86,12 @@
throws WSDDException
{
super(e);
+
+ name = e.getAttribute("name");
+
+ String retQNameStr = e.getAttribute("returnQName");
+ if (retQNameStr != null && !retQNameStr.equals(""))
+ returnQName = XMLUtils.getQNameFromString(retQNameStr, e);
}
/**
@@ -84,9 +99,46 @@
*/
public void writeToContext(SerializationContext context)
throws IOException {
+ AttributesImpl attrs = new AttributesImpl();
+
+ if (returnQName != null) {
+ attrs.addAttribute("", "returnQName", "returnQName",
+ "CDATA", context.qName2String(returnQName));
+ }
+
+ if (name != null) {
+ attrs.addAttribute("", "name", "name", "CDATA", name);
+ }
+
+ context.startElement(getElementName(), attrs);
+ context.endElement();
}
protected QName getElementName() {
- return new QName("", "operation");
+ return WSDDConstants.OPERATION_QNAME;
+ }
+
+ public QName getReturnQName() {
+ return returnQName;
+ }
+
+ public void setReturnQName(QName returnQName) {
+ this.returnQName = returnQName;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public OperationDesc getOperationDesc()
+ {
+ OperationDesc desc = new OperationDesc();
+ desc.setName(name);
+ desc.setReturnQName(returnQName);
+ return desc;
}
}
1.43 +56 -38
xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java
Index: WSDDService.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- WSDDService.java 28 Feb 2002 13:37:47 -0000 1.42
+++ WSDDService.java 3 Mar 2002 14:09:08 -0000 1.43
@@ -86,10 +86,11 @@
{
public static final QName elMapQName = new QName("", "elementMapping");
public TypeMappingRegistry tmr = null;
-
+
private Vector faultFlows = new Vector();
private Vector typeMappings = new Vector();
-
+ private Vector operations = new Vector();
+
/** Which namespaces should auto-dispatch to this service? */
private Vector namespaces = new Vector();
@@ -97,25 +98,25 @@
private HashMap qName2MethodMap = null;
private String descriptionURL;
-
+
/** Style - document or RPC (the default) */
private int style = SOAPService.STYLE_RPC;
private SOAPService cachedService = null;
-
+
/**
* Our provider - used to figure out which Handler we use as a service
* pivot (see getInstance() below)
- */
+ */
private QName providerQName;
/**
* Default constructor
- */
+ */
public WSDDService()
{
}
-
+
/**
*
* @param e (Element) XXX
@@ -125,21 +126,27 @@
throws WSDDException
{
super(e);
-
+
+ Element [] operationElements = getChildElements(e, "operation");
+ for (int i = 0; i < operationElements.length; i++) {
+ WSDDOperation operation = new WSDDOperation(operationElements[i]);
+ operations.add(operation);
+ }
+
Element [] typeMappingElements = getChildElements(e, "typeMapping");
for (int i = 0; i < typeMappingElements.length; i++) {
WSDDTypeMapping mapping =
new WSDDTypeMapping(typeMappingElements[i]);
typeMappings.add(mapping);
}
-
+
Element [] beanMappingElements = getChildElements(e, "beanMapping");
for (int i = 0; i < beanMappingElements.length; i++) {
WSDDBeanMapping mapping =
new WSDDBeanMapping(beanMappingElements[i]);
typeMappings.add(mapping);
}
-
+
Element [] namespaceElements = getChildElements(e, "namespace");
for (int i = 0; i < namespaceElements.length; i++) {
// Register a namespace for this service
@@ -150,7 +157,7 @@
String typeStr = e.getAttribute("provider");
if (typeStr != null && !typeStr.equals(""))
providerQName = XMLUtils.getQNameFromString(typeStr, e);
-
+
String modeStr = e.getAttribute("style");
if (modeStr != null && modeStr.equals("document")) {
style = SOAPService.STYLE_DOCUMENT;
@@ -173,22 +180,22 @@
/**
* Add a WSDDTypeMapping to the Service.
- * @param mapping
+ * @param mapping
**/
public void addTypeMapping(WSDDTypeMapping mapping) {
typeMappings.add(mapping);
}
-
+
protected QName getElementName()
{
return WSDDConstants.SERVICE_QNAME;
}
-
+
/**
* Get any service description URL which might be associated with this
* service.
- *
+ *
* @return a String containing a URL, or null.
*/
public String getServiceDescriptionURL()
@@ -198,7 +205,7 @@
/**
* Set the service description URL for this service.
- *
+ *
* @param sdUrl a String containing a URL
*/
public void setServiceDescriptionURL(String sdUrl)
@@ -216,14 +223,14 @@
/**
* Get the service style - document or RPC
- */
+ */
public int getStyle() {
return style;
}
/**
* Set the service style - document or RPC
- */
+ */
public void setStyle(int style) {
this.style = style;
}
@@ -238,12 +245,12 @@
faultFlows.toArray(t);
return t;
}
-
+
/**
* Obtain the list of namespaces registered for this service
* @return a Vector of namespaces (Strings) which should dispatch to
* this service
- */
+ */
public Vector getNamespaces()
{
return namespaces;
@@ -279,10 +286,10 @@
if (cachedService != null) {
return cachedService;
}
-
+
Handler reqHandler = null;
WSDDChain request = getRequestFlow();
-
+
if (request != null) {
reqHandler = request.getInstance(registry);
}
@@ -308,7 +315,7 @@
if (response != null) {
respHandler = response.getInstance(registry);
}
-
+
SOAPService service = new SOAPService(reqHandler, providerHandler,
respHandler);
service.setStyle(style);
@@ -340,6 +347,12 @@
service.setElementMap(qName2MethodMap);
+ for (Iterator i = operations.iterator(); i.hasNext();) {
+ WSDDOperation operation = (WSDDOperation) i.next();
+ service.addOperationDesc(operation.getName(),
+ operation.getOperationDesc());
+ }
+
cachedService = service;
return service;
}
@@ -370,28 +383,28 @@
tm.setSupportedNamespaces(new String[] {encodingStyle});
tmr.register(encodingStyle, tm);
}
-
+
SerializerFactory ser = null;
DeserializerFactory deser = null;
-
+
// Try to construct a serializerFactory by introspecting for the
// following:
// public static create(Class javaType, QName xmlType)
// public <constructor>(Class javaType, QName xmlType)
// public <constructor>()
- //
- // The BaseSerializerFactory createFactory() method is a utility
+ //
+ // The BaseSerializerFactory createFactory() method is a utility
// that does this for us.
if (mapping.getSerializerName() != null &&
!mapping.getSerializerName().equals("")) {
- ser = BaseSerializerFactory.createFactory(mapping.getSerializer(),
+ ser = BaseSerializerFactory.createFactory(mapping.getSerializer(),
mapping.getLanguageSpecificType(),
mapping.getQName());
}
-
+
if (mapping.getDeserializerName() != null &&
!mapping.getDeserializerName().equals("")) {
- deser =
BaseDeserializerFactory.createFactory(mapping.getDeserializer(),
+ deser =
BaseDeserializerFactory.createFactory(mapping.getDeserializer(),
mapping.getLanguageSpecificType(),
mapping.getQName());
}
@@ -421,8 +434,13 @@
if (style == SOAPService.STYLE_DOCUMENT) {
attrs.addAttribute("", "style", "style", "CDATA", "document");
}
-
+
context.startElement(WSDDConstants.SERVICE_QNAME, attrs);
+
+ for (int i = 0; i < operations.size(); i++) {
+ WSDDOperation operation = (WSDDOperation) operations.elementAt(i);
+ operation.writeToContext(context);
+ }
writeFlowsToContext(context);
writeParamsToContext(context);
@@ -449,7 +467,7 @@
for (int i=0; i < typeMappings.size(); i++) {
((WSDDTypeMapping) typeMappings.elementAt(i)).writeToContext(context);
}
-
+
for (int i=0; i < namespaces.size(); i++ ) {
context.startElement(new QName("", "namespace"), null);
context.writeString((String)namespaces.get(i));
@@ -458,7 +476,7 @@
context.endElement();
}
-
+
public void setCachedService(SOAPService service)
{
cachedService = service;
@@ -467,19 +485,19 @@
public void deployToRegistry(WSDDDeployment registry)
{
registry.addService(this);
-
+
// Register the name of the service as a valid namespace, just for
// backwards compatibility
registry.registerNamespaceForService(getQName().getLocalPart(), this);
-
+
for (int i = 0; i < namespaces.size(); i++) {
String namespace = (String) namespaces.elementAt(i);
- registry.registerNamespaceForService(namespace, this);
+ registry.registerNamespaceForService(namespace, this);
}
-
+
super.deployToRegistry(registry);
}
-
+
public void removeNamespaceMappings(WSDDDeployment registry)
{
for (int i = 0; i < namespaces.size(); i++) {
1.49 +17 -0 xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java
Index: SOAPService.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- SOAPService.java 28 Feb 2002 13:37:47 -0000 1.48
+++ SOAPService.java 3 Mar 2002 14:09:08 -0000 1.49
@@ -62,6 +62,7 @@
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.SimpleTargetedChain;
+import org.apache.axis.description.OperationDesc;
import org.apache.axis.providers.java.MsgProvider;
import org.apache.axis.encoding.DeserializerFactory;
import org.apache.axis.encoding.Serializer;
@@ -122,6 +123,22 @@
* not in wrapped mode.
*/
private HashMap qName2MethodMap = null;
+
+ private HashMap method2OperationMap = null;
+
+ public void addOperationDesc(String method, OperationDesc operation)
+ {
+ if (method2OperationMap == null)
+ method2OperationMap = new HashMap();
+ method2OperationMap.put(method, operation);
+ }
+
+ public OperationDesc getOperationDescByName(String methodName)
+ {
+ if (method2OperationMap == null)
+ return null;
+ return (OperationDesc)method2OperationMap.get(methodName);
+ }
/**
* SOAPRequestHandler is used to inject SOAP semantics just before
1.43 +26 -4
xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java
Index: RPCProvider.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- RPCProvider.java 25 Feb 2002 10:53:40 -0000 1.42
+++ RPCProvider.java 3 Mar 2002 14:09:08 -0000 1.43
@@ -58,6 +58,8 @@
import org.apache.axis.AxisFault;
import org.apache.axis.Constants;
import org.apache.axis.MessageContext;
+import org.apache.axis.description.OperationDesc;
+import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.message.RPCElement;
import org.apache.axis.message.RPCParam;
import org.apache.axis.message.SOAPEnvelope;
@@ -67,6 +69,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.xml.rpc.namespace.QName;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.util.StringTokenizer;
@@ -291,6 +294,7 @@
resBody.setPrefix( body.getPrefix() );
resBody.setNamespaceURI( body.getNamespaceURI() );
resBody.setEncodingStyle(msgContext.getEncodingStyle());
+ SOAPService service = msgContext.getService();
if ( objRes != null ) {
// In the old skeleton a param list was returned, which
// contained the RPC params. Preserve this for now.
@@ -307,11 +311,13 @@
}
}
else {
- RPCParam param = new RPCParam(getParameterName(obj,
method[m],-1, mName), objRes);
+ QName returnQName = getReturnQName(service, mName);
+ RPCParam param = new RPCParam(returnQName, objRes);
resBody.addParam(param);
}
} else if (method[m].getReturnType() != Void.TYPE) {
- RPCParam param = new RPCParam(getParameterName(obj, method[m],-1,
mName), objRes);
+ QName returnQName = getReturnQName(service, mName);
+ RPCParam param = new RPCParam(returnQName, objRes);
resBody.addParam(param);
}
@@ -377,10 +383,26 @@
} else {
parmName = mName + "Result" + i;
}
- } else {
- parmName = mName + "Result";
}
}
return parmName;
+ }
+
+ protected QName getReturnQName(SOAPService service, String methodName)
+ {
+ QName ret = null;
+
+ if (service != null) {
+ OperationDesc oper = service.getOperationDescByName(methodName);
+ if (oper != null) {
+ ret = oper.getReturnQName();
+ }
+ }
+
+ if (ret == null) {
+ ret = new QName("", methodName + "Result");
+ }
+
+ return ret;
}
}
1.22 +23 -2
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java
Index: JavaDeployWriter.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- JavaDeployWriter.java 28 Feb 2002 17:34:06 -0000 1.21
+++ JavaDeployWriter.java 3 Mar 2002 14:09:08 -0000 1.22
@@ -60,6 +60,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
+import java.util.List;
import javax.wsdl.Binding;
import javax.wsdl.BindingOperation;
@@ -189,13 +190,33 @@
BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
String serviceName = port.getName();
- boolean isRPC = true;
+ boolean isRPC = (bEntry.getBindingStyle() == BindingEntry.STYLE_RPC);
boolean hasLiteral = bEntry.hasLiteral();
String prefix = Constants.NSPREFIX_WSDD_JAVA;
pw.println(" <service name=\"" + serviceName
+ "\" provider=\"" + (isRPC ? prefix +":RPC" : prefix +":MSG")
- + "\"" + (hasLiteral ? " style=\"document\"" : "") + ">");
+ + "\"" + (hasLiteral ? " style=\"literal\"" : "") + ">");
+
+ List operations = binding.getBindingOperations();
+ for (Iterator i = operations.iterator(); i.hasNext();) {
+ BindingOperation bOperation = (BindingOperation) i.next();
+ Operation operation = bOperation.getOperation();
+ // We pass "" as the namespace argument because we're just
+ // interested in the return type for now.
+ Parameters params =
+ symbolTable.getOperationParameters(operation, "", bEntry);
+ if (params.returnType instanceof DefinedElement) {
+ QName returnQName = params.returnType.getQName();
+ pw.print(" <operation name=\"" + operation.getName() +
+ "\" returnQName=\"retNS:" +
+ returnQName.getLocalPart() +
+ "\" xmlns:retNS=\"" +
+ returnQName.getNamespaceURI() +
+ "\"");
+ pw.println("/>");
+ }
+ }
writeDeployBinding(binding);
writeDeployTypes(hasLiteral);
1.39 +9 -2 xml-axis/java/src/org/apache/axis/wsdl/toJava/SymbolTable.java
Index: SymbolTable.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/SymbolTable.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- SymbolTable.java 28 Feb 2002 15:56:16 -0000 1.38
+++ SymbolTable.java 3 Mar 2002 14:09:08 -0000 1.39
@@ -868,7 +868,7 @@
* Rather than do that processing 3 times, it is done once, here, and stored in
the
* Parameters object.
*/
- private Parameters getOperationParameters(Operation operation,
+ public Parameters getOperationParameters(Operation operation,
String namespace,
BindingEntry bindingEntry) throws
IOException {
Parameters parameters = new Parameters();
@@ -1039,8 +1039,15 @@
*/
private void addOutParm(Vector outputs, int outdex, Parameters parameters,
boolean trim) {
Parameter p = new Parameter();
- p.setName((String) outputs.get(outdex));
p.type = (TypeEntry) outputs.get(outdex - 1);
+
+ if (p.type instanceof DefinedElement) {
+ DefinedElement de = (DefinedElement)p.type;
+ p.setQName(de.getQName());
+ } else {
+ p.setName((String) outputs.get(outdex));
+ }
+
if (trim) {
outputs.remove(outdex);
outputs.remove(outdex - 1);