1/* 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26package com.sun.xml.internal.ws.api.model.wsdl; 27 28 29import com.sun.istack.internal.NotNull; 30import com.sun.xml.internal.ws.api.server.Container; 31import com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension; 32import com.sun.xml.internal.ws.api.wsdl.parser.XMLEntityResolver; 33import com.sun.xml.internal.ws.api.policy.PolicyResolver; 34import com.sun.xml.internal.ws.api.policy.PolicyResolverFactory; 35import com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser; 36import com.sun.xml.internal.ws.policy.PolicyMap; 37 38import org.xml.sax.SAXException; 39 40import javax.xml.namespace.QName; 41import javax.xml.stream.XMLStreamException; 42 43import java.io.IOException; 44import java.util.Map; 45 46/** 47 * Provides abstraction of wsdl:definitions. 48 * 49 * @author Vivek Pandey 50 */ 51public interface WSDLModel extends WSDLExtensible { 52 /** 53 * Gets {@link WSDLPortType} that models <code>wsdl:portType</code> 54 * 55 * @param name non-null quaified name of wsdl:message, where the localName is the value of <code>wsdl:portType@name</code> and 56 * the namespaceURI is the value of wsdl:definitions@targetNamespace 57 * @return A {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLPortType} or null if no wsdl:portType found. 58 */ 59 WSDLPortType getPortType(@NotNull QName name); 60 61 /** 62 * Gets {@link WSDLBoundPortType} that models <code>wsdl:binding</code> 63 * 64 * @param name non-null quaified name of wsdl:binding, where the localName is the value of <code>wsdl:binding@name</code> and 65 * the namespaceURI is the value of wsdl:definitions@targetNamespace 66 * @return A {@link WSDLBoundPortType} or null if no wsdl:binding found 67 */ 68 WSDLBoundPortType getBinding(@NotNull QName name); 69 70 /** 71 * Give a {@link WSDLBoundPortType} for the given wsdl:service and wsdl:port names. 72 * 73 * @param serviceName service QName 74 * @param portName port QName 75 * @return A {@link WSDLBoundPortType}. null if the Binding for the given wsd:service and wsdl:port name are not 76 * found. 77 */ 78 WSDLBoundPortType getBinding(@NotNull QName serviceName, @NotNull QName portName); 79 80 /** 81 * Gets {@link WSDLService} that models <code>wsdl:service</code> 82 * 83 * @param name non-null quaified name of wsdl:service, where the localName is the value of <code>wsdl:service@name</code> and 84 * the namespaceURI is the value of wsdl:definitions@targetNamespace 85 * @return A {@link WSDLService} or null if no wsdl:service found 86 */ 87 WSDLService getService(@NotNull QName name); 88 89 /** 90 * Gives a {@link Map} of wsdl:portType {@link QName} and {@link WSDLPortType} 91 * 92 * @return an empty Map if the wsdl document has no wsdl:portType 93 */ 94 @NotNull Map<QName, ? extends WSDLPortType> getPortTypes(); 95 96 /** 97 * Gives a {@link Map} of wsdl:binding {@link QName} and {@link WSDLBoundPortType} 98 * 99 * @return an empty Map if the wsdl document has no wsdl:binding 100 */ 101 @NotNull Map<QName, ? extends WSDLBoundPortType> getBindings(); 102 103 /** 104 * Gives a {@link Map} of wsdl:service qualified name and {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLService} 105 * 106 * @return an empty Map if the wsdl document has no wsdl:service 107 */ 108 @NotNull Map<QName, ? extends WSDLService> getServices(); 109 110 /** 111 * Returns the first service QName from insertion order 112 */ 113 public QName getFirstServiceName(); 114 115 /** 116 * Returns the message with the given QName 117 * @param name Message name 118 * @return Message 119 */ 120 public WSDLMessage getMessage(QName name); 121 122 /** 123 * Gives a {@link Map} of wsdl:message qualified name and {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLMesage} 124 * 125 * @return an empty Map if the wsdl document has no wsdl:message 126 */ 127 @NotNull Map<QName, ? extends WSDLMessage> getMessages(); 128 129 /** 130 * Gives the PolicyMap associated with the WSDLModel 131 * 132 * @return PolicyMap 133 * 134 * @deprecated 135 * Do not use this method as the PolicyMap API is not final yet and might change in next few months. 136 */ 137 public PolicyMap getPolicyMap(); 138 139 /** 140 * Main purpose of this class is to parsing of a WSDL and get the {@link WSDLModel} from it. 141 */ 142 public class WSDLParser{ 143 /** 144 * Parses WSDL from the given wsdlLoc and gives a {@link WSDLModel} built from it. 145 * 146 * @param wsdlEntityParser Works like an entityResolver to resolve WSDLs 147 * @param resolver {@link XMLEntityResolver}, works at XML infoset level 148 * @param isClientSide true - its invoked on the client, false means its invoked on the server 149 * @param extensions var args of {@link com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension}s 150 * @return A {@link WSDLModel} built from the given wsdlLocation} 151 * @throws java.io.IOException 152 * @throws javax.xml.stream.XMLStreamException 153 * @throws org.xml.sax.SAXException 154 */ 155 public static @NotNull WSDLModel parse(XMLEntityResolver.Parser wsdlEntityParser, XMLEntityResolver resolver, boolean isClientSide, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException { 156 return parse(wsdlEntityParser, resolver, isClientSide, Container.NONE, extensions); 157 } 158 159 /** 160 * Parses WSDL from the given wsdlLoc and gives a {@link WSDLModel} built from it. 161 * 162 * @param wsdlEntityParser Works like an entityResolver to resolve WSDLs 163 * @param resolver {@link XMLEntityResolver}, works at XML infoset level 164 * @param isClientSide true - its invoked on the client, false means its invoked on the server 165 * @param container - container in which the parser is run 166 * @param extensions var args of {@link com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension}s 167 * @return A {@link WSDLModel} built from the given wsdlLocation} 168 * @throws java.io.IOException 169 * @throws javax.xml.stream.XMLStreamException 170 * @throws org.xml.sax.SAXException 171 */ 172 public static @NotNull WSDLModel parse(XMLEntityResolver.Parser wsdlEntityParser, XMLEntityResolver resolver, boolean isClientSide, @NotNull Container container, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException { 173 return parse(wsdlEntityParser, resolver, isClientSide, container, PolicyResolverFactory.create(),extensions); 174 } 175 176 177 /** 178 * Parses WSDL from the given wsdlLoc and gives a {@link WSDLModel} built from it. 179 * 180 * @param wsdlEntityParser Works like an entityResolver to resolve WSDLs 181 * @param resolver {@link XMLEntityResolver}, works at XML infoset level 182 * @param isClientSide true - its invoked on the client, false means its invoked on the server 183 * @param container - container in which the parser is run 184 * @param policyResolver - PolicyResolver for resolving effective Policy 185 * @param extensions var args of {@link com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension}s 186 * @return A {@link WSDLModel} built from the given wsdlLocation} 187 * @throws java.io.IOException 188 * @throws javax.xml.stream.XMLStreamException 189 * @throws org.xml.sax.SAXException 190 */ 191 public static @NotNull WSDLModel parse(XMLEntityResolver.Parser wsdlEntityParser, XMLEntityResolver resolver, boolean isClientSide, @NotNull Container container, PolicyResolver policyResolver, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException { 192 return RuntimeWSDLParser.parse(wsdlEntityParser, resolver, isClientSide, container, policyResolver, extensions); 193 } 194 195 } 196} 197