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
diff options
context:
space:
mode:
authorcbrealey2004-11-16 22:09:41 +0000
committercbrealey2004-11-16 22:09:41 +0000
commit678d2af18829ac0fbabfddd4fc84560a7d9d957b (patch)
tree2e1fa0119b6bca294a60506f7655ef4a0babd491 /bundles/org.eclipse.wst.ws.parser/src
parentfd90b96e9c2c6a39a29d0223e9621f727ac1de0b (diff)
downloadwebtools.webservices-678d2af18829ac0fbabfddd4fc84560a7d9d957b.tar.gz
webtools.webservices-678d2af18829ac0fbabfddd4fc84560a7d9d957b.tar.xz
webtools.webservices-678d2af18829ac0fbabfddd4fc84560a7d9d957b.zip
Initial version.
Diffstat (limited to 'bundles/org.eclipse.wst.ws.parser/src')
-rw-r--r--bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/ParserPlugin.java65
-rw-r--r--bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/disco/DISCOContractReference.java28
-rw-r--r--bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/disco/DISCOParser.java123
-rw-r--r--bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/disco/DISCOReference.java27
-rw-r--r--bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/discovery/NetUtils.java151
-rw-r--r--bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/discovery/WebServicesParserExt.java40
-rw-r--r--bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/HTMLHeadHandler.java171
-rw-r--r--bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/IllegalArgumentsException.java20
-rw-r--r--bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/UDDIURIHelper.java63
-rw-r--r--bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WWWAuthenticationException.java44
-rw-r--r--bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WWWAuthenticationHandler.java19
-rw-r--r--bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WebServiceEntity.java148
-rw-r--r--bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WebServicesParser.java559
-rw-r--r--bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/wsil.properties22
14 files changed, 1480 insertions, 0 deletions
diff --git a/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/ParserPlugin.java b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/ParserPlugin.java
new file mode 100644
index 000000000..05db134cf
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/ParserPlugin.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 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.parser;
+
+import org.eclipse.core.runtime.*;
+import java.util.*;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class ParserPlugin extends Plugin {
+ //The shared instance.
+ private static ParserPlugin plugin;
+ //Resource bundle.
+ private ResourceBundle resourceBundle;
+
+ /**
+ * The constructor.
+ */
+ public ParserPlugin(IPluginDescriptor descriptor) {
+ super(descriptor);
+ plugin = this;
+ try {
+ resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.ws.parser.ParserPluginResources");
+ } catch (MissingResourceException x) {
+ resourceBundle = null;
+ }
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static ParserPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns the string from the plugin's resource bundle,
+ * or 'key' if not found.
+ */
+ public static String getResourceString(String key) {
+ ResourceBundle bundle = ParserPlugin.getDefault().getResourceBundle();
+ try {
+ return (bundle != null) ? bundle.getString(key) : key;
+ } catch (MissingResourceException e) {
+ return key;
+ }
+ }
+
+ /**
+ * Returns the plugin's resource bundle,
+ */
+ public ResourceBundle getResourceBundle() {
+ return resourceBundle;
+ }
+}
diff --git a/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/disco/DISCOContractReference.java b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/disco/DISCOContractReference.java
new file mode 100644
index 000000000..2e4b713ae
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/disco/DISCOContractReference.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 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.parser.disco;
+
+public class DISCOContractReference extends DISCOReference
+{
+ private String docRef_;
+
+ public DISCOContractReference(String ref,String docRef)
+ {
+ super(ref);
+ docRef_ = docRef;
+ }
+
+ public String getDocRef()
+ {
+ return docRef_;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/disco/DISCOParser.java b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/disco/DISCOParser.java
new file mode 100644
index 000000000..f5f3cb049
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/disco/DISCOParser.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 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.parser.disco;
+
+import java.util.Vector;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+/**
+ * See http://msdn.microsoft.com/msdnmag/issues/02/02/xml/default.aspx for more
+ * details on DISCO.
+ */
+public class DISCOParser
+{
+ private DocumentBuilder parser_;
+ private final String NS_DISCO = "http://schemas.xmlsoap.org/disco/";
+ private final String DISCOVERY = "discovery";
+ private final String DISCOVERY_REF = "discoveryRef";
+ private final String NS_CONTRACT_REF = "http://schemas.xmlsoap.org/disco/scl/";
+ private final String CONTRACT_REF = "contractRef";
+ private final String REF = "ref";
+ private final String DOC_REF = "docRef";
+
+ public DISCOParser()
+ {
+ try
+ {
+ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ docBuilderFactory.setNamespaceAware(true);
+ parser_ = docBuilderFactory.newDocumentBuilder();
+ }
+ catch (ParserConfigurationException pce)
+ {
+ parser_ = null;
+ }
+ }
+
+ public DISCOReference[] parse(String discoURI, InputSource source) throws Exception
+ {
+ if (parser_ != null)
+ {
+ Document doc = parser_.parse(source);
+ Element rootElement = doc.getDocumentElement();
+ // Root element must by <disco:discovery
+ // xmlns:disco="http://schemas.xmlsoap.org/disco/">
+ if (rootElement != null && rootElement.getNamespaceURI().equals(NS_DISCO) && rootElement.getLocalName().equals(DISCOVERY))
+ {
+ NodeList childNodes = rootElement.getChildNodes();
+ Vector discoReferences = new Vector();
+ for (int i = 0; i < childNodes.getLength(); i++)
+ {
+ Node childNode = childNodes.item(i);
+ if (childNode instanceof Element)
+ {
+ Element element = (Element)childNode;
+ String localName = element.getLocalName();
+ String nsURI = element.getNamespaceURI();
+ if (nsURI.equals(NS_DISCO) && localName.equals(DISCOVERY_REF))
+ {
+ // DISCO link.
+ String ref = convertToAbsoluteURI(discoURI, element.getAttribute(REF));
+ discoReferences.addElement(new DISCOReference(ref));
+ }
+ else if (nsURI.equals(NS_CONTRACT_REF) && localName.equals(CONTRACT_REF))
+ {
+ // WSDL link.
+ String ref = convertToAbsoluteURI(discoURI, element.getAttribute(REF));
+ String docRef = convertToAbsoluteURI(discoURI, element.getAttribute(DOC_REF));
+ discoReferences.addElement(new DISCOContractReference(ref, docRef));
+ }
+ }
+ }
+ int numberOfDISCOReferences = discoReferences.size();
+ if (numberOfDISCOReferences > 0)
+ {
+ DISCOReference[] references = new DISCOReference[numberOfDISCOReferences];
+ discoReferences.copyInto(references);
+ return references;
+ }
+ }
+ else
+ {
+ // The document is not a valid DISCO document.
+ throw new Exception();
+ }
+ }
+ return null;
+ }
+
+ private String convertToAbsoluteURI(String discoURI, String refURI)
+ {
+ if (refURI != null)
+ {
+ if (refURI.indexOf("://") > -1)
+ {
+ // refURI is already absolute.
+ return refURI;
+ }
+ else
+ {
+ StringBuffer absoluteURI = new StringBuffer(discoURI.substring(0, Math.max(discoURI.lastIndexOf('\\'), discoURI.lastIndexOf('/') + 1)));
+ absoluteURI.append(refURI);
+ return absoluteURI.toString();
+ }
+ }
+ return null;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/disco/DISCOReference.java b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/disco/DISCOReference.java
new file mode 100644
index 000000000..3c13bba1b
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/disco/DISCOReference.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 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.parser.disco;
+
+public class DISCOReference
+{
+ private String ref_;
+
+ public DISCOReference(String ref)
+ {
+ ref_ = ref;
+ }
+
+ public String getRef()
+ {
+ return ref_;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/discovery/NetUtils.java b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/discovery/NetUtils.java
new file mode 100644
index 000000000..41d3e3338
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/discovery/NetUtils.java
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 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.parser.discovery;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.Provider;
+import java.security.Security;
+
+import org.apache.soap.transport.http.SOAPHTTPConnection;
+
+import sun.misc.BASE64Encoder;
+
+import com.ibm.jsse.JSSEProvider;
+import com.ibm.net.ssl.internal.www.protocol.https.Handler;
+
+public final class NetUtils
+{
+ // Initialize the SSL provider subsystem.
+ static
+ {
+ Security.addProvider(new JSSEProvider());
+ System.setProperty("java.protocol.handler.pkgs","com.ibm.net.ssl.internal.www.protocol");
+ }
+
+ /**
+ * Get the java.net.URLConnection given a string representing the URL. This class ensures
+ * that proxy settings in WSAD are respected.
+ * @param urlString String representing the URL.
+ * @return java.net.URLCDonnection URLConnection to the URL.
+ */
+ public static final URLConnection getURLConnection(String urlString)
+ {
+ try
+ {
+ URL url = createURL(urlString);
+ URLConnection uc = url.openConnection();
+ String proxyUserName = System.getProperty("http.proxyUserName");
+ String proxyPassword = System.getProperty("http.proxyPassword");
+ if (proxyUserName != null && proxyPassword != null)
+ {
+ StringBuffer userNamePassword = new StringBuffer(proxyUserName);
+ userNamePassword.append(':').append(proxyPassword);
+ BASE64Encoder encoder = new BASE64Encoder();
+ String encoding = encoder.encode(userNamePassword.toString().getBytes());
+ userNamePassword.setLength(0);
+ userNamePassword.append("Basic ").append(encoding);
+ uc.setRequestProperty("Proxy-authorization",userNamePassword.toString());
+ }
+ return uc;
+ }
+ catch (MalformedURLException e)
+ {
+ }
+ catch (IOException e)
+ {
+ }
+ return null;
+ }
+
+ public static final void adjustSecurityProviderList()
+ {
+ // Ensure that the JSSE provider is first. This worksaround a WAS V502 issue where the IBMJSSEFIPS is added first.
+ Provider jsseProvider = Security.getProvider("JSSE");
+ Security.removeProvider("JSSE");
+ if (jsseProvider == null)
+ {
+ jsseProvider = new JSSEProvider();
+ System.setProperty("java.protocol.handler.pkgs","com.ibm.net.ssl.internal.www.protocol");
+ }
+ Security.insertProviderAt(jsseProvider,1);
+ }
+
+ /**
+ * Get the java.io.InputStream for a URL given a string representing the URL. This class
+ * ensures that proxy settings in WSAD are respected.
+ * @param urlString String representing the URL.
+ * @return java.io.InputStream InputStream for reading the URL stream.
+ */
+ public static final InputStream getURLInputStream(String urlString)
+ {
+ try
+ {
+ URLConnection uc = getURLConnection(urlString);
+ if (uc != null)
+ {
+ InputStream is = uc.getInputStream();
+ return is;
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ return null;
+ }
+
+ /**
+ * Create a org.apache.soap.transport.http.SOAPHTTPConnection that accounts for WSAD proxy
+ * information.
+ * @return SOAPHTTPConnection org.apache.soap.transport.http.SOAPHTTPConnection
+ */
+ public static final SOAPHTTPConnection createSOAPHTTPConnection()
+ {
+ SOAPHTTPConnection soapHttpConnection = new SOAPHTTPConnection();
+ String proxyHost = System.getProperty("http.proxyHost");
+ String proxyPort = System.getProperty("http.proxyPort");
+ String proxyUserName = System.getProperty("http.proxyUserName");
+ String proxyPassword = System.getProperty("http.proxyPassword");
+ if (proxyHost != null && proxyPort != null)
+ {
+ soapHttpConnection.setProxyHost(proxyHost);
+ soapHttpConnection.setProxyPort(Integer.parseInt(proxyPort));
+ }
+ if (proxyUserName != null)
+ soapHttpConnection.setProxyUserName(proxyUserName);
+ if (proxyPassword != null)
+ soapHttpConnection.setProxyPassword(proxyPassword);
+ return soapHttpConnection;
+ }
+
+ /**
+ * Create a URL from a string and provide an SSL handler if applicable.
+ * @param urlString String representing the URL.
+ * @return URL java.lang.URL representation of the URL.
+ * @throws MalformedURLException
+ */
+ public static final URL createURL(String urlString) throws MalformedURLException
+ {
+ URL url;
+ if (urlString.startsWith("https"))
+ {
+ adjustSecurityProviderList();
+ url = new URL(null,urlString,new Handler());
+ }
+ else
+ url = new URL(urlString);
+ return url;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/discovery/WebServicesParserExt.java b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/discovery/WebServicesParserExt.java
new file mode 100644
index 000000000..aad5a8bba
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/discovery/WebServicesParserExt.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 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.parser.discovery;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.Security;
+
+import org.eclipse.wst.ws.parser.wsil.WebServicesParser;
+
+import com.ibm.jsse.JSSEProvider;
+
+public class WebServicesParserExt extends WebServicesParser {
+ // Initialize the SSL provider subsystem.
+ static {
+ Security.addProvider(new JSSEProvider());
+ System.setProperty("java.protocol.handler.pkgs", "com.ibm.net.ssl.internal.www.protocol");
+ }
+
+ public WebServicesParserExt() {
+ super();
+ }
+
+ public WebServicesParserExt(String uri) {
+ super(uri);
+ }
+
+ protected URL createURL(String url) throws MalformedURLException {
+ return NetUtils.createURL(url);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/HTMLHeadHandler.java b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/HTMLHeadHandler.java
new file mode 100644
index 000000000..98ef2b974
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/HTMLHeadHandler.java
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 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.parser.wsil;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Vector;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class HTMLHeadHandler extends DefaultHandler
+{
+ private final char START_TAG = '<';
+ private final char END_TAG = '>';
+ private final String HEAD_START_TAG = "<head>";
+ private final String HEAD_END_TAG = "</head>";
+ private final String ROOT_START_TAG = "<root>";
+ private final String ROOT_END_TAG = "</root>";
+ private final String UTF8 = "UTF-8";
+
+ // WSIL tag information.
+ private final String META = "meta";
+ private final String NAME = "name";
+ private final String SERVICE_INSPECTION = "serviceInspection";
+ private final String CONTENT = "content";
+
+ // DISCO tag information.
+ private final String LINK = "link";
+ private final String TYPE = "type";
+ private final String TEXT_XML = "text/xml";
+ private final String REL = "rel";
+ private final String ALTERNATE = "alternate";
+ private final String HREF = "href";
+
+ private String baseURI_;
+ private Vector wsils_;
+ private Vector discos_;
+
+ public HTMLHeadHandler(String baseURI)
+ {
+ super();
+ baseURI_ = baseURI;
+ wsils_ = new Vector();
+ discos_ = new Vector();
+ }
+
+ public String[] getWsils()
+ {
+ String[] wsils = new String[wsils_.size()];
+ wsils_.copyInto(wsils);
+ return wsils;
+ }
+
+ public String[] getDiscos()
+ {
+ String[] discos = new String[discos_.size()];
+ discos_.copyInto(discos);
+ return discos;
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
+ {
+ String qNameLC = qName.toLowerCase();
+ if (qNameLC.equals(META))
+ {
+ String nameValue = attributes.getValue(NAME);
+ if (SERVICE_INSPECTION.equals(nameValue))
+ {
+ String wsilURI = attributes.getValue(CONTENT);
+ if (baseURI_ != null && wsilURI.indexOf(":/") == -1)
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append(baseURI_.substring(0, baseURI_.lastIndexOf("/")+1));
+ sb.append(wsilURI);
+ wsilURI = sb.toString();
+ }
+ if (!wsils_.contains(wsilURI))
+ wsils_.add(wsilURI);
+ }
+ }
+ else if (qNameLC.equals(LINK))
+ {
+ // See http://msdn.microsoft.com/msdnmag/issues/02/02/xml/default.aspx for more details on DISCO.
+ String type = attributes.getValue(TYPE);
+ String rel = attributes.getValue(REL);
+ String href = attributes.getValue(HREF);
+ if (TEXT_XML.equals(type) && ALTERNATE.equals(rel) && href != null)
+ {
+ String discoURI = href;
+ if (discoURI.indexOf(":/") == -1)
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append(baseURI_.substring(0,baseURI_.lastIndexOf("/")+1));
+ sb.append(discoURI);
+ discoURI = sb.toString();
+ }
+ if (!discos_.contains(discoURI))
+ discos_.add(discoURI);
+ }
+ }
+ }
+
+ public void error(SAXParseException e) throws SAXException
+ {
+ }
+
+ public void fatalError(SAXParseException e) throws SAXException
+ {
+ }
+
+ public void warning(SAXParseException e) throws SAXException
+ {
+ }
+
+ private void harvestTags(StringBuffer target,String document,String tag)
+ {
+ int index = document.indexOf(START_TAG);
+ int documentLength = document.length();
+ int tagLength = tag.length();
+ while (index != -1 && (index+1+tagLength)<documentLength)
+ {
+ String str = document.substring(index+1,index+1+tagLength);
+ if (str.toLowerCase().equals(tag))
+ {
+ str = document.substring(index,document.indexOf(END_TAG,index+1)+1);
+ target.append(str);
+ index += str.length();
+ }
+ else
+ index++;
+ index = document.indexOf(START_TAG,index);
+ }
+ }
+
+ public byte[] harvestHeadTags(byte[] b)
+ {
+ String s;
+ try
+ {
+ s = new String(b, UTF8);
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ s = new String(b);
+ }
+ String head = s.toLowerCase();
+ int headStartIndex = head.indexOf(HEAD_START_TAG);
+ int headEndIndex = head.indexOf(HEAD_END_TAG);
+ StringBuffer sb = new StringBuffer();
+ sb.append(ROOT_START_TAG);
+ if (headStartIndex != -1 && headEndIndex != -1)
+ {
+ head = s.substring(headStartIndex, headEndIndex+HEAD_END_TAG.length());
+ harvestTags(sb,head,META);
+ harvestTags(sb,head,LINK);
+ }
+ sb.append(ROOT_END_TAG);
+ return sb.toString().getBytes();
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/IllegalArgumentsException.java b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/IllegalArgumentsException.java
new file mode 100644
index 000000000..77788d83f
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/IllegalArgumentsException.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 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.parser.wsil;
+
+public class IllegalArgumentsException extends Exception
+{
+ public IllegalArgumentsException(String arg)
+ {
+ super(arg);
+ }
+}
diff --git a/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/UDDIURIHelper.java b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/UDDIURIHelper.java
new file mode 100644
index 000000000..05b21fd56
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/UDDIURIHelper.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 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.parser.wsil;
+
+import java.text.MessageFormat;
+import java.text.ParseException;
+
+public class UDDIURIHelper
+{
+ private static final String QUERYSERVICE_URI_TEMPLATE = "uddiservice:query:{0}:query:{1}";
+ private static final String SERVICEKEY_URI_TEMPLATE = "uddiservice:serviceKey:{0}:serviceKey:{1}";
+
+ public static final String getQueryServiceURI(String query,String inquiryURL)
+ {
+ String[] uriParams = {query,inquiryURL};
+ return MessageFormat.format(QUERYSERVICE_URI_TEMPLATE,uriParams);
+ }
+
+ public static final String getServiceKeyURI(String serviceKey,String inquiryURL)
+ {
+ String[] uriParams = {serviceKey,inquiryURL};
+ return MessageFormat.format(SERVICEKEY_URI_TEMPLATE,uriParams);
+ }
+
+ private static final String[] parseURI(String pattern,String uri)
+ {
+ try
+ {
+ MessageFormat mf = new MessageFormat(pattern);
+ Object[] parsedResults = mf.parse(uri);
+ if (parsedResults != null && parsedResults.length > 0)
+ {
+ String[] results = new String[parsedResults.length];
+ for (int i=0;i<parsedResults.length;i++)
+ results[i] = (String)parsedResults[i];
+ return results;
+ }
+ }
+ catch (ParseException e)
+ {
+ }
+ return null;
+ }
+
+ public static final String[] parseServiceKeyURI(String uri)
+ {
+ return parseURI(SERVICEKEY_URI_TEMPLATE,uri);
+ }
+
+ public static final String[] parseQueryServiceURI(String uri)
+ {
+ return parseURI(QUERYSERVICE_URI_TEMPLATE,uri);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WWWAuthenticationException.java b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WWWAuthenticationException.java
new file mode 100644
index 000000000..09fde2e51
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WWWAuthenticationException.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 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.parser.wsil;
+
+import java.io.IOException;
+
+public class WWWAuthenticationException extends Exception
+{
+ private IOException ioe_;
+ private String wwwAuthMsg_;
+ private String url_;
+
+ public WWWAuthenticationException(IOException ioe, String wwwAuthMsg, String url)
+ {
+ super(ioe.getMessage());
+ ioe_ = ioe;
+ wwwAuthMsg_ = wwwAuthMsg;
+ url_ = url;
+ }
+
+ public IOException getIOException()
+ {
+ return ioe_;
+ }
+
+ public String getWWWAuthenticationMsg()
+ {
+ return wwwAuthMsg_;
+ }
+
+ public String getURL()
+ {
+ return url_;
+ }
+}
diff --git a/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WWWAuthenticationHandler.java b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WWWAuthenticationHandler.java
new file mode 100644
index 000000000..86ddc42cd
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WWWAuthenticationHandler.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 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.parser.wsil;
+
+public interface WWWAuthenticationHandler
+{
+ public void handleWWWAuthentication(WWWAuthenticationException wwwae);
+ public String getUsername();
+ public String getPassword();
+}
diff --git a/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WebServiceEntity.java b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WebServiceEntity.java
new file mode 100644
index 000000000..776bd2aad
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WebServiceEntity.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 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.parser.wsil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class WebServiceEntity
+{
+ public static final int TYPE_UNKNOWN = -1;
+ public static final int TYPE_HTML = 0;
+ public static final int TYPE_WSIL = 1;
+ public static final int TYPE_WSDL = 2;
+ public static final int TYPE_UDDI_SERVICE = 3;
+ public static final int TYPE_DISCO = 4;
+
+ private Object parent_;
+ private List children_;
+ private int type_;
+ private String uri_;
+ private byte[] bytes_;
+ private String httpUsername_;
+ private String httpPassword_;
+ private String documentation_;
+ private Object model_;
+
+ public WebServiceEntity()
+ {
+ parent_ = null;
+ children_ = new ArrayList();
+ type_ = TYPE_UNKNOWN;
+ uri_ = null;
+ bytes_ = null;
+ httpUsername_ = null;
+ httpPassword_ = null;
+ documentation_ = null;
+ model_ = null;
+ }
+
+ public Object getParent()
+ {
+ return parent_;
+ }
+
+ public void setParent(Object parent)
+ {
+ parent_ = parent;
+ }
+
+ public List getChildren()
+ {
+ return children_;
+ }
+
+ public void addChild(Object child)
+ {
+ children_.add(child);
+ }
+
+ public void removeChild(Object child)
+ {
+ children_.remove(child);
+ }
+
+ public int getType()
+ {
+ return type_;
+ }
+
+ public void setType(int type)
+ {
+ type_ = type;
+ }
+
+ public String getURI()
+ {
+ return uri_;
+ }
+
+ public void setURI(String uri)
+ {
+ uri_ = uri;
+ }
+
+ public byte[] getBytes()
+ {
+ return bytes_;
+ }
+
+ public void setBytes(byte[] bytes)
+ {
+ bytes_ = bytes;
+ }
+
+ public String getHTTPUsername()
+ {
+ return httpUsername_;
+ }
+
+ public void setHTTPUsername(String httpUsername)
+ {
+ httpUsername_ = httpUsername;
+ }
+
+ public String getHTTPPassword()
+ {
+ return httpPassword_;
+ }
+
+ public void setHTTPPassword(String httpPassword)
+ {
+ httpPassword_ = httpPassword;
+ }
+
+ public String getDocumentation()
+ {
+ return documentation_;
+ }
+
+ public void setDocumentation(String documentation)
+ {
+ documentation_ = documentation;
+ }
+
+ public Object getModel()
+ {
+ return model_;
+ }
+
+ public void setModel(Object model)
+ {
+ model_ = model;
+ }
+
+ public boolean isEntityResolved()
+ {
+ return (bytes_ != null);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WebServicesParser.java b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WebServicesParser.java
new file mode 100644
index 000000000..cd0f440cf
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/WebServicesParser.java
@@ -0,0 +1,559 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 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.parser.wsil;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Hashtable;
+
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.wsil.Abstract;
+import org.apache.wsil.Description;
+import org.apache.wsil.Inspection;
+import org.apache.wsil.Link;
+import org.apache.wsil.Service;
+import org.apache.wsil.WSILConstants;
+import org.apache.wsil.WSILDocument;
+import org.apache.wsil.WSILException;
+import org.apache.wsil.extension.ExtensionElement;
+import org.apache.wsil.extension.uddi.ServiceDescription;
+import org.apache.wsil.extension.uddi.UDDIConstants;
+import org.apache.wsil.extension.wsdl.WSDLConstants;
+import org.eclipse.wst.ws.parser.disco.DISCOContractReference;
+import org.eclipse.wst.ws.parser.disco.DISCOParser;
+import org.eclipse.wst.ws.parser.disco.DISCOReference;
+import org.eclipse.wst.wsdl.WSDLPlugin;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import sun.misc.BASE64Encoder;
+
+public class WebServicesParser
+{
+ public static final int PARSE_NONE = 0;
+ public static final int PARSE_WSIL = 1<<0;
+ public static final int PARSE_WSDL = 1<<1;
+ public static final int PARSE_LINKS = 1<<2;
+ public static final int PARSE_DISCO = 1<<3;
+
+ private String uri_;
+ private Hashtable uriToEntityTable_;
+
+ private String httpBasicAuthUsername_;
+ private String httpBasicAuthPassword_;
+
+ public WebServicesParser()
+ {
+ this(null);
+ }
+
+ public WebServicesParser(String uri)
+ {
+ uri_ = uri;
+ uriToEntityTable_ = new Hashtable();
+ httpBasicAuthUsername_ = null;
+ httpBasicAuthPassword_ = null;
+ }
+
+ public String getURI()
+ {
+ return uri_;
+ }
+
+ public void setURI(String uri)
+ {
+ uri_ = uri;
+ }
+
+ public WebServiceEntity getWebServiceEntityByURI(String uri)
+ {
+ if (uri != null)
+ return (WebServiceEntity)uriToEntityTable_.get(uri);
+ else
+ return null;
+ }
+
+ public WSILDocument getWSILDocument(String wsilURI)
+ {
+ try
+ {
+ return getWSILDocumentVerbose(wsilURI);
+ }
+ catch (Throwable t)
+ {
+ }
+ return null;
+ }
+
+ public WSILDocument getWSILDocumentVerbose(String wsilURI) throws MalformedURLException, IOException, WWWAuthenticationException, WSILException
+ {
+ WebServiceEntity wsEntity = getWebServiceEntityByURI(wsilURI);
+ if (wsEntity == null)
+ {
+ wsEntity = new WebServiceEntity();
+ wsEntity.setURI(wsilURI);
+ uriToEntityTable_.put(wsilURI, wsEntity);
+ }
+ WSILDocument wsilDocument = (WSILDocument)wsEntity.getModel();
+ if (wsilDocument == null)
+ {
+ byte[] b = getInputStreamAsByteArray(wsilURI);
+ wsEntity.setBytes(b);
+ setHTTPSettings(wsEntity);
+ InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(b));
+ wsilDocument = WSILDocument.newInstance();
+ wsilDocument.read(isr);
+ wsEntity.setType(WebServiceEntity.TYPE_WSIL);
+ wsEntity.setModel(wsilDocument);
+ }
+ return wsilDocument;
+ }
+
+ public Definition getWSDLDefinition(String wsdlURI)
+ {
+ try
+ {
+ return getWSDLDefinitionVerbose(wsdlURI);
+ }
+ catch (Throwable t)
+ {
+ }
+ return null;
+ }
+
+ public Definition getWSDLDefinitionVerbose(String wsdlURI) throws MalformedURLException, IOException, WWWAuthenticationException, WSDLException
+ {
+ WebServiceEntity wsEntity = getWebServiceEntityByURI(wsdlURI);
+ if (wsEntity == null)
+ {
+ wsEntity = new WebServiceEntity();
+ wsEntity.setURI(wsdlURI);
+ uriToEntityTable_.put(wsdlURI, wsEntity);
+ }
+ Definition definition = (Definition)wsEntity.getModel();
+ if (definition == null)
+ {
+ byte[] b = getInputStreamAsByteArray(wsdlURI);
+ wsEntity.setBytes(b);
+ setHTTPSettings(wsEntity);
+ ByteArrayInputStream bais = new ByteArrayInputStream(b);
+ WSDLFactory factory = WSDLPlugin.INSTANCE.createWSDL4JFactory();
+ WSDLReader wsdlReader = factory.newWSDLReader();
+ definition = wsdlReader.readWSDL(wsdlURI, new InputSource(bais));
+ wsEntity.setType(WebServiceEntity.TYPE_WSDL);
+ wsEntity.setModel(definition);
+ }
+ return definition;
+ }
+
+ public void parse() throws MalformedURLException, IOException, ParserConfigurationException, SAXException, WWWAuthenticationException
+ {
+ parseURL(PARSE_WSIL | PARSE_WSDL | PARSE_LINKS | PARSE_DISCO);
+ }
+
+ public void parse(int parseOption) throws MalformedURLException, IOException, ParserConfigurationException, SAXException, WWWAuthenticationException
+ {
+ parseURL(parseOption);
+ }
+
+ private void parseURL(int parseOption) throws MalformedURLException, IOException, ParserConfigurationException, SAXException, WWWAuthenticationException
+ {
+ WebServiceEntity wsEntity = new WebServiceEntity();
+ wsEntity.setURI(uri_);
+ byte[] b = getInputStreamAsByteArray(uri_);
+ wsEntity.setBytes(b);
+ setHTTPSettings(wsEntity);
+ uriToEntityTable_.put(uri_, wsEntity);
+ // parse uri_ as a HTML document
+ HTMLHeadHandler headHandler = new HTMLHeadHandler(uri_);
+ byte[] head = headHandler.harvestHeadTags(b);
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(false);
+ factory.setValidating(false);
+ SAXParser parser = factory.newSAXParser();
+ try
+ {
+ parser.parse(new ByteArrayInputStream(head), headHandler);
+ }
+ catch (Throwable t)
+ {
+ }
+ String[] wsilURIs = headHandler.getWsils();
+ String[] discoURIs = headHandler.getDiscos();
+ // true if uri_ is a HTML document
+ if (wsilURIs.length > 0 || discoURIs.length > 0)
+ {
+ wsEntity.setType(WebServiceEntity.TYPE_HTML);
+ for (int i = 0; i < wsilURIs.length; i++)
+ {
+ String absoluteURI = convertToAbsoluteURI(uri_, wsilURIs[i]);
+ WebServiceEntity wsilEntity = new WebServiceEntity();
+ wsilEntity.setType(WebServiceEntity.TYPE_WSIL);
+ wsilEntity.setURI(absoluteURI);
+ associate(wsEntity, wsilEntity);
+ uriToEntityTable_.put(absoluteURI, wsilEntity);
+ if ((parseOption | PARSE_WSIL) == parseOption)
+ {
+ try
+ {
+ parseWSIL(absoluteURI, parseOption);
+ }
+ catch (Throwable t)
+ {
+ }
+ }
+ }
+ for (int i=0;i<discoURIs.length;i++)
+ {
+ WebServiceEntity discoEntity = new WebServiceEntity();
+ discoEntity.setType(WebServiceEntity.TYPE_DISCO);
+ discoEntity.setURI(discoURIs[i]);
+ associate(wsEntity,discoEntity);
+ uriToEntityTable_.put(discoURIs[i],discoEntity);
+ if ((parseOption | PARSE_DISCO) == parseOption)
+ {
+ try
+ {
+ parseDISCO(discoURIs[i],parseOption);
+ }
+ catch (Throwable t)
+ {
+ }
+ }
+ }
+ }
+ // false if uri_ is not a HTML document
+ // then parse uri_ as a WSIL document
+ else
+ {
+ try
+ {
+ parseWSIL(uri_, parseOption);
+ // no exception thrown if uri_ is a WSIL document
+ wsEntity.setType(WebServiceEntity.TYPE_WSIL);
+ }
+ catch (Throwable t)
+ {
+ // exception thrown if uri_ is not a WSIL document
+ // then parse uri_ as a DISCO document.
+ try
+ {
+ parseDISCO(uri_, parseOption);
+ // no exception thrown if uri_ is a DISCO document
+ wsEntity.setType(WebServiceEntity.TYPE_DISCO);
+ }
+ catch (Throwable t2)
+ {
+ // exception thrown if uri_ is not a DISCO document
+ // then parse uri_ as a WSDL document
+ try
+ {
+ parseWSDL(uri_);
+ // no exception thrown if uri_ is a WSDL document
+ wsEntity.setType(WebServiceEntity.TYPE_WSDL);
+ }
+ catch (Throwable t3)
+ {
+ // exception thrown if uri_ is not a WSDL document
+ // then do nothing
+ }
+ }
+ }
+ }
+ }
+
+ private void parseWSIL(String wsilURI, int parseOption) throws WSILException, MalformedURLException, IOException, WSDLException, WWWAuthenticationException
+ {
+ WebServiceEntity wsilEntity = getWebServiceEntityByURI(wsilURI);
+ WSILDocument wsilDoc = (WSILDocument)wsilEntity.getModel();
+ if (wsilDoc != null)
+ {
+ // Prevent infinite loops from occurring when a WSIL cycles occur.
+ return;
+ }
+ wsilDoc = getWSILDocumentVerbose(wsilURI);
+ Inspection inspection = wsilDoc.getInspection();
+ Service[] services = inspection.getServices();
+ for (int i = 0; i < services.length; i++)
+ {
+ Description[] descs = services[i].getDescriptions();
+ // Set the documentation to the <service> element's first abstract.
+ String documentation = null;
+ Abstract[] abstracts = services[i].getAbstracts();
+ if (abstracts != null && abstracts.length > 0)
+ documentation = abstracts[0].getText();
+ for (int j = 0; j < descs.length; j++)
+ {
+ String referencedNS = descs[j].getReferencedNamespace();
+ // If a <description> element contains an abstract, use it to override the service documentation.
+ abstracts = descs[j].getAbstracts();
+ if (abstracts != null && abstracts.length > 0)
+ documentation = abstracts[0].getText();
+ if (WSDLConstants.NS_URI_WSDL.equals(referencedNS))
+ {
+ String location = descs[j].getLocation();
+ if (location != null && location.length() > 0)
+ {
+ String absoluteURI = convertToAbsoluteURI(wsilURI, location);
+ WebServiceEntity wsdlEntity = new WebServiceEntity();
+ wsdlEntity.setType(WebServiceEntity.TYPE_WSDL);
+ wsdlEntity.setURI(absoluteURI);
+ wsdlEntity.setDocumentation(documentation);
+ associate(wsilEntity, wsdlEntity);
+ uriToEntityTable_.put(absoluteURI, wsdlEntity);
+ if ((parseOption | PARSE_WSDL) == parseOption)
+ parseWSDL(absoluteURI);
+ }
+ }
+ else if (UDDIConstants.NS_URI_UDDI_V2.equals(referencedNS))
+ {
+ ExtensionElement ee = descs[j].getExtensionElement();
+ if (ee instanceof ServiceDescription)
+ {
+ ServiceDescription sd = (ServiceDescription)ee;
+ String inquiryURL = sd.getLocation();
+ String serviceKey = sd.getServiceKey().getText();
+ WebServiceEntity uddiServiceEntity = new WebServiceEntity();
+ uddiServiceEntity.setType(WebServiceEntity.TYPE_UDDI_SERVICE);
+ String uddiServiceKeyURI = UDDIURIHelper.getServiceKeyURI(serviceKey,inquiryURL);
+ uddiServiceEntity.setURI(uddiServiceKeyURI);
+ uddiServiceEntity.setDocumentation(documentation);
+ associate(wsilEntity,uddiServiceEntity);
+ uriToEntityTable_.put(uddiServiceKeyURI,uddiServiceEntity);
+ // TODO: parse WSDL if necessary...
+ }
+ }
+ }
+ }
+ Link[] links = inspection.getLinks();
+ for (int i = 0; i < links.length; i++)
+ {
+ if (WSILConstants.NS_URI_WSIL.equals(links[i].getReferencedNamespace()))
+ {
+ String documentation = null;
+ Abstract[] abstracts = links[i].getAbstracts();
+ if (abstracts != null && abstracts.length > 0)
+ documentation = abstracts[0].getText();
+ String linkLocation = links[i].getLocation();
+ String absoluteURI = convertToAbsoluteURI(wsilURI, linkLocation);
+ // Prevent cycles.
+ WebServiceEntity wsilLinkEntity = getWebServiceEntityByURI(absoluteURI);
+ if (wsilLinkEntity == null)
+ {
+ wsilLinkEntity = new WebServiceEntity();
+ wsilLinkEntity.setType(WebServiceEntity.TYPE_WSIL);
+ wsilLinkEntity.setURI(absoluteURI);
+ wsilLinkEntity.setDocumentation(documentation);
+ uriToEntityTable_.put(absoluteURI, wsilLinkEntity);
+ if ((parseOption | PARSE_LINKS) == parseOption)
+ parseWSIL(absoluteURI, parseOption);
+ }
+ associate(wsilEntity,wsilLinkEntity);
+ }
+ }
+ }
+
+ private void parseDISCO(String discoURI, int parseOption) throws MalformedURLException, WWWAuthenticationException, Exception
+ {
+ WebServiceEntity discoEntity = getWebServiceEntityByURI(discoURI);
+ byte[] b = getInputStreamAsByteArray(discoURI);
+ discoEntity.setBytes(b);
+ setHTTPSettings(discoEntity);
+ ByteArrayInputStream bais = new ByteArrayInputStream(b);
+ DISCOParser parser = new DISCOParser();
+ DISCOReference[] references = parser.parse(discoURI,new InputSource(bais));
+ if (references != null && references.length > 0)
+ {
+ for (int i=0;i<references.length;i++)
+ {
+ if (references[i] instanceof DISCOContractReference)
+ {
+ // contractRef
+ DISCOContractReference reference = (DISCOContractReference)references[i];
+ String ref = reference.getRef();
+ String docRef = reference.getDocRef();
+ WebServiceEntity wsdlEntity = new WebServiceEntity();
+ wsdlEntity.setType(WebServiceEntity.TYPE_WSDL);
+ wsdlEntity.setURI(ref);
+ wsdlEntity.setDocumentation(docRef);
+ associate(discoEntity,wsdlEntity);
+ uriToEntityTable_.put(ref,wsdlEntity);
+ if ((parseOption | PARSE_WSDL) == parseOption)
+ parseWSDL(ref);
+ }
+ else
+ {
+ // discoveryRef
+ String ref = references[i].getRef();
+ // Prevent cycles.
+ WebServiceEntity discoLinkEntity = getWebServiceEntityByURI(ref);
+ if (discoLinkEntity == null)
+ {
+ discoLinkEntity = new WebServiceEntity();
+ discoLinkEntity.setType(WebServiceEntity.TYPE_DISCO);
+ discoLinkEntity.setURI(ref);
+ uriToEntityTable_.put(ref,discoLinkEntity);
+ if ((parseOption | PARSE_LINKS) == parseOption)
+ parseDISCO(ref,parseOption);
+ }
+ associate(discoEntity,discoLinkEntity);
+ }
+ }
+ }
+ }
+
+ private Definition parseWSDL(String wsdlURI) throws WSDLException, MalformedURLException, IOException, WWWAuthenticationException
+ {
+ return getWSDLDefinitionVerbose(wsdlURI);
+ }
+
+ private byte[] getInputStreamAsByteArray(String uriString) throws MalformedURLException, IOException, WWWAuthenticationException
+ {
+ // Try to get a cached copy of the byte[]
+ WebServiceEntity wsEntity = getWebServiceEntityByURI(uriString);
+ if (wsEntity != null)
+ {
+ byte[] bytes = wsEntity.getBytes();
+ if (bytes != null)
+ return bytes;
+ }
+ // Get the byte[] by opening a stream to the URI
+ URL url = createURL(uriString);
+ URLConnection conn = url.openConnection();
+ // proxy server setting
+ String proxyUserName = System.getProperty("http.proxyUserName");
+ String proxyPassword = System.getProperty("http.proxyPassword");
+ if (proxyUserName != null && proxyPassword != null)
+ {
+ StringBuffer userNamePassword = new StringBuffer(proxyUserName);
+ userNamePassword.append(':').append(proxyPassword);
+ BASE64Encoder encoder = new BASE64Encoder();
+ String encoding = encoder.encode(userNamePassword.toString().getBytes());
+ userNamePassword.setLength(0);
+ userNamePassword.append("Basic ").append(encoding);
+ conn.setRequestProperty("Proxy-authorization", userNamePassword.toString());
+ }
+ // HTTP basic authentication setting
+ if (httpBasicAuthUsername_ != null && httpBasicAuthPassword_ != null)
+ {
+ StringBuffer sb = new StringBuffer(httpBasicAuthUsername_);
+ sb.append(':').append(httpBasicAuthPassword_);
+ BASE64Encoder encoder = new BASE64Encoder();
+ String encoding = encoder.encode(sb.toString().getBytes());
+ sb.setLength(0);
+ sb.append("Basic ").append(encoding);
+ conn.setRequestProperty("Authorization", sb.toString());
+ }
+ InputStream is = null;
+ try
+ {
+ is = conn.getInputStream();
+ String wwwAuthMsg = conn.getHeaderField("WWW-Authenticate");
+ if (wwwAuthMsg != null)
+ throw new WWWAuthenticationException(new IOException(), wwwAuthMsg, uriString);
+ }
+ catch (IOException ioe)
+ {
+ String wwwAuthMsg = conn.getHeaderField("WWW-Authenticate");
+ if (wwwAuthMsg != null)
+ throw new WWWAuthenticationException(ioe, wwwAuthMsg, uriString);
+ else
+ throw ioe;
+ }
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ byte[] b = new byte[1024];
+ int byteRead = is.read(b);
+ while (byteRead != -1)
+ {
+ baos.write(b, 0, byteRead);
+ byteRead = is.read(b);
+ }
+ is.close();
+ return baos.toByteArray();
+ }
+
+ protected URL createURL(String url) throws MalformedURLException
+ {
+ return new URL(url);
+ }
+
+ private byte[] getBytes(WebServiceEntity wsEntity) throws MalformedURLException, IOException, WWWAuthenticationException
+ {
+ byte[] b = wsEntity.getBytes();
+ if (b == null)
+ {
+ b = getInputStreamAsByteArray(wsEntity.getURI());
+ wsEntity.setBytes(b);
+ setHTTPSettings(wsEntity);
+ }
+ return b;
+ }
+
+ private void associate(WebServiceEntity parent, WebServiceEntity child)
+ {
+ parent.addChild(child);
+ child.setParent(parent);
+ }
+
+ private String convertToAbsoluteURI(String baseURI,String refURI)
+ {
+ if (refURI != null && refURI.indexOf(":") < 0)
+ {
+ StringBuffer absoluteURI = new StringBuffer(baseURI.substring(0,Math.max(baseURI.lastIndexOf('\\'),baseURI.lastIndexOf('/')+1)));
+ absoluteURI.append(refURI);
+ return absoluteURI.toString();
+ }
+ return refURI;
+ }
+
+ private void setHTTPSettings(WebServiceEntity entity)
+ {
+ if (httpBasicAuthUsername_ != null && httpBasicAuthPassword_ != null)
+ {
+ entity.setHTTPUsername(httpBasicAuthUsername_);
+ entity.setHTTPPassword(httpBasicAuthPassword_);
+ }
+ }
+
+ public String getHTTPBasicAuthUsername()
+ {
+ return httpBasicAuthUsername_;
+ }
+
+ public void setHTTPBasicAuthUsername(String username)
+ {
+ httpBasicAuthUsername_ = username;
+ }
+
+ public String getHTTPBasicAuthPassword()
+ {
+ return httpBasicAuthPassword_;
+ }
+
+ public void setHTTPBasicAuthPassword(String password)
+ {
+ httpBasicAuthPassword_ = password;
+ }
+}
diff --git a/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/wsil.properties b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/wsil.properties
new file mode 100644
index 000000000..1e60c01ba
--- /dev/null
+++ b/bundles/org.eclipse.wst.ws.parser/src/org/eclipse/wst/ws/parser/wsil/wsil.properties
@@ -0,0 +1,22 @@
+###############################################################################
+# Copyright (c) 2001,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
+###############################################################################
+
+#
+# Messages for AddWSDLToWSILCommand
+#
+MSG_ERROR_INVALID_ARGUMENTS=IWAB0055E Invalid command arguments.
+MSG_ERROR_ILLEGAL_ARGUMENTS=IWAB0105E Illegal argument.
+MSG_ERROR_INVALID_WSDL_URI=IWAB0185E Invalid WSDL URI.
+MSG_ERROR_INVALID_WSIL_URI=IWAB0206E Invalid WSIL URI.
+MSG_ERROR_UNRESOLVABLE_WSDL=IWAB0405E WSDL is unresolvable.
+MSG_ERROR_UNEXPECTED_EXCEPTION=IWAB0451E An unexpected exception has occured.
+MSG_ERROR_MALFORMED_WSDL=IWAB0452E WSDL is malformed, error parsing WSDL.
+MSG_ERROR_WRITE_WSIL=IWAB0453E Error writing WSIL.

Back to the top