butek 2002/06/10 07:00:39 Modified: java/src/org/apache/axis/wsdl/symbolTable Utils.java java/src/org/apache/axis/wsdl/toJava JavaStubWriter.java Utils.java Log: I backed out my fix for bugzilla 9643 (what I did was wrong), but I didn't put back what was there; instead, the code is now calling Utils.getOperationQName. Much cleaner. But getOperationQName was designed for deploy/skel, which only wants a QName if something is out of the ordinary. Whereas stub ALWAYS wants one. I chatted with Tom (who wrote this method) and he said it's OK for getOperationQName to always return a QName, so I implemented it that way. I also moved getNewQName from wsdl.symbolTable.Utils to wsdl.toJava.Utils. It's a Java generation method. Java-isms don't belong in wsdl.symbolTable. (and while I was in wsdl.symbolTable.Utils, I added some comments to the methods getAxisQName and getWSDLQName.) (just FYI: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9643) Revision Changes Path 1.9 +8 -11 xml-axis/java/src/org/apache/axis/wsdl/symbolTable/Utils.java Index: Utils.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/symbolTable/Utils.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- Utils.java 4 Jun 2002 20:35:08 -0000 1.8 +++ Utils.java 10 Jun 2002 14:00:38 -0000 1.9 @@ -547,16 +547,9 @@ } // getNestedTypes /** - * Common code for generating a QName in emitted code. Note that there's - * no semicolon at the end, so we can use this in a variety of contexts. - */ - public static String getNewQName(javax.xml.rpc.namespace.QName qname) - { - return "new javax.xml.rpc.namespace.QName(\"" + - qname.getNamespaceURI() + "\", \"" + - qname.getLocalPart() + "\")"; - } - + * Given the WSDL4J QName (javax.wsdl.QName), return the JAX-RPC + * QName (javax.xml.rpc.namespace.QName). + */ public static javax.xml.rpc.namespace.QName getAxisQName(QName qname) { if (qname == null) { @@ -565,7 +558,11 @@ return new javax.xml.rpc.namespace.QName(qname.getNamespaceURI(), qname.getLocalPart()); } - + + /** + * Given the JAX-RPC QName (javax.xml.rpc.namespace.QName), return + * the WSDL4J QName (javax.wsdl.QName). + */ public static QName getWSDLQName(javax.xml.rpc.namespace.QName qname) { if (qname == null) { 1.69 +7 -7 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java Index: JavaStubWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- JavaStubWriter.java 7 Jun 2002 20:59:12 -0000 1.68 +++ JavaStubWriter.java 10 Jun 2002 14:00:38 -0000 1.69 @@ -259,10 +259,6 @@ break; } } - // Get the namespace for the operation from the portType - // RJB: is this the right thing to do? - String namespace = portType.getQName().getNamespaceURI(); - Operation ptOperation = operation.getOperation(); OperationType type = ptOperation.getStyle(); @@ -275,7 +271,7 @@ } else { writeOperation(pw, - operation, parameters, soapAction, namespace, isRPC); + operation, parameters, soapAction, isRPC); } } } // writeFileBody @@ -460,7 +456,6 @@ BindingOperation operation, Parameters parms, String soapAction, - String namespace, boolean isRPC) throws IOException { writeComment(pw, operation.getDocumentationElement()); @@ -574,7 +569,12 @@ QName q = p.getElementName(); pw.println(" call.setOperationName(new javax.xml.rpc.namespace.QName(\"" + q.getNamespaceURI() + "\", \"" + q.getLocalPart() + "\"));" ); } else { - pw.println(" call.setOperationName(new javax.xml.rpc.namespace.QName(\"" + namespace + "\", \"" + operation.getName() + "\"));" ); + javax.xml.rpc.namespace.QName elementQName = Utils.getAxisQName( + Utils.getOperationQName(operation)); + if (elementQName != null) { + pw.println(" call.setOperationName(" + + Utils.getNewQName(elementQName) + ");" ); + } } // Invoke the operation 1.36 +27 -11 xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java Index: Utils.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- Utils.java 3 Jun 2002 02:15:53 -0000 1.35 +++ Utils.java 10 Jun 2002 14:00:39 -0000 1.36 @@ -450,12 +450,11 @@ } // isPrimitiveType /** - * Return the XML Element which will trigger a particular operation - * or null if the default case (localPart equals operation name) will - * work fine. + * Return the operation QName. The namespace is determined from + * the soap:body namespace, if it exists, otherwise it is "". * * @param operation the operation - * @return element QName for doc/lit operation or null + * @return the operation QName */ public static QName getOperationQName(BindingOperation bindingOper) { Operation operation = bindingOper.getOperation(); @@ -463,10 +462,11 @@ String javaOperName = JavaUtils.xmlNameToJava(operation.getName()); QName elementQName = null; + String ns = null; + // Get a namespace from the soap:body tag, if any // example: // <soap:body namespace="this_is_what_we_want" ..> - String ns = null; BindingInput bindInput = bindingOper.getBindingInput(); if (bindInput != null) { Iterator it = bindInput.getExtensibilityElements().iterator(); @@ -479,6 +479,15 @@ } } } + + // If we didn't get a namespace from the soap:body, then + // use "". We should probably use the targetNamespace, + // but the target namespace of what? binding? portType? + // Also, we don't have enough info for to get it. + if (ns == null) { + ns = ""; + } + // Get the qname from the first message part, if it is an element // example: // <part name="paramters" element="ns:myelem"> @@ -498,16 +507,23 @@ // If we didn't find an element declared in the part (assume it's a // type), so the QName will be the operation name with the - // namespace (if any) from the binding soap:body tag.. + // namespace (if any) from the binding soap:body tag. if (elementQName == null) { - // We don't need to even set the QName in the meta data if we don't - // have a namespace or we didn't mangle the XML name to a java name - if (ns != null || !javaOperName.equals(operationName)) { - elementQName = new QName(ns, operationName); - } + elementQName = new QName(ns, operationName); } return elementQName; } + /** + * Common code for generating a QName in emitted code. Note that there's + * no semicolon at the end, so we can use this in a variety of contexts. + */ + public static String getNewQName(javax.xml.rpc.namespace.QName qname) + { + return "new javax.xml.rpc.namespace.QName(\"" + + qname.getNamespaceURI() + "\", \"" + + qname.getLocalPart() + "\")"; + } + } // class Utils