Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: 1966cd0c229ae9548372dfca73639dc7f98a1aef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*******************************************************************************
 * Copyright (c) 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel;

import java.util.Vector;
import org.apache.wsil.Description;
import org.apache.wsil.Service;
import org.apache.wsil.extension.ExtensionElement;
import org.apache.wsil.extension.wsdl.ImplementedBinding;
import org.apache.wsil.extension.wsdl.Reference;
import org.apache.wsil.extension.wsdl.ReferencedService;
import org.eclipse.wst.ws.internal.datamodel.Model;

/**
* The data model element that represents 
* a WSDL service in a WSIL document
*/
public class WsilWsdlServiceElement extends WsilServiceElement
{
    public WsilWsdlServiceElement(String name, Model model, Service service) {
        super(name, model, service);
    }

    public String getWSDLServiceURL() {
        Description desc = getValidWSDLDescription();
        return (desc == null) ? null : makeAbsolute(desc.getLocation());
    }

    public Vector getWSDLBinding() {
        Vector v = new Vector();
        Description[] descList = service_.getDescriptions();
        for (int i = 0; i < descList.length; i++) {
            ExtensionElement extElement = descList[i].getExtensionElement();
            if (extElement != null && extElement instanceof Reference) {
                ReferencedService refService = ((Reference)extElement).getReferencedService();
                if (refService != null) {
                    v.add(refService.getReferencedServiceName());
                }
                ImplementedBinding[] implBindingList = ((Reference)extElement).getImplementedBindings();
                for (int j = 0; j < implBindingList.length; j++) {
                    v.add(implBindingList[j].getBindingName());
                }
            }
        }
        return v;
    }
    
    private Description getValidWSDLDescription() {
        Description[] descList = service_.getDescriptions();
        for (int i = 0; i < descList.length; i++) {
            // skip this description if the locatioin attribute is a malformed URL
            String location = descList[i].getLocation();
            if (location == null || location.length() <= 0)
                continue;
            // skip this description if the extension element indicates
            // that the description's location contains only the wsdl binding
            ExtensionElement extElement = descList[i].getExtensionElement();
            if (extElement != null && extElement instanceof Reference) {
                Boolean endpointPresent = ((Reference)extElement).getEndpointPresent();
                if (endpointPresent != null && endpointPresent.booleanValue() == false)
                    continue;
            }
            // a valid description is found
            return descList[i];
        }
        // no valid description is found for this service
        return null;
    }

    public boolean validateWSDLService() {
        Description desc = getValidWSDLDescription();
        return (desc != null);
    }

    public String toString() {
        return getWSDLServiceURL();
    }
}

Back to the top