KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > utils > WSDLUtils


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.axis.utils;
18
19 import org.apache.axis.components.logger.LogFactory;
20 import org.apache.axis.Constants;
21 import org.apache.commons.logging.Log;
22
23 import javax.wsdl.Port;
24 import javax.wsdl.extensions.soap.SOAPAddress;
25 import javax.wsdl.extensions.UnknownExtensibilityElement;
26 import javax.xml.namespace.QName JavaDoc;
27 import java.util.List JavaDoc;
28 import java.util.ListIterator JavaDoc;
29
30
31 public class WSDLUtils {
32     protected static Log log =
33         LogFactory.getLog(WSDLUtils.class.getName());
34
35     /**
36      * Return the endpoint address from a <soap:address location="..."> tag
37      */

38     public static String JavaDoc getAddressFromPort(Port p) {
39         // Get the endpoint for a port
40
List JavaDoc extensibilityList = p.getExtensibilityElements();
41         for (ListIterator JavaDoc li = extensibilityList.listIterator(); li.hasNext();) {
42             Object JavaDoc obj = li.next();
43             if (obj instanceof SOAPAddress) {
44                 return ((SOAPAddress) obj).getLocationURI();
45             } else if (obj instanceof UnknownExtensibilityElement){
46                 //TODO: After WSDL4J supports soap12, change this code
47
UnknownExtensibilityElement unkElement = (UnknownExtensibilityElement) obj;
48                 QName JavaDoc name = unkElement.getElementType();
49                 if(name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP) &&
50                    name.getLocalPart().equals("address")) {
51                     return unkElement.getElement().getAttribute("location");
52                 }
53             }
54         }
55         // didn't find it
56
return null;
57     } // getAddressFromPort
58

59 } // class WSDLUtils
60
Popular Tags