diff options
author | kchan | 2007-01-24 22:16:39 +0000 |
---|---|---|
committer | kchan | 2007-01-24 22:16:39 +0000 |
commit | 76fff93b1dc01d4cb24c4b4e99ba7d67290911ff (patch) | |
tree | 3aca7515050509ac955c98d201e96e683c4aa38b | |
parent | a27691521e236eaf3717266c23130cb89f829e1c (diff) | |
download | webtools.webservices-76fff93b1dc01d4cb24c4b4e99ba7d67290911ff.tar.gz webtools.webservices-76fff93b1dc01d4cb24c4b4e99ba7d67290911ff.tar.xz webtools.webservices-76fff93b1dc01d4cb24c4b4e99ba7d67290911ff.zip |
[167487] Web Service Explorer doesn't resolve external xsd files imported by a WSDL file.
4 files changed, 93 insertions, 8 deletions
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/extension/PreClientDevelopCommand.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/extension/PreClientDevelopCommand.java index 65f13a243..8c03870bb 100644 --- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/extension/PreClientDevelopCommand.java +++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/extension/PreClientDevelopCommand.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. + * Copyright (c) 2005, 2007 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 @@ -13,6 +13,7 @@ * 20060221 119111 rsinha@ca.ibm.com - Rupam Kuehner * 20060516 126965 kathy@ca.ibm.com - Kathy Chan * 20060529 141422 kathy@ca.ibm.com - Kathy Chan + * 20070123 167487 makandre@ca.ibm.com - Andrew Mak *******************************************************************************/ package org.eclipse.jst.ws.internal.consumption.ui.extension; @@ -30,6 +31,7 @@ import org.eclipse.jst.ws.internal.data.TypeRuntimeServer; import org.eclipse.wst.command.internal.env.core.context.ResourceContext; import org.eclipse.wst.common.environment.IEnvironment; import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; +import org.eclipse.wst.ws.internal.common.HTTPUtility; import org.eclipse.wst.ws.internal.wsrt.IContext; import org.eclipse.wst.ws.internal.wsrt.ISelection; import org.eclipse.wst.ws.internal.wsrt.IWebService; @@ -95,7 +97,10 @@ public class PreClientDevelopCommand extends AbstractDataModelOperation wsInfo.setServerInstanceId(typeRuntimeServer_.getServerInstanceId()); wsInfo.setState(WebServiceState.UNKNOWN_LITERAL); wsInfo.setWebServiceRuntimeId(typeRuntimeServer_.getRuntimeId()); - wsInfo.setWsdlURL(wsdlURI_); + + // check for redirection in the wsdl + HTTPUtility httpUtil = new HTTPUtility(); + wsInfo.setWsdlURL(httpUtil.handleRedirect(wsdlURI_)); webServiceClient_ = wsrt.getWebServiceClient(wsInfo); WebServiceScenario scenario = WebServiceScenario.CLIENT_LITERAL; diff --git a/bundles/org.eclipse.jst.ws.creation.ui/src/org/eclipse/jst/ws/internal/creation/ui/extension/PreServiceDevelopCommand.java b/bundles/org.eclipse.jst.ws.creation.ui/src/org/eclipse/jst/ws/internal/creation/ui/extension/PreServiceDevelopCommand.java index 856e99c30..3cebfaf07 100644 --- a/bundles/org.eclipse.jst.ws.creation.ui/src/org/eclipse/jst/ws/internal/creation/ui/extension/PreServiceDevelopCommand.java +++ b/bundles/org.eclipse.jst.ws.creation.ui/src/org/eclipse/jst/ws/internal/creation/ui/extension/PreServiceDevelopCommand.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. + * Copyright (c) 2005, 2007 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 @@ -13,6 +13,7 @@ * 20060221 119111 rsinha@ca.ibm.com - Rupam Kuehner * 20060516 126965 kathy@ca.ibm.com - Kathy Chan * 20060529 141422 kathy@ca.ibm.com - Kathy Chan + * 20070123 167487 makandre@ca.ibm.com - Andrew Mak *******************************************************************************/ package org.eclipse.jst.ws.internal.creation.ui.extension; @@ -30,6 +31,7 @@ import org.eclipse.jst.ws.internal.data.TypeRuntimeServer; import org.eclipse.wst.command.internal.env.core.context.ResourceContext; import org.eclipse.wst.common.environment.IEnvironment; import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation; +import org.eclipse.wst.ws.internal.common.HTTPUtility; import org.eclipse.wst.ws.internal.wsrt.IContext; import org.eclipse.wst.ws.internal.wsrt.ISelection; import org.eclipse.wst.ws.internal.wsrt.IWebService; @@ -111,7 +113,10 @@ public class PreServiceDevelopCommand extends AbstractDataModelOperation { scenario = WebServiceScenario.TOPDOWN_LITERAL; String wsdlURL = (String)(selection_.getSelection())[0]; - wsInfo.setWsdlURL(wsdlURL); + + // check for redirection in the wsdl + HTTPUtility httpUtil = new HTTPUtility(); + wsInfo.setWsdlURL(httpUtil.handleRedirect(wsdlURL)); } context_ = new SimpleContext(develop_, assemble_, deploy_, install_, run_, client_, test_, publish_, diff --git a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLElement.java b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLElement.java index 320ec1800..7530a4371 100644 --- a/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLElement.java +++ b/bundles/org.eclipse.wst.ws.explorer/wsexplorer-src/org/eclipse/wst/ws/internal/explorer/platform/wsdl/datamodel/WSDLElement.java @@ -1,15 +1,16 @@ /******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. + * Copyright (c) 2004, 2007 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 * yyyymmdd bug Email and other contact information * -------- -------- ----------------------------------------------------------- * 20060717 146707 mahutch@ca.ibm.com - Mark Hutchinson + * 20070124 167487 gilberta@ca.ibm.com - Gilbert Andrews *******************************************************************************/ package org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel; @@ -38,6 +39,7 @@ import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.wst.common.uriresolver.internal.util.URIEncoder; +import org.eclipse.wst.ws.internal.common.HTTPUtility; import org.eclipse.wst.ws.internal.datamodel.Model; import org.eclipse.wst.ws.internal.explorer.platform.constants.ModelConstants; import org.eclipse.wst.ws.internal.explorer.platform.util.Validator; @@ -98,14 +100,15 @@ public class WSDLElement extends WSDLCommonElement public WSDLElement(String name, Model model, String wsdlUrl) { super(name, model); - wsdlUrl_ = wsdlUrl; + setWsdlUrl(wsdlUrl); definition_ = null; schemaList_ = new Vector(); schemaURI_ = new Vector(); } public void setWsdlUrl(String wsdlUrl) { - wsdlUrl_ = wsdlUrl; + HTTPUtility http = new HTTPUtility(); + wsdlUrl_ = http.handleRedirect(wsdlUrl); } public String getWsdlUrl() { @@ -151,6 +154,8 @@ public class WSDLElement extends WSDLCommonElement Vector errorMessages = new Vector(); definition_ = loadWSDL(wsdlUrl_); + + if (definition_ != null) { setDocumentation(definition_.getDocumentationElement()); diff --git a/bundles/org.eclipse.wst.ws/src/org/eclipse/wst/ws/internal/common/HTTPUtility.java b/bundles/org.eclipse.wst.ws/src/org/eclipse/wst/ws/internal/common/HTTPUtility.java new file mode 100644 index 000000000..1f5112ee9 --- /dev/null +++ b/bundles/org.eclipse.wst.ws/src/org/eclipse/wst/ws/internal/common/HTTPUtility.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2007 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 + * yyyymmdd bug Email and other contact information + * -------- -------- ----------------------------------------------------------- + * 20070124 167487 gilberta@ca.ibm.com - Gilbert Andrews + *******************************************************************************/ +package org.eclipse.wst.ws.internal.common; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; + +public class HTTPUtility { + + public String handleRedirect(String urlString){ + URLConnection conn = null; + String urlRedirect = urlString; + int time = 0; + while(urlRedirect!= null){ + if (time == 6) return urlRedirect; + try{ + URL url = new URL(urlRedirect); + conn = url.openConnection(); + }catch(Exception exc){ + return urlRedirect; + } + if (conn instanceof HttpURLConnection) + { + HttpURLConnection http = (HttpURLConnection) conn; + http.setInstanceFollowRedirects(false); + + try{ + int code = http.getResponseCode(); + if (code >= 300 && code <= 307 && code != 306 && + code != HttpURLConnection.HTTP_NOT_MODIFIED) + { + String urlRedirect2 = changeSlash(http.getHeaderField("Location")); + if (urlRedirect2 == null || urlRedirect.equals(urlRedirect2)) return urlRedirect; + else urlRedirect = urlRedirect2; + }else return urlRedirect; + + + }catch(IOException exc){ + return urlRedirect; + } + } + else return urlRedirect; + time++; + } + return urlString; + } + + public String changeSlash(String url){ + String temp = ""; + try{ + temp = url.replace('\\', '/'); + }catch(Exception exc){ + return url; + } + return temp; + } +} |