butek 02/02/01 10:04:09 Modified: java/src/org/apache/axis/wsdl/toJava BindingEntry.java JavaImplWriter.java JavaInterfaceWriter.java JavaServiceImplWriter.java JavaSkelWriter.java JavaStubWriter.java JavaTestCaseWriter.java SymbolTable.java java/test/wsdl Wsdl2javaTestSuite.xml Added: java/test/wsdl/multibinding multibinding.wsdl Log: According to JAX-RPC, the Service Definition Interface name MIGHT come from the binding instead of the portType. I've made this fix and the test to prove it. Revision Changes Path 1.3 +13 -3 xml-axis/java/src/org/apache/axis/wsdl/toJava/BindingEntry.java Index: BindingEntry.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/BindingEntry.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- BindingEntry.java 24 Jan 2002 23:12:59 -0000 1.2 +++ BindingEntry.java 1 Feb 2002 18:04:08 -0000 1.3 @@ -84,20 +84,23 @@ private Binding binding; private int bindingType; private int bindingStyle; + private boolean hasLiteral; private HashMap attributes; private HashMap parameters = new HashMap (); /** * Construct a BindingEntry from a WSDL4J Binding object and the additional binding info: - * binding type, binding style, and the attributes which contain the input/output/fault body - * type information. + * binding type, binding style, whether there is any literal binding, and the attributes which + * contain the input/output/fault body type information. */ - public BindingEntry(Binding binding, int bindingType, int bindingStyle, HashMap attributes) { + public BindingEntry(Binding binding, int bindingType, int bindingStyle, + boolean hasLiteral, HashMap attributes) { super(binding.getQName()); this.binding = binding; this.bindingType = bindingType; this.bindingStyle = bindingStyle; + this.hasLiteral = hasLiteral; this.attributes = attributes; } // ctor @@ -143,6 +146,13 @@ public int getBindingStyle() { return bindingStyle; } // getBindingStyle + + /** + * Do any of the message stanzas contain a soap:body which uses literal? + */ + public boolean hasLiteral() { + return hasLiteral; + } // hasLiteral /** * Get the input body type for the given operation. One of BindingEntry.USE_ENCODED, 1.10 +5 -1 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaImplWriter.java Index: JavaImplWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaImplWriter.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- JavaImplWriter.java 30 Jan 2002 18:26:49 -0000 1.9 +++ JavaImplWriter.java 1 Feb 2002 18:04:08 -0000 1.10 @@ -111,7 +111,11 @@ protected void writeFileBody() throws IOException { PortType portType = binding.getPortType(); PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(portType.getQName()); - String portTypeName = ptEntry.getName(); + + // If there is not literal use, the interface name is the portType name. + // Otherwise it is the binding name. + String portTypeName = bEntry.hasLiteral() ? + bEntry.getName() : ptEntry.getName(); pw.print("public class " + className + " implements " + portTypeName); pw.println(" {"); 1.5 +11 -14 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaInterfaceWriter.java Index: JavaInterfaceWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaInterfaceWriter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JavaInterfaceWriter.java 24 Jan 2002 23:12:59 -0000 1.4 +++ JavaInterfaceWriter.java 1 Feb 2002 18:04:08 -0000 1.5 @@ -86,6 +86,13 @@ this.portType = ptEntry.getPortType(); this.symbolTable = symbolTable; this.bEntry = bEntry; + + // If there is literal use in this binding, then the interface name is + // derived from the binding name, not the portType name (the default). + if (bEntry.hasLiteral()) { + super.className = Utils.getJavaLocalName(bEntry.getName()); + super.fileName = className + ".java"; + } } // ctor /** @@ -94,21 +101,11 @@ */ public void write() throws IOException { String fqClass = packageName + "." + className; - - // Do not emit the same portType/interface twice - // Warn the user and skip writing this class. - // XXX This would be the wrong thing if the two bindings - // XXX refer to the same port type, but describe it in a different way. - // XXX For example, one has use=literal, the other use=encoded. - if (emitter.fileInfo.getClassNames().contains(fqClass)) { - System.err.println( - JavaUtils.getMessage("multipleBindings00", - portType.getQName().toString())); - return; - } - // proceed normally - super.write(); + // Do not emit the same portType/interface twice + if (!emitter.fileInfo.getClassNames().contains(fqClass)) { + super.write(); + } } // write /** 1.5 +5 -1 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java Index: JavaServiceImplWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JavaServiceImplWriter.java 24 Jan 2002 17:01:38 -0000 1.4 +++ JavaServiceImplWriter.java 1 Feb 2002 18:04:08 -0000 1.5 @@ -136,7 +136,11 @@ String portName = Utils.xmlNameToJavaClass(p.getName()); String stubClass = bEntry.getName() + "Stub"; - String bindingType = ptEntry.getName(); + + // If there is not literal use, the interface name is the portType name. + // Otherwise it is the binding name. + String bindingType = bEntry.hasLiteral() ? + bEntry.getName() : ptEntry.getName(); // Get endpoint address and validate it String address = getAddressFromPort(p); 1.11 +5 -1 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java Index: JavaSkelWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- JavaSkelWriter.java 24 Jan 2002 23:12:59 -0000 1.10 +++ JavaSkelWriter.java 1 Feb 2002 18:04:08 -0000 1.11 @@ -104,7 +104,11 @@ PortType portType = binding.getPortType(); PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(portType.getQName()); - String portTypeName = ptEntry.getName(); + + // If there is not literal use, the interface name is the portType name. + // Otherwise it is the binding name. + String portTypeName = bEntry.hasLiteral() ? + bEntry.getName () : ptEntry.getName(); boolean isRPC = true; if (bEntry.getBindingStyle() == BindingEntry.STYLE_DOCUMENT) { isRPC = false; 1.25 +5 -1 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.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- JavaStubWriter.java 31 Jan 2002 15:20:26 -0000 1.24 +++ JavaStubWriter.java 1 Feb 2002 18:04:08 -0000 1.25 @@ -115,7 +115,11 @@ PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(portType.getQName()); String name = Utils.xmlNameToJavaClass(qname.getLocalPart()); - String portTypeName = ptEntry.getName(); + + // If there is not literal use, the interface name is the portType name. + // Otherwise it is the binding name. + String portTypeName = bEntry.hasLiteral() ? + bEntry.getName() : ptEntry.getName(); boolean isRPC = true; if (bEntry.getBindingStyle() == BindingEntry.STYLE_DOCUMENT) { isRPC = false; 1.13 +9 -4 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java Index: JavaTestCaseWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- JavaTestCaseWriter.java 30 Jan 2002 18:26:49 -0000 1.12 +++ JavaTestCaseWriter.java 1 Feb 2002 18:04:08 -0000 1.13 @@ -130,7 +130,7 @@ String portName = Utils.xmlNameToJavaClass(p.getName()); writeComment(pw, p.getDocumentationElement()); - writeServiceTestCode(portName, binding); + writeServiceTestCode(portName, binding, bEntry); } finish(); } // writeFileBody @@ -142,12 +142,17 @@ pw.close(); } // finish - public final void writeServiceTestCode(String portName, Binding binding) throws IOException { + public final void writeServiceTestCode( + String portName, Binding binding, BindingEntry bEntry) + throws IOException { PortType portType = binding.getPortType(); PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(portType.getQName()); - BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName()); - String bindingType = ptEntry.getName(); + + // If there is not literal use, the interface name is the portType name. + // Otherwise it is the binding name. + String bindingType = bEntry.hasLiteral() ? + bEntry.getName() : ptEntry.getName(); pw.println(); pw.println(" public void test" + portName + "() {"); 1.23 +8 -1 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.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- SymbolTable.java 31 Jan 2002 15:33:05 -0000 1.22 +++ SymbolTable.java 1 Feb 2002 18:04:08 -0000 1.23 @@ -1049,6 +1049,7 @@ } // Check the Binding Operations for use="literal" + boolean hasLiteral = false; HashMap attributes = new HashMap(); List bindList = binding.getBindingOperations(); for (Iterator opIterator = bindList.iterator(); opIterator.hasNext();) { @@ -1120,9 +1121,15 @@ attributes.put(bindOp.getOperation(), new BindingEntry.OperationAttr(inputBodyType, outputBodyType, faultMap)); + // If the input or output body uses literal, flag the binding as using literal. + // NOTE: should I include faultBodyType in this check? + if (inputBodyType == BindingEntry.USE_LITERAL || + outputBodyType == BindingEntry.USE_LITERAL) { + hasLiteral = true; + } } // binding operations - BindingEntry bEntry = new BindingEntry(binding, bindingType, bindingStyle, attributes); + BindingEntry bEntry = new BindingEntry(binding, bindingType, bindingStyle, hasLiteral, attributes); symbolTablePut(bEntry); } } // populateBindings 1.65 +7 -0 xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml Index: Wsdl2javaTestSuite.xml =================================================================== RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- Wsdl2javaTestSuite.xml 1 Feb 2002 16:48:12 -0000 1.64 +++ Wsdl2javaTestSuite.xml 1 Feb 2002 18:04:09 -0000 1.65 @@ -56,6 +56,13 @@ <mapping namespace="urn:Example6" package="samples.userguide.example6"/> </wsdl2java> + <!-- Multiple-binding test with different literal usage --> + <wsdl2java url="test/wsdl/multibinding/multibinding.wsdl" + output="build/work" + skeleton="yes" + testcase="yes"> + </wsdl2java> + <!-- MultiRef Test --> <wsdl2java url="test/wsdl/multiref/MultiRefTest.wsdl" output="build/work" 1.1 xml-axis/java/test/wsdl/multibinding/multibinding.wsdl Index: multibinding.wsdl =================================================================== <?xml version="1.0" ?> <definitions name="multiple bindings test" targetNamespace="multibinding.wsdl.test" xmlns:tns="multibinding.wsdl.test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"> <!-- message declns --> <message name="empty"/> <!-- port type declns --> <portType name="mbPT"> <operation name="a"> <input message="tns:empty"/> <output message="tns:empty"/> </operation> <operation name="b"> <input message="tns:empty"/> <output message="tns:empty"/> </operation> </portType> <!-- binding declns --> <binding name="bindingNoLit" type="tns:mbPT"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="a"> <input> <soap:body use="encoded"/> </input> <output> <soap:body use="encoded"/> </output> </operation> <operation name="b"> <input> <soap:body use="encoded"/> </input> <output> <soap:body use="encoded"/> </output> </operation> </binding> <binding name="bindingSomeLit" type="tns:mbPT"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="a"> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> <operation name="b"> <input> <soap:body use="encoded"/> </input> <output> <soap:body use="encoded"/> </output> </operation> </binding> <binding name="bindingAllLit" type="tns:mbPT"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="a"> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> <operation name="b"> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> </binding> <!-- service decln --> <service name="mbService"> <port name="noLiteral" binding="tns:bindingNoLit"> <soap:address location="http://localhost:8080/axis/services/noLiteral"/> </port> <port name="someLiteral" binding="tns:bindingSomeLit"> <soap:address location="http://localhost:8080/axis/services/someLiteral"/> </port> <port name="allLiteral" binding="tns:bindingAllLit"> <soap:address location="http://localhost:8080/axis/services/allLiteral"/> </port> </service> </definitions>