< prev index next >

src/java.xml.ws/share/classes/com/sun/xml/internal/ws/wsdl/writer/WSDLGenerator.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 69,90 **** import com.sun.xml.internal.ws.wsdl.writer.document.soap.Body; import com.sun.xml.internal.ws.wsdl.writer.document.soap.BodyType; import com.sun.xml.internal.ws.wsdl.writer.document.soap.Header; import com.sun.xml.internal.ws.wsdl.writer.document.soap.SOAPAddress; import com.sun.xml.internal.ws.wsdl.writer.document.soap.SOAPFault; - import com.sun.xml.internal.ws.wsdl.writer.document.xsd.Schema; import com.sun.xml.internal.ws.spi.db.BindingContext; import com.sun.xml.internal.ws.spi.db.BindingHelper; - import com.sun.xml.internal.ws.spi.db.TypeInfo; - import com.sun.xml.internal.ws.spi.db.WrapperComposite; import com.sun.xml.internal.ws.util.RuntimeVersion; import com.sun.xml.internal.ws.policy.jaxws.PolicyWSDLGeneratorExtension; import com.sun.xml.internal.ws.encoding.soap.streaming.SOAPNamespaceConstants; - import com.sun.xml.internal.bind.v2.schemagen.xmlschema.Element; - import com.sun.xml.internal.bind.v2.schemagen.xmlschema.ComplexType; - import com.sun.xml.internal.bind.v2.schemagen.xmlschema.ExplicitGroup; - import com.sun.xml.internal.bind.v2.schemagen.xmlschema.LocalElement; import javax.jws.soap.SOAPBinding.Style; import javax.jws.soap.SOAPBinding.Use; import javax.xml.bind.SchemaOutputResolver; import javax.xml.namespace.QName; --- 69,83 ----
*** 98,113 **** import javax.xml.transform.sax.SAXResult; import javax.xml.ws.Holder; import javax.xml.ws.WebServiceException; import org.w3c.dom.Document; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; - import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; --- 91,106 ---- import javax.xml.transform.sax.SAXResult; import javax.xml.ws.Holder; import javax.xml.ws.WebServiceException; import org.w3c.dom.Document; + import org.w3c.dom.NodeList; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set;
*** 127,152 **** /** * Constant String for ".wsdl" */ private static final String DOT_WSDL = ".wsdl"; /** - * Constant String appended to response message names - */ - private static final String RESPONSE = "Response"; - /** - * constant String used for part name for wrapped request messages - */ - private static final String PARAMETERS = "parameters"; - /** - * the part name for unwrappable response messages - */ - private static final String RESULT = "parameters"; - /** - * the part name for response messages that are not unwrappable - */ - private static final String UNWRAPPABLE_RESULT = "result"; - /** * The WSDL namespace */ private static final String WSDL_NAMESPACE = WSDLConstants.NS_WSDL; /** --- 120,129 ----
*** 194,203 **** --- 171,183 ---- private static final String LITERAL = "literal"; /** * Constant String to flag the URL to replace at runtime for the endpoint */ private static final String REPLACE_WITH_ACTUAL_URL = "REPLACE_WITH_ACTUAL_URL"; + + static public final String XsdNs = "http://www.w3.org/2001/XMLSchema"; + private Set<QName> processedExceptions = new HashSet<QName>(); private WSBinding binding; private String wsdlLocation; private String portWSDLID; private String schemaPrefix;
*** 466,542 **** TransformerFactory tf = XmlUtil.newTransformerFactory(!disableXmlSecurity); try { Transformer t = tf.newTransformer(); for (DOMResult xsd : resolver.nonGlassfishSchemas) { Document doc = (Document) xsd.getNode(); SAXResult sax = new SAXResult(new TXWContentHandler(types)); t.transform(new DOMSource(doc.getDocumentElement()), sax); } } catch (TransformerConfigurationException e) { throw new WebServiceException(e.getMessage(), e); } catch (TransformerException e) { throw new WebServiceException(e.getMessage(), e); } } - generateWrappers(); - } - - void generateWrappers() { - List<WrapperParameter> wrappers = new ArrayList<WrapperParameter>(); - for (JavaMethodImpl method : model.getJavaMethods()) { - if(method.getBinding().isRpcLit()) continue; - for (ParameterImpl p : method.getRequestParameters()) { - if (p instanceof WrapperParameter) { - if (WrapperComposite.class.equals((((WrapperParameter)p).getTypeInfo().type))) { - wrappers.add((WrapperParameter)p); - } - } - } - for (ParameterImpl p : method.getResponseParameters()) { - if (p instanceof WrapperParameter) { - if (WrapperComposite.class.equals((((WrapperParameter)p).getTypeInfo().type))) { - wrappers.add((WrapperParameter)p); - } - } - } - } - if (wrappers.isEmpty()) return; - HashMap<String, Schema> xsds = new HashMap<String, Schema>(); - for(WrapperParameter wp : wrappers) { - String tns = wp.getName().getNamespaceURI(); - Schema xsd = xsds.get(tns); - if (xsd == null) { - xsd = types.schema(); - xsd.targetNamespace(tns); - xsds.put(tns, xsd); - } - Element e = xsd._element(Element.class); - e._attribute("name", wp.getName().getLocalPart()); - e.type(wp.getName()); - ComplexType ct = xsd._element(ComplexType.class); - ct._attribute("name", wp.getName().getLocalPart()); - ExplicitGroup sq = ct.sequence(); - for (ParameterImpl p : wp.getWrapperChildren() ) { - if (p.getBinding().isBody()) { - LocalElement le = sq.element(); - le._attribute("name", p.getName().getLocalPart()); - TypeInfo typeInfo = p.getItemType(); - boolean repeatedElement = false; - if (typeInfo == null) { - typeInfo = p.getTypeInfo(); - } else { - repeatedElement = true; - } - QName type = model.getBindingContext().getTypeName(typeInfo); - le.type(type); - if (repeatedElement) { - le.minOccurs(0); - le.maxOccurs("unbounded"); - } - } - } - } } /** * Generates the WSDL messages */ --- 446,471 ---- TransformerFactory tf = XmlUtil.newTransformerFactory(!disableXmlSecurity); try { Transformer t = tf.newTransformer(); for (DOMResult xsd : resolver.nonGlassfishSchemas) { Document doc = (Document) xsd.getNode(); + if (inlineSchemas) { + NodeList importList = doc.getDocumentElement().getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "import"); + for(int i = 0; i < importList.getLength(); i++) { + org.w3c.dom.Element impElem = (org.w3c.dom.Element)importList.item(i); + impElem.removeAttribute("schemaLocation"); + } + } SAXResult sax = new SAXResult(new TXWContentHandler(types)); t.transform(new DOMSource(doc.getDocumentElement()), sax); } } catch (TransformerConfigurationException e) { throw new WebServiceException(e.getMessage(), e); } catch (TransformerException e) { throw new WebServiceException(e.getMessage(), e); } } } /** * Generates the WSDL messages */
< prev index next >