blob: 97b207ecd91421205320f6ff2acba8e5b5750285 (
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
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/*******************************************************************************
* Copyright (c) 2002, 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.jst.ws.internal.consumption.wsfinder;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.wsdl.Definition;
import javax.wsdl.Port;
import javax.wsdl.Service;
import javax.wsdl.WSDLException;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.http.HTTPAddress;
import javax.wsdl.extensions.soap.SOAPAddress;
import org.eclipse.wst.ws.internal.parser.discovery.WebServicesParserExt;
import org.eclipse.wst.ws.internal.parser.wsil.WWWAuthenticationException;
public class LiveWSDLFilter extends Thread
{
private String wsdlURL_;
private boolean finish_;
private boolean live_;
public LiveWSDLFilter(String wsdlURL)
{
wsdlURL_ = wsdlURL;
finish_ = false;
live_ = false;
}
public String getWSDLURL()
{
return wsdlURL_;
}
public boolean isFinish()
{
return finish_;
}
public boolean isWSDLLive()
{
return live_;
}
public void run()
{
try
{
live_ = validateWSDL();
}
catch (Throwable t)
{
live_ = false;
}
finally
{
finish_ = true;
}
}
private boolean validateWSDL() throws WSDLException, MalformedURLException, IOException, WWWAuthenticationException
{
WebServicesParserExt parser = new WebServicesParserExt();
Definition definition = parser.getWSDLDefinitionVerbose(wsdlURL_);
Map services = definition.getServices();
Iterator serviceIterator = services.values().iterator();
while (serviceIterator.hasNext())
{
Service service = (Service)serviceIterator.next();
Map ports = service.getPorts();
Iterator portIterator = ports.values().iterator();
while (portIterator.hasNext())
{
Port port = (Port)portIterator.next();
List extensibilityElements = port.getExtensibilityElements();
Iterator extensibilityElementsIterator = extensibilityElements.iterator();
while (extensibilityElementsIterator.hasNext())
{
ExtensibilityElement extensibilityElement = (ExtensibilityElement)extensibilityElementsIterator.next();
if ((extensibilityElement instanceof SOAPAddress) || (extensibilityElement instanceof HTTPAddress))
return true;
}
}
}
return false;
}
}
|