wsdldefinitions.java
来自「RESIN 3.2 最新源码」· Java 代码 · 共 580 行 · 第 1/2 页
JAVA
580 行
/* * Copyright (c) 1998-2007 Caucho Technology -- all rights reserved * * This file is part of Resin(R) Open Source * * Each copy or derived work must preserve the copyright notice and this * notice unmodified. * * Resin Open Source is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Resin Open Source is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty * of NON-INFRINGEMENT. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with Resin Open Source; if not, write to the * Free SoftwareFoundation, Inc. * 59 Temple Place, Suite 330 * Boston, MA 02111-1307 USA * * @author Scott Ferguson */package com.caucho.soap.wsdl;import java.io.*;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import javax.xml.bind.JAXBException;import javax.xml.bind.Unmarshaller;import javax.xml.bind.annotation.XmlAccessType;import javax.xml.bind.annotation.XmlAccessorType;import javax.xml.bind.annotation.XmlAttribute;import javax.xml.bind.annotation.XmlElement;import javax.xml.bind.annotation.XmlElements;import javax.xml.bind.annotation.XmlRootElement;import javax.xml.bind.annotation.XmlTransient;import javax.xml.namespace.QName;import static com.caucho.soap.wsdl.WSDLConstants.*;import com.caucho.java.JavaWriter;import com.caucho.util.L10N;import com.caucho.vfs.Vfs;import com.caucho.vfs.WriteStream;import com.caucho.xml.schema.Type;/** * WSDL Definitions top level */@XmlAccessorType(XmlAccessType.FIELD)@XmlRootElement(name="definitions", namespace=WSDL_NAMESPACE)public class WSDLDefinitions extends WSDLExtensibleDocumented { @XmlTransient private static final L10N L = new L10N(WSDLDefinitions.class); @XmlAttribute(name="name") private String _name; @XmlAttribute(name="targetNamespace") private String _targetNamespace; @XmlElement(name="import", namespace=WSDL_NAMESPACE) private List<WSDLImport> _imports; @XmlElement(name="types", namespace=WSDL_NAMESPACE, required=true) private List<WSDLTypes> _types; @XmlElement(name="message", namespace=WSDL_NAMESPACE, required=true) private List<WSDLMessage> _messages; @XmlElement(name="portType", namespace=WSDL_NAMESPACE, required=true) private List<WSDLPortType> _portTypes; @XmlElement(name="binding", namespace=WSDL_NAMESPACE, required=true) private List<WSDLBinding> _bindings; @XmlElement(name="service", namespace=WSDL_NAMESPACE, required=true) private List<WSDLService> _services; @XmlTransient private final Map<QName,WSDLMessage> _messageMap = new HashMap<QName,WSDLMessage>(); @XmlTransient private final Map<QName,WSDLPortType> _portTypeMap = new HashMap<QName,WSDLPortType>(); @XmlTransient private final Map<QName,WSDLBinding> _bindingMap = new HashMap<QName,WSDLBinding>(); @XmlTransient private String _endpointAddress; @XmlTransient private String _bindingId; /** * Sets the definition name. */ public void setName(String name) { _name = name; } public String getName() { return _name; } /** * Sets the target namespace */ public void setTargetNamespace(String uri) { _targetNamespace = uri; } /** * Gets the target namespace */ public String getTargetNamespace() { return _targetNamespace; } public List<WSDLImport> getImports() { if (_imports == null) return _imports = new ArrayList<WSDLImport>(); return _imports; } public List<WSDLTypes> getTypes() { if (_types == null) return _types = new ArrayList<WSDLTypes>(); return _types; } public List<WSDLMessage> getMessages() { if (_messages == null) return _messages = new ArrayList<WSDLMessage>(); return _messages; } public List<WSDLPortType> getPortTypes() { if (_portTypes == null) return _portTypes = new ArrayList<WSDLPortType>(); return _portTypes; } public List<WSDLBinding> getBindings() { if (_bindings == null) return _bindings = new ArrayList<WSDLBinding>(); return _bindings; } public List<WSDLService> getServices() { if (_services == null) return _services = new ArrayList<WSDLService>(); return _services; } public String getBindingId(QName serviceName, QName portName) { if (_bindingId == null) { if (! serviceName.getNamespaceURI().equals(getTargetNamespace())) return null; // first find out which binding we're looking for QName bindingName = null; if (_services != null) { for (int i = 0; i < _services.size(); i++) { WSDLService service = _services.get(i); if (serviceName.getLocalPart().equals(service.getName())) { List<WSDLPort> ports = service.getPorts(); for (int j = 0; j < ports.size(); j++) { WSDLPort port = ports.get(j); if (portName.getLocalPart().equals(port.getName())) { bindingName = port.getBinding(); break; } } if (bindingName != null) break; } } } if (bindingName != null && _bindings != null) { for (int i = 0; i < _bindings.size(); i++) { WSDLBinding binding = _bindings.get(i); if (bindingName.getLocalPart().equals(binding.getName())) { List<Object> any = binding.getAny(); for (int j = 0; j < any.size(); j++) { if (any.get(j) instanceof SOAPBinding) { SOAPBinding soapBinding = (SOAPBinding) any.get(j); _bindingId = soapBinding.getTransport(); return _bindingId; } } } } } } return _bindingId; } public String getEndpointAddress(QName serviceName, QName portName) { if (_endpointAddress == null) { if (! serviceName.getNamespaceURI().equals(getTargetNamespace())) return null; // dig down to find the <soap:address location="..."/> if (_services != null) { for (int i = 0; i < _services.size(); i++) { WSDLService service = _services.get(i); if (serviceName.getLocalPart().equals(service.getName())) { List<WSDLPort> ports = service.getPorts(); for (int j = 0; j < ports.size(); j++) { WSDLPort port = ports.get(j); if (portName.getLocalPart().equals(port.getName())) { List<Object> any = port.getAny(); for (int k = 0; k < any.size(); k++) { if (any.get(k) instanceof SOAPAddress) { SOAPAddress address = (SOAPAddress) any.get(k); _endpointAddress = address.getLocation(); return _endpointAddress; } } } } } } } } return _endpointAddress; } /** * Sets up the cached, transient data. **/ public void afterUnmarshal(Unmarshaller u, Object o) throws JAXBException, WSDLValidationException { if (_messages != null) { for (WSDLMessage message : _messages) { QName name = null;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?