001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.net.rpc.client; 020 021import java.util.Iterator; 022import java.util.List; 023import java.util.Map; 024import java.util.Map.Entry; 025 026import javax.wsdl.Message; 027import javax.wsdl.Port; 028import javax.wsdl.extensions.soap.SOAPAddress; 029import javax.xml.namespace.QName; 030 031import lucee.runtime.net.rpc.RPCException; 032 033public class WSUtil { 034 public static Port getSoapPort(javax.wsdl.Service service) throws RPCException { 035 String name = null; 036 Port port = null; 037 List list = null; 038 Map ports = service.getPorts(); 039 Iterator it; 040 Iterator<Port> itr = ports.values().iterator(); 041 Object v; 042 while(itr.hasNext()) { 043 port = itr.next(); 044 045 list=port.getExtensibilityElements(); 046 if(list != null) { 047 it = list.iterator(); 048 while(it.hasNext()) { 049 v=it.next(); 050 if(v instanceof SOAPAddress) { 051 return port; 052 } 053 } 054 055 } 056 } 057 throw new RPCException("Can't locate port entry for service " + service.getQName().toString() + " WSDL"); 058 } 059 060 public static Message getMessageByLocalName(Map<QName, Message> messages, String name) { 061 Iterator<Entry<QName,Message>> it = messages.entrySet().iterator(); 062 Entry<QName,Message> e; 063 while(it.hasNext()){ 064 e = it.next(); 065 //print.e(e.getKey().getLocalPart()+":"+name); 066 if(e.getKey().getLocalPart().equals(name)) return e.getValue(); 067 } 068 return null; 069 } 070}