⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wsdlutils.java

📁 bpel执行引擎用来执行bpel业务流程
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements.  See the NOTICE file * distributed with this work for additional information * regarding copyright ownership.  The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License.  You may obtain a copy of the License at * *    http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied.  See the License for the * specific language governing permissions and limitations * under the License. */package org.apache.ode.utils.wsdl;import org.apache.ode.utils.Namespaces;import org.apache.ode.utils.stl.CollectionsX;import org.w3c.dom.Element;import javax.wsdl.Binding;import javax.wsdl.BindingFault;import javax.wsdl.BindingInput;import javax.wsdl.BindingOperation;import javax.wsdl.Definition;import javax.wsdl.Fault;import javax.wsdl.Operation;import javax.wsdl.Part;import javax.wsdl.Port;import javax.wsdl.Service;import javax.wsdl.extensions.ExtensibilityElement;import javax.wsdl.extensions.UnknownExtensibilityElement;import javax.wsdl.extensions.http.HTTPAddress;import javax.wsdl.extensions.http.HTTPBinding;import javax.wsdl.extensions.http.HTTPOperation;import javax.wsdl.extensions.http.HTTPUrlEncoded;import javax.wsdl.extensions.http.HTTPUrlReplacement;import javax.wsdl.extensions.mime.MIMEContent;import javax.wsdl.extensions.mime.MIMEMultipartRelated;import javax.wsdl.extensions.soap.SOAPAddress;import javax.wsdl.extensions.soap.SOAPBinding;import javax.wsdl.extensions.soap.SOAPOperation;import javax.xml.namespace.QName;import java.util.ArrayList;import java.util.Collection;import java.util.List;/** * @author <a href="mailto:midon@intalio.com">Alexis Midon</a> */public class WsdlUtils {    private static final Messages msgs = Messages.getMessages(Messages.class);    /**     * Test if the given binding uses a Soap binding.     *     * @param binding     * @return true if {@link SOAPBinding} is assignable from the binding     * @see #getBindingExtension(javax.wsdl.Binding)     */    public static boolean useSOAPBinding(Binding binding) {        ExtensibilityElement element = getBindingExtension(binding);        return SOAPBinding.class.isAssignableFrom(element.getClass());    }    /**     * Test if the given binding uses HTTP binding.     *     * @param binding     * @return true if {@link HTTPBinding} is assignable from the binding     * @see #getBindingExtension(javax.wsdl.Binding)     */    public static boolean useHTTPBinding(Binding binding) {        ExtensibilityElement element = getBindingExtension(binding);        // with a fully wsdl-compliant document, this element cannot be null.        // but ODE extends the HTTP binding and supports the HTTP verb at the operation level.        // A port using this extension may have no HTTPBinding at the port level.          if (element == null) {            // in this case, we check the binding information of one operation            final BindingOperation anOperation = (BindingOperation) binding.getBindingOperations().get(0);            final ExtensibilityElement opExt = getOperationExtension(anOperation);            return HTTPOperation.class.isAssignableFrom(opExt.getClass());        } else {            return HTTPBinding.class.isAssignableFrom(element.getClass());        }    }    /**     * @see #useSOAPBinding(javax.wsdl.Binding)     */    public static boolean useSOAPBinding(Port port) {        return useSOAPBinding(port.getBinding());    }    /**     * @see #useHTTPBinding(javax.wsdl.Binding)     */    public static boolean useHTTPBinding(Port port) {        return useHTTPBinding(port.getBinding());    }    /**     * @see #useSOAPBinding(javax.wsdl.Binding)     */    public static boolean useSOAPBinding(Definition def, QName serviceName, String portName) {        Service serviceDef = def.getService(serviceName);        if (serviceDef == null)            throw new IllegalArgumentException(msgs.msgServiceDefinitionNotFound(serviceName));        Port port = serviceDef.getPort(portName);        if (port == null)            throw new IllegalArgumentException(msgs.msgPortDefinitionNotFound(serviceName, portName));        return useSOAPBinding(port);    }    /**     * @see #useHTTPBinding(javax.wsdl.Binding)     */    public static boolean useHTTPBinding(Definition def, QName serviceName, String portName) {        Service serviceDef = def.getService(serviceName);        if (serviceDef == null)            throw new IllegalArgumentException(msgs.msgServiceDefinitionNotFound(serviceName));        Port port = serviceDef.getPort(portName);        if (port == null)            throw new IllegalArgumentException(msgs.msgPortDefinitionNotFound(serviceName, portName));        return useHTTPBinding(port);    }    /**     * Look up the ExtensibilityElement defining the binding for the given Port or     * throw an {@link IllegalArgumentException} if multiple bindings found.     *     * @param binding     * @return an instance of {@link SOAPBinding} or {@link HTTPBinding} or null     * @throws IllegalArgumentException if multiple bindings found.     */    public static ExtensibilityElement getBindingExtension(Binding binding) {        Collection bindings = new ArrayList();        CollectionsX.filter(bindings, binding.getExtensibilityElements(), HTTPBinding.class);        CollectionsX.filter(bindings, binding.getExtensibilityElements(), SOAPBinding.class);        if (bindings.size() == 0) {            return null;        } else if (bindings.size() > 1) {            // exception if multiple bindings found            throw new IllegalArgumentException(msgs.msgMultipleBindings(binding.getQName()));        } else {            // retrieve the single element            ExtensibilityElement result = (ExtensibilityElement) bindings.iterator().next();            return result;        }    }    /**     * @see #getBindingExtension(javax.wsdl.Binding)     */    public static ExtensibilityElement getBindingExtension(Port port) {        Binding binding = port.getBinding();        if (binding == null) {            throw new IllegalArgumentException(msgs.msgBindingNotFound(port.getName()));        }        return getBindingExtension(binding);    }    /**     * Extract the instance of {@link javax.wsdl.extensions.http.HTTPOperation] or {@link javax.wsdl.extensions.soap.SOAPOperation}     * from the list of extensibility elements of the given {@link javax.wsdl.BindingOperation}.     *     * @param bindingOperation     * @return an instance of {@link javax.wsdl.extensions.http.HTTPOperation} or {@link javax.wsdl.extensions.soap.SOAPOperation}     * @throws IllegalArgumentException if not exactly 1 element is found.     */    public static ExtensibilityElement getOperationExtension(BindingOperation bindingOperation) {        Collection operations = new ArrayList();        CollectionsX.filter(operations, bindingOperation.getExtensibilityElements(), HTTPOperation.class);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -