ohair@286: /*
mkos@408: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
ohair@286: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@286: *
ohair@286: * This code is free software; you can redistribute it and/or modify it
ohair@286: * under the terms of the GNU General Public License version 2 only, as
ohair@286: * published by the Free Software Foundation. Oracle designates this
ohair@286: * particular file as subject to the "Classpath" exception as provided
ohair@286: * by Oracle in the LICENSE file that accompanied this code.
ohair@286: *
ohair@286: * This code is distributed in the hope that it will be useful, but WITHOUT
ohair@286: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@286: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@286: * version 2 for more details (a copy is included in the LICENSE file that
ohair@286: * accompanied this code).
ohair@286: *
ohair@286: * You should have received a copy of the GNU General Public License version
ohair@286: * 2 along with this work; if not, write to the Free Software Foundation,
ohair@286: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@286: *
ohair@286: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@286: * or visit www.oracle.com if you need additional information or have any
ohair@286: * questions.
ohair@286: */
ohair@286:
ohair@286: package com.sun.xml.internal.ws.api.model.wsdl;
ohair@286:
ohair@286:
ohair@286: import com.sun.istack.internal.NotNull;
ohair@286: import com.sun.xml.internal.ws.api.server.Container;
ohair@286: import com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension;
ohair@286: import com.sun.xml.internal.ws.api.wsdl.parser.XMLEntityResolver;
ohair@286: import com.sun.xml.internal.ws.api.policy.PolicyResolver;
ohair@286: import com.sun.xml.internal.ws.api.policy.PolicyResolverFactory;
ohair@286: import com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser;
ohair@286: import com.sun.xml.internal.ws.policy.PolicyMap;
mkos@408:
ohair@286: import org.xml.sax.SAXException;
ohair@286:
ohair@286: import javax.xml.namespace.QName;
ohair@286: import javax.xml.stream.XMLStreamException;
mkos@408:
ohair@286: import java.io.IOException;
ohair@286: import java.util.Map;
ohair@286:
ohair@286: /**
ohair@286: * Provides abstraction of wsdl:definitions.
ohair@286: *
ohair@286: * @author Vivek Pandey
ohair@286: */
ohair@286: public interface WSDLModel extends WSDLExtensible {
ohair@286: /**
ohair@286: * Gets {@link WSDLPortType} that models wsdl:portType
ohair@286: *
ohair@286: * @param name non-null quaified name of wsdl:message, where the localName is the value of wsdl:portType@name
and
ohair@286: * the namespaceURI is the value of wsdl:definitions@targetNamespace
ohair@286: * @return A {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLPortType} or null if no wsdl:portType found.
ohair@286: */
ohair@286: WSDLPortType getPortType(@NotNull QName name);
ohair@286:
ohair@286: /**
ohair@286: * Gets {@link WSDLBoundPortType} that models wsdl:binding
ohair@286: *
ohair@286: * @param name non-null quaified name of wsdl:binding, where the localName is the value of wsdl:binding@name
and
ohair@286: * the namespaceURI is the value of wsdl:definitions@targetNamespace
ohair@286: * @return A {@link WSDLBoundPortType} or null if no wsdl:binding found
ohair@286: */
ohair@286: WSDLBoundPortType getBinding(@NotNull QName name);
ohair@286:
ohair@286: /**
ohair@286: * Give a {@link WSDLBoundPortType} for the given wsdl:service and wsdl:port names.
ohair@286: *
ohair@286: * @param serviceName service QName
ohair@286: * @param portName port QName
ohair@286: * @return A {@link WSDLBoundPortType}. null if the Binding for the given wsd:service and wsdl:port name are not
ohair@286: * found.
ohair@286: */
ohair@286: WSDLBoundPortType getBinding(@NotNull QName serviceName, @NotNull QName portName);
ohair@286:
ohair@286: /**
ohair@286: * Gets {@link WSDLService} that models wsdl:service
ohair@286: *
ohair@286: * @param name non-null quaified name of wsdl:service, where the localName is the value of wsdl:service@name
and
ohair@286: * the namespaceURI is the value of wsdl:definitions@targetNamespace
ohair@286: * @return A {@link WSDLService} or null if no wsdl:service found
ohair@286: */
ohair@286: WSDLService getService(@NotNull QName name);
ohair@286:
ohair@286: /**
ohair@286: * Gives a {@link Map} of wsdl:portType {@link QName} and {@link WSDLPortType}
ohair@286: *
ohair@286: * @return an empty Map if the wsdl document has no wsdl:portType
ohair@286: */
ohair@286: @NotNull Map getPortTypes();
ohair@286:
ohair@286: /**
ohair@286: * Gives a {@link Map} of wsdl:binding {@link QName} and {@link WSDLBoundPortType}
ohair@286: *
ohair@286: * @return an empty Map if the wsdl document has no wsdl:binding
ohair@286: */
mkos@408: @NotNull Map getBindings();
ohair@286:
ohair@286: /**
ohair@286: * Gives a {@link Map} of wsdl:service qualified name and {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLService}
ohair@286: *
ohair@286: * @return an empty Map if the wsdl document has no wsdl:service
ohair@286: */
ohair@286: @NotNull Map getServices();
ohair@286:
ohair@286: /**
mkos@408: * Returns the first service QName from insertion order
mkos@408: */
mkos@408: public QName getFirstServiceName();
mkos@408:
mkos@408: /**
mkos@408: * Returns the message with the given QName
mkos@408: * @param name Message name
mkos@408: * @return Message
mkos@408: */
mkos@408: public WSDLMessage getMessage(QName name);
mkos@408:
mkos@408: /**
mkos@408: * Gives a {@link Map} of wsdl:message qualified name and {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLMesage}
mkos@408: *
mkos@408: * @return an empty Map if the wsdl document has no wsdl:message
mkos@408: */
mkos@408: @NotNull Map getMessages();
mkos@408:
mkos@408: /**
ohair@286: * Gives the PolicyMap associated with the WSDLModel
ohair@286: *
ohair@286: * @return PolicyMap
ohair@286: *
ohair@286: * @deprecated
ohair@286: * Do not use this method as the PolicyMap API is not final yet and might change in next few months.
ohair@286: */
ohair@286: public PolicyMap getPolicyMap();
ohair@286:
ohair@286: /**
ohair@286: * Main purpose of this class is to parsing of a WSDL and get the {@link WSDLModel} from it.
ohair@286: */
ohair@286: public class WSDLParser{
ohair@286: /**
ohair@286: * Parses WSDL from the given wsdlLoc and gives a {@link WSDLModel} built from it.
ohair@286: *
ohair@286: * @param wsdlEntityParser Works like an entityResolver to resolve WSDLs
ohair@286: * @param resolver {@link XMLEntityResolver}, works at XML infoset level
ohair@286: * @param isClientSide true - its invoked on the client, false means its invoked on the server
ohair@286: * @param extensions var args of {@link com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension}s
ohair@286: * @return A {@link WSDLModel} built from the given wsdlLocation}
ohair@286: * @throws java.io.IOException
ohair@286: * @throws javax.xml.stream.XMLStreamException
ohair@286: * @throws org.xml.sax.SAXException
ohair@286: */
ohair@286: public static @NotNull WSDLModel parse(XMLEntityResolver.Parser wsdlEntityParser, XMLEntityResolver resolver, boolean isClientSide, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException {
ohair@286: return parse(wsdlEntityParser, resolver, isClientSide, Container.NONE, extensions);
ohair@286: }
ohair@286:
ohair@286: /**
ohair@286: * Parses WSDL from the given wsdlLoc and gives a {@link WSDLModel} built from it.
ohair@286: *
ohair@286: * @param wsdlEntityParser Works like an entityResolver to resolve WSDLs
ohair@286: * @param resolver {@link XMLEntityResolver}, works at XML infoset level
ohair@286: * @param isClientSide true - its invoked on the client, false means its invoked on the server
ohair@286: * @param container - container in which the parser is run
ohair@286: * @param extensions var args of {@link com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension}s
ohair@286: * @return A {@link WSDLModel} built from the given wsdlLocation}
ohair@286: * @throws java.io.IOException
ohair@286: * @throws javax.xml.stream.XMLStreamException
ohair@286: * @throws org.xml.sax.SAXException
ohair@286: */
ohair@286: public static @NotNull WSDLModel parse(XMLEntityResolver.Parser wsdlEntityParser, XMLEntityResolver resolver, boolean isClientSide, @NotNull Container container, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException {
ohair@286: return parse(wsdlEntityParser, resolver, isClientSide, container, PolicyResolverFactory.create(),extensions);
ohair@286: }
ohair@286:
ohair@286:
ohair@286: /**
ohair@286: * Parses WSDL from the given wsdlLoc and gives a {@link WSDLModel} built from it.
ohair@286: *
ohair@286: * @param wsdlEntityParser Works like an entityResolver to resolve WSDLs
ohair@286: * @param resolver {@link XMLEntityResolver}, works at XML infoset level
ohair@286: * @param isClientSide true - its invoked on the client, false means its invoked on the server
ohair@286: * @param container - container in which the parser is run
ohair@286: * @param policyResolver - PolicyResolver for resolving effective Policy
ohair@286: * @param extensions var args of {@link com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension}s
ohair@286: * @return A {@link WSDLModel} built from the given wsdlLocation}
ohair@286: * @throws java.io.IOException
ohair@286: * @throws javax.xml.stream.XMLStreamException
ohair@286: * @throws org.xml.sax.SAXException
ohair@286: */
ohair@286: public static @NotNull WSDLModel parse(XMLEntityResolver.Parser wsdlEntityParser, XMLEntityResolver resolver, boolean isClientSide, @NotNull Container container, PolicyResolver policyResolver, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException {
ohair@286: return RuntimeWSDLParser.parse(wsdlEntityParser, resolver, isClientSide, container, policyResolver, extensions);
ohair@286: }
ohair@286:
ohair@286: }
ohair@286: }