Return-Path: Delivered-To: apmail-ws-axis-cvs-archive@www.apache.org Received: (qmail 71789 invoked from network); 12 Jun 2005 14:54:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 12 Jun 2005 14:54:49 -0000 Received: (qmail 6368 invoked by uid 500); 12 Jun 2005 14:54:47 -0000 Delivered-To: apmail-ws-axis-cvs-archive@ws.apache.org Received: (qmail 6267 invoked by uid 500); 12 Jun 2005 14:54:46 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 6250 invoked by uid 99); 12 Jun 2005 14:54:46 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sun, 12 Jun 2005 07:54:45 -0700 Received: (qmail 71743 invoked by uid 1203); 12 Jun 2005 14:54:44 -0000 Date: 12 Jun 2005 14:54:44 -0000 Message-ID: <20050612145444.71742.qmail@minotaur.apache.org> From: dims@apache.org To: ws-axis-cvs@apache.org Subject: cvs commit: ws-axis/java/src/org/apache/axis/wsdl/fromJava Types.java X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N dims 2005/06/12 07:54:44 Modified: java/src/org/apache/axis/wsdl/toJava JavaDeployWriter.java java/src/org/apache/axis/wsdl/symbolTable SymbolTable.java java/src/org/apache/axis/wsdl/fromJava Types.java Log: Fix for AXIS-1366 - Service re-creates incorrect WSDL http://issues.apache.org/jira/browse/AXIS-1366 Revision Changes Path 1.98 +33 -3 ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java Index: JavaDeployWriter.java =================================================================== RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java,v retrieving revision 1.97 retrieving revision 1.98 diff -u -r1.97 -r1.98 --- JavaDeployWriter.java 24 May 2005 15:51:36 -0000 1.97 +++ JavaDeployWriter.java 12 Jun 2005 14:54:44 -0000 1.98 @@ -406,14 +406,44 @@ + service.getQName().getNamespaceURI() + "\"/>"); pw.println(" "); - pw.println(" "); - // MIME attachments don't work with multiref, so turn it off. if (hasMIME) { pw.println( " "); } + ArrayList qualified = new ArrayList(); + ArrayList unqualified = new ArrayList(); + Map elementFormDefaults = symbolTable.getElementFormDefaults(); + for(Iterator it = elementFormDefaults.entrySet().iterator();it.hasNext();){ + Map.Entry entry = (Map.Entry) it.next(); + if(entry.getValue().equals("qualified")){ + qualified.add(entry.getKey()); + } else { + unqualified.add(entry.getKey()); + } + } + if(qualified.size()>0){ + pw.print(" "); + } + if(unqualified.size()>0){ + pw.print(" "); + } + pw.println(" "); writeDeployBinding(pw, bEntry); writeDeployTypes(pw, bEntry.getBinding(), hasLiteral, hasMIME, use); 1.121 +16 -1 ws-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java Index: SymbolTable.java =================================================================== RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java,v retrieving revision 1.120 retrieving revision 1.121 diff -u -r1.120 -r1.121 --- SymbolTable.java 3 Jun 2005 22:23:50 -0000 1.120 +++ SymbolTable.java 12 Jun 2005 14:54:44 -0000 1.121 @@ -175,6 +175,8 @@ Set arrayTypeQNames = new HashSet(); + /** Field elementFormDefaults */ + private final Map elementFormDefaults = new HashMap(); /** * Construct a symbol table with the given Namespaces. * @@ -1096,6 +1098,15 @@ if ((localPart != null) && localPart.equals("schema")) { level = SCHEMA_LEVEL; + String targetNamespace = ((org.w3c.dom.Element) node).getAttribute("targetNamespace"); + String elementFormDefault = ((org.w3c.dom.Element) node).getAttribute("elementFormDefault"); + if (targetNamespace != null && targetNamespace.length() > 0) { + elementFormDefault = (elementFormDefault == null || elementFormDefault.length() == 0) ? + "unqualified" : elementFormDefault; + if(elementFormDefaults.get(targetNamespace)==null) { + elementFormDefaults.put(targetNamespace, elementFormDefault); + } + } } } else { ++level; @@ -3786,4 +3797,8 @@ public void setWrapArrays(boolean wrapArrays) { this.wrapArrays = wrapArrays; } -} // class SymbolTable + + public Map getElementFormDefaults() { + return elementFormDefaults; + } +} 1.114 +64 -37 ws-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java Index: Types.java =================================================================== RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java,v retrieving revision 1.113 retrieving revision 1.114 diff -u -r1.113 -r1.114 --- Types.java 12 Apr 2005 22:18:16 -0000 1.113 +++ Types.java 12 Jun 2005 14:54:44 -0000 1.114 @@ -20,6 +20,7 @@ import org.apache.axis.Constants; import org.apache.axis.InternalException; import org.apache.axis.MessageContext; +import org.apache.axis.handlers.soap.SOAPService; import org.apache.axis.components.logger.LogFactory; import org.apache.axis.constants.Style; import org.apache.axis.description.ServiceDesc; @@ -33,6 +34,7 @@ import org.apache.axis.utils.JavaUtils; import org.apache.axis.utils.Messages; import org.apache.axis.utils.XMLUtils; +import org.apache.axis.utils.StringUtils; import org.apache.axis.wsdl.symbolTable.BaseTypeMapping; import org.apache.axis.wsdl.symbolTable.SymbolTable; import org.apache.axis.wsdl.symbolTable.TypeEntry; @@ -116,10 +118,10 @@ /** Keep track of the element QNames we've written to avoid dups */ private Set writtenElementQNames = new HashSet(); - + /** Which types have we already written? */ Class [] mappedTypes = null; - + /** The java to wsdl emitter */ Emitter emitter = null; @@ -169,7 +171,7 @@ this.defaultTM = defaultTM; mappedTypes = tm.getAllClasses(); - + this.namespaces = namespaces; this.targetNamespace = targetNamespace; this.stopClasses = stopClasses; @@ -190,10 +192,10 @@ * @param stopClasses * @param serviceDesc * @param emitter Java2Wsdl emitter - */ + */ public Types(Definition def, TypeMapping tm, TypeMapping defaultTM, - Namespaces namespaces, String targetNamespace, - List stopClasses, ServiceDesc serviceDesc, Emitter emitter) { + Namespaces namespaces, String targetNamespace, + List stopClasses, ServiceDesc serviceDesc, Emitter emitter) { this(def, tm, defaultTM, namespaces, targetNamespace, stopClasses, serviceDesc); this.emitter = emitter; } @@ -393,14 +395,14 @@ // replicable test data to the Axis team via bugzilla /* - * if( type==null ) { - * return null; - * } - */ + * if( type==null ) { + * return null; + * } + */ if (type.getName().equals("void")) { return null; } - + if (Holder.class.isAssignableFrom(type)) { type = JavaUtils.getHolderValueType(type); } @@ -422,7 +424,7 @@ return qname; } - + /** * Write out a type (and its subtypes) referenced by a part type attribute. * @@ -435,39 +437,39 @@ */ public QName writeTypeAndSubTypeForPart(Class type, QName qname) throws AxisFault { - + // Write out type in parameter QName qNameRet = writeTypeForPart(type, qname); - + // If mappedTypesexists // Will write subTypes of the type in parameters if (mappedTypes != null) { for (int i = 0; i < mappedTypes.length; i++) { Class tempMappedType = mappedTypes[i]; QName name; - + // If tempMappedType is subtype of the "type" parameter // and type is not Object (Object superclass of all Java class...) // write the subtype if (tempMappedType != null && - type != Object.class && + type != Object.class && tempMappedType != type && type.isAssignableFrom(tempMappedType)) { name = tm.getTypeQName(tempMappedType); if (!isAnonymousType(name)) { writeTypeForPart(tempMappedType, name); } - + // Only do each one once. This is OK to do because each // Types instance is for generating a single WSDL. mappedTypes[i] = null; } } } //if (mappedTyped != null) { - - return qNameRet; + + return qNameRet; } - + /** * Write out an element referenced by a part element attribute. * @@ -484,10 +486,10 @@ // replicable test data to the Axis team via bugzilla /* - * if( type==null ) { - * return null; - * } - */ + * if( type==null ) { + * return null; + * } + */ if (type.getName().equals("void")) { return null; } @@ -733,7 +735,7 @@ // If the javaType is an array and the qName is // SOAP_ARRAY, construct the QName using the // QName of the component type - if (isArray(javaType) && + if (isArray(javaType) && Constants.equals(Constants.SOAP_ARRAY, qName)) { Class componentType = getComponentType(javaType); @@ -746,7 +748,7 @@ if (isWSICompliant) { arrayTypePrefix = "MyArrayOf"; } - + // If component namespace uri == targetNamespace // Construct ArrayOf // Else @@ -944,7 +946,15 @@ Constants.URI_DEFAULT_SOAP_ENC); } - if ((serviceDesc.getStyle() == Style.DOCUMENT) + SOAPService service = null; + if(MessageContext.getCurrentContext() != null) { + service = MessageContext.getCurrentContext().getService(); + } + if(service != null && isPresent((String) service.getOption("schemaQualified"), namespaceURI)){ + schemaElem.setAttribute("elementFormDefault", "qualified"); + } else if(service != null && isPresent((String) service.getOption("schemaUnqualified"), namespaceURI)){ + // DO nothing..default is unqualified. + } else if ((serviceDesc.getStyle() == Style.DOCUMENT) || (serviceDesc.getStyle() == Style.WRAPPED)) { schemaElem.setAttribute("elementFormDefault", "qualified"); } @@ -956,6 +966,23 @@ } /** + * check if the namespace is present in the list. + * @param list + * @param namespace + * @return + */ + private boolean isPresent(String list, String namespace) { + if(list == null || list.length()==0) + return false; + String[] array = StringUtils.split(list,','); + for(int i=0;i element. if (anonymous) { - if (typeEl == null) { + if (typeEl == null) { containingElement.setAttribute("type", getQNameString(getTypeQName(type))); - } else { + } else { containingElement.appendChild(typeEl); - } + } } else { if (typeEl != null) { typeEl.setAttribute("name", qName.getLocalPart()); @@ -1858,7 +1885,7 @@ /** * return the service description * @return - */ + */ public ServiceDesc getServiceDesc() { return serviceDesc; }