gdaniels 02/04/05 17:46:04 Modified: java/src/org/apache/axis/wsdl/toJava JavaDeployWriter.java Added: java/test/wsdl/qualify Qualify_BindingImpl.java Qualify_ServiceTestCase.java qualifytest.wsdl Log: Check in missing qualify test, and use the genQNameAttributeString method in more places to avoid namespace bugs with unqualified elements. Revision Changes Path 1.33 +23 -19 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.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- JavaDeployWriter.java 5 Apr 2002 21:24:32 -0000 1.32 +++ JavaDeployWriter.java 6 Apr 2002 01:46:04 -0000 1.33 @@ -88,8 +88,8 @@ /** * Constructor. */ - protected JavaDeployWriter(Emitter emitter, - Definition definition, + protected JavaDeployWriter(Emitter emitter, + Definition definition, SymbolTable symbolTable) { super(emitter, new QName(definition.getTargetNamespace(), "deploy"), @@ -122,7 +122,7 @@ protected void writeDeployServices() throws IOException { //deploy the ports on each service Map serviceMap = definition.getServices(); - for (Iterator mapIterator = serviceMap.values().iterator(); + for (Iterator mapIterator = serviceMap.values().iterator(); mapIterator.hasNext();) { Service myService = (Service) mapIterator.next(); @@ -135,7 +135,7 @@ for (Iterator portIterator = myService.getPorts().values().iterator(); portIterator.hasNext();) { Port myPort = (Port) portIterator.next(); - BindingEntry bEntry = + BindingEntry bEntry = symbolTable.getBindingEntry( myPort.getBinding().getQName()); @@ -164,7 +164,7 @@ // 1) Don't register types that are base (primitive) types. // If the baseType != null && getRefType() != null this // is a simpleType that must be registered. - // 2) Don't register the special types for collections + // 2) Don't register the special types for collections // (indexed properties) or element types // 3) Don't register types that are not referenced // or only referenced in a literal context. @@ -294,7 +294,7 @@ } QName defaultQName = new QName("", javaOperName); if (! defaultQName.equals(elementQName)) { - pw.print(" qname=\"" + + pw.print(" qname=\"" + Utils.genQNameAttributeString(elementQName, "operNS") + "\""); } @@ -303,8 +303,8 @@ if (params.returnName != null) returnQName = Utils.getWSDLQName(params.returnName); if (returnQName != null) { - pw.print(" returnQName=\"" + - Utils.genQNameAttributeString(returnQName, "retNS") + + pw.print(" returnQName=\"" + + Utils.genQNameAttributeString(returnQName, "retNS") + "\""); } pw.println(">"); @@ -320,21 +320,25 @@ } else { paramType = typeEntry.getQName(); } - String mode = getModeString(param.getMode()); - pw.print(" <parameter "); + pw.print(" <parameter"); if (paramQName == null || "".equals(paramQName.getNamespaceURI())) { - pw.print("name=\"" + param.getName() + "\" " ); + pw.print(" name=\"" + param.getName() + "\"" ); } else { - pw.print("qname=\"pns:" + paramQName.getLocalPart() + - "\" xmlns:pns=\"" + paramQName.getNamespaceURI() + - "\" "); - } - pw.print("type=\"tns:" + paramType.getLocalPart() + "\" " ); - pw.print("xmlns:tns=\"" + paramType.getNamespaceURI() + "\" " ); - pw.print("mode=\"" + mode + "\"" ); + pw.print(" qname=\"" + + Utils.genQNameAttributeString(paramQName, + "pns") + "\""); + } + pw.print(" type=\"" + + Utils.genQNameAttributeString(paramType, + "tns") + "\""); + if (param.getMode() != Parameter.IN) { + String mode = getModeString(param.getMode()); + pw.print(" mode=\"" + mode + "\""); + } + pw.println("/>"); } - + pw.println(" </operation>"); } } 1.1 xml-axis/java/test/wsdl/qualify/Qualify_BindingImpl.java Index: Qualify_BindingImpl.java =================================================================== /** * Qualify_BindingImpl.java * * This file was auto-generated from WSDL * by the Apache Axis Wsdl2java emitter. */ package test.wsdl.qualify; public class Qualify_BindingImpl implements test.wsdl.qualify.Qualify_Binding { public java.lang.String simple(java.lang.String name) throws java.rmi.RemoteException { // Validate XML request to make sure elements are properly qualified // or not per the WSDL // FIXME // Return a response (which the client will validate) return "Hello there: " + name; } public test.wsdl.qualify.Response formOverride(test.wsdl.qualify.Complex complex) throws java.rmi.RemoteException { // Validate XML request to make sure elements are properly qualified // or not per the WSDL // FIXME // Return a response (which the client will validate) test.wsdl.qualify.Response r = new Response(); r.setName("Tommy"); return r; } } 1.1 xml-axis/java/test/wsdl/qualify/Qualify_ServiceTestCase.java Index: Qualify_ServiceTestCase.java =================================================================== /** * Qualify_ServiceTestCase.java * * This file was auto-generated from WSDL * by the Apache Axis Wsdl2java emitter. */ package test.wsdl.qualify; public class Qualify_ServiceTestCase extends junit.framework.TestCase { public Qualify_ServiceTestCase(String name) { super(name); } public void test1QualifySimple() { test.wsdl.qualify.Qualify_Binding binding; try { binding = new test.wsdl.qualify.Qualify_ServiceLocator().getQualify(); } catch (javax.xml.rpc.ServiceException jre) { throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); } assertTrue("binding is null", binding != null); try { java.lang.String value = null; java.lang.String name = "Tommy"; value = binding.simple(name); // Get the XML response // Validate XML reponse to make sure elements are properly qualified // or not per the WSDL // FIXME // Check the response junit.framework.Assert.assertEquals(value, "Hello there: " + name); } catch (java.rmi.RemoteException re) { throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re); } } public void test2QualifyFormOverride() { test.wsdl.qualify.Qualify_Binding binding; try { binding = new test.wsdl.qualify.Qualify_ServiceLocator().getQualify(); } catch (javax.xml.rpc.ServiceException jre) { throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); } assertTrue("binding is null", binding != null); try { test.wsdl.qualify.Response value = null; value = binding.formOverride(new test.wsdl.qualify.Complex()); // Get the XML response // Validate XML reponse to make sure elements are properly qualified // or not per the WSDL // FIXME // Check the response junit.framework.Assert.assertEquals(value.getName(), "Tommy"); } catch (java.rmi.RemoteException re) { throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re); } } } 1.1 xml-axis/java/test/wsdl/qualify/qualifytest.wsdl Index: qualifytest.wsdl =================================================================== <?xml version="1.0" encoding="utf-8"?> <definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="urn:qualifyTest" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="urn:qualifyTest" xmlns="http://schemas.xmlsoap.org/wsdl/"> <documentation> This test tests the use and overriding of the "elementFormDefault" attribute. We have a simple test which uses a qualified element "name", and then a more complex test which overrides the default to use an unqualified element inside both the request and the response. </documentation> <types> <s:schema elementFormDefault="qualified" targetNamespace="urn:qualifyTest"> <s:element name="Simple"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="name" type="s:string" /> </s:sequence> </s:complexType> </s:element> <s:element name="SimpleResponse"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="SimpleResult" type="s:string" /> </s:sequence> </s:complexType> </s:element> <s:element name="FormOverride"> <s:complexType> <s:sequence> <s:element form="unqualified" minOccurs="0" maxOccurs="1" name="complex"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="name" type="s:string"/> </s:sequence> </s:complexType> </s:element> </s:sequence> </s:complexType> </s:element> <s:element name="FormOverrideResponse"> <s:complexType> <s:sequence> <s:element form="unqualified" minOccurs="0" maxOccurs="1" name="response"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="name" type="s:string"/> </s:sequence> </s:complexType> </s:element> </s:sequence> </s:complexType> </s:element> </s:schema> </types> <message name="SimpleSoapIn"> <part name="parameters" element="s0:Simple" /> </message> <message name="SimpleSoapOut"> <part name="parameters" element="s0:SimpleResponse" /> </message> <message name="FormOverrideSoapIn"> <part name="parameters" element="s0:FormOverride" /> </message> <message name="FormOverrideSoapOut"> <part name="parameters" element="s0:FormOverrideResponse" /> </message> <portType name="Qualify"> <operation name="Simple"> <input message="s0:SimpleSoapIn" /> <output message="s0:SimpleSoapOut" /> </operation> <operation name="FormOverride"> <input message="s0:FormOverrideSoapIn" /> <output message="s0:FormOverrideSoapOut" /> </operation> </portType> <binding name="Qualify" type="s0:Qualify"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> <operation name="Simple"> <soap:operation soapAction="" style="document" /> <input> <soap:body use="literal" /> </input> <output> <soap:body use="literal" /> </output> </operation> <operation name="FormOverride"> <soap:operation soapAction="" style="document" /> <input> <soap:body use="literal" /> </input> <output> <soap:body use="literal" /> </output> </operation> </binding> <service name="Qualify"> <port name="Qualify" binding="s0:Qualify"> <soap:address location="http://localhost:8080/axis/services/Qualify" /> </port> </service> </definitions>