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

📄 locatebindinghandler.java

📁 Xfire文件 用于开发web service 的一个开源工具 很好用的
💻 JAVA
字号:
package org.codehaus.xfire.handler;import java.util.Iterator;import org.codehaus.xfire.MessageContext;import org.codehaus.xfire.fault.XFireFault;import org.codehaus.xfire.service.Binding;import org.codehaus.xfire.service.Endpoint;import org.codehaus.xfire.service.Service;import org.codehaus.xfire.soap.handler.ReadHeadersHandler;import org.codehaus.xfire.transport.Channel;/** * Finds the appropriate binding to use when invoking a service. This is delegated * to the transport via the findBinding method. *  * @author Dan Diephouse */public class LocateBindingHandler    extends AbstractHandler{    public LocateBindingHandler()    {        super();        setPhase(Phase.DISPATCH);        after(ReadHeadersHandler.class.getName());    }    public void invoke(MessageContext context)        throws Exception    {        if (context.getBinding() != null) return;                Channel c = context.getInMessage().getChannel();        Service service = context.getService();                if (service == null)         {            throw new XFireFault("Could not find a service to invoke.", XFireFault.SENDER);        }                // find a binding with that soap binding id        // set the binding        Binding binding =  c.getTransport().findBinding(context, service);                if (binding == null)        {            throw new XFireFault("Could not find an appropriate Transport Binding to invoke.", XFireFault.SENDER);        }                if (!binding.isUndefinedEndpointAllowed())        {            boolean defined = false;            for (Iterator itr = service.getEndpoints().iterator(); itr.hasNext();)            {                if (((Endpoint) itr.next()).getUrl().equals(c.getUri()))                {                    defined = true;                    break;                }            }                        if (!defined)            {                throw new XFireFault("Invalid endpoint for service.", XFireFault.SENDER);            }        }                context.setBinding(binding);    }}

⌨️ 快捷键说明

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