Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 88765 invoked from network); 12 Jun 2008 18:52:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Jun 2008 18:52:18 -0000 Received: (qmail 95704 invoked by uid 500); 12 Jun 2008 18:52:21 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 95580 invoked by uid 500); 12 Jun 2008 18:52:20 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 95571 invoked by uid 99); 12 Jun 2008 18:52:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jun 2008 11:52:20 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jun 2008 18:51:28 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 76E7A23889FA; Thu, 12 Jun 2008 11:51:46 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r667197 - in /cxf/trunk: common/schemas/src/main/resources/schemas/wsdl/ rt/core/src/main/java/org/apache/cxf/transport/http/ rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ systests/src/test/java/org/apache/cxf/... Date: Thu, 12 Jun 2008 18:51:46 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080612185146.76E7A23889FA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Thu Jun 12 11:51:45 2008 New Revision: 667197 URL: http://svn.apache.org/viewvc?rev=667197&view=rev Log: [CXF-1644] Return a real error message if the wsdl/schema isn't found in the maps instead of a NPE Modified: cxf/trunk/common/schemas/src/main/resources/schemas/wsdl/ws-addr-wsdl.xjb cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/QueryMessages.properties cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/PublishedEndpointUrlTest.java Modified: cxf/trunk/common/schemas/src/main/resources/schemas/wsdl/ws-addr-wsdl.xjb URL: http://svn.apache.org/viewvc/cxf/trunk/common/schemas/src/main/resources/schemas/wsdl/ws-addr-wsdl.xjb?rev=667197&r1=667196&r2=667197&view=diff ============================================================================== --- cxf/trunk/common/schemas/src/main/resources/schemas/wsdl/ws-addr-wsdl.xjb (original) +++ cxf/trunk/common/schemas/src/main/resources/schemas/wsdl/ws-addr-wsdl.xjb Thu Jun 12 11:51:45 2008 @@ -28,6 +28,6 @@ - + Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/QueryMessages.properties URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/QueryMessages.properties?rev=667197&r1=667196&r2=667197&view=diff ============================================================================== --- cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/QueryMessages.properties (original) +++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/QueryMessages.properties Thu Jun 12 11:51:45 2008 @@ -19,3 +19,5 @@ # # COULD_NOT_PROVIDE_WSDL = Exception occurred while trying to process {0} +WSDL_NOT_FOUND = Could not find wsdl {0} +SCHEMA_NOT_FOUND = Could not find xsd {0} Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java?rev=667197&r1=667196&r2=667197&view=diff ============================================================================== --- cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java (original) +++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java Thu Jun 12 11:51:45 2008 @@ -145,7 +145,12 @@ String wsdl2 = resolveWithCatalogs(OASISCatalogManager.getCatalogManager(bus), wsdl, base); - def = mp.get(wsdl2); + if (wsdl2 != null) { + def = mp.get(wsdl2); + } + } + if (def == null) { + throw new WSDLQueryException(new Message("WSDL_NOT_FOUND", LOG, wsdl), null); } synchronized (def) { @@ -168,7 +173,12 @@ String xsd2 = resolveWithCatalogs(OASISCatalogManager.getCatalogManager(bus), xsd, base); - si = smp.get(xsd2); + if (xsd2 != null) { + si = smp.get(xsd2); + } + } + if (si == null) { + throw new WSDLQueryException(new Message("SCHEMA_NOT_FOUND", LOG, wsdl), null); } String uri = si.getReferencedSchema().getDocumentBaseURI(); @@ -185,37 +195,7 @@ doc = XMLUtils.getParser().parse(src); } - NodeList nl = doc.getDocumentElement() - .getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", - "import"); - for (int x = 0; x < nl.getLength(); x++) { - Element el = (Element)nl.item(x); - String sl = el.getAttribute("schemaLocation"); - if (smp.containsKey(sl)) { - el.setAttribute("schemaLocation", base + "?xsd=" + sl); - } - } - nl = doc.getDocumentElement() - .getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", - "include"); - for (int x = 0; x < nl.getLength(); x++) { - Element el = (Element)nl.item(x); - String sl = el.getAttribute("schemaLocation"); - if (smp.containsKey(sl)) { - el.setAttribute("schemaLocation", base + "?xsd=" + sl); - } - } - nl = doc.getDocumentElement() - .getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/", - "import"); - for (int x = 0; x < nl.getLength(); x++) { - Element el = (Element)nl.item(x); - String sl = el.getAttribute("location"); - if (mp.containsKey(sl)) { - el.setAttribute("location", base + "?wsdl=" + sl); - } - } - doc.setXmlStandalone(true); + updateDoc(doc, base, mp, smp); String enc = doc.getXmlEncoding(); if (enc == null) { enc = "utf-8"; @@ -225,12 +205,50 @@ enc); StaxUtils.writeNode(doc, writer, true); writer.flush(); + } catch (WSDLQueryException wex) { + throw wex; } catch (Exception wex) { throw new WSDLQueryException(new Message("COULD_NOT_PROVIDE_WSDL", LOG, baseUri), wex); } } + + private void updateDoc(Document doc, String base, + Map mp, + Map smp) { + NodeList nl = doc.getDocumentElement() + .getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", + "import"); + for (int x = 0; x < nl.getLength(); x++) { + Element el = (Element)nl.item(x); + String sl = el.getAttribute("schemaLocation"); + if (smp.containsKey(sl)) { + el.setAttribute("schemaLocation", base + "?xsd=" + sl); + } + } + nl = doc.getDocumentElement() + .getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", + "include"); + for (int x = 0; x < nl.getLength(); x++) { + Element el = (Element)nl.item(x); + String sl = el.getAttribute("schemaLocation"); + if (smp.containsKey(sl)) { + el.setAttribute("schemaLocation", base + "?xsd=" + sl); + } + } + nl = doc.getDocumentElement() + .getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/", + "import"); + for (int x = 0; x < nl.getLength(); x++) { + Element el = (Element)nl.item(x); + String sl = el.getAttribute("location"); + if (mp.containsKey(sl)) { + el.setAttribute("location", base + "?wsdl=" + sl); + } + } + doc.setXmlStandalone(true); + } static String resolveWithCatalogs(OASISCatalogManager catalogs, String start, String base) { String resolvedSchemaLocation = null; Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?rev=667197&r1=667196&r2=667197&view=diff ============================================================================== --- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java (original) +++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java Thu Jun 12 11:51:45 2008 @@ -230,6 +230,11 @@ qh.writeResponse(requestURL, pathInfo, endpointInfo, resp.getOutputStream()); } catch (Exception ex) { LOG.log(Level.WARNING, "writeResponse failed: ", ex); + try { + resp.sendError(500, ex.getMessage()); + } catch (IOException ioe) { + //ignore + } } endpointInfo.setAddress(oldAddress); resp.getOutputStream().flush(); Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/PublishedEndpointUrlTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/PublishedEndpointUrlTest.java?rev=667197&r1=667196&r2=667197&view=diff ============================================================================== --- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/PublishedEndpointUrlTest.java (original) +++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/PublishedEndpointUrlTest.java Thu Jun 12 11:51:45 2008 @@ -18,6 +18,8 @@ */ package org.apache.cxf.systest.http; +import java.net.HttpURLConnection; +import java.net.URL; import java.util.Collection; import java.util.List; @@ -55,6 +57,11 @@ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); wsdlReader.setFeature("javax.wsdl.verbose", false); + + URL url = new URL(svrFactory.getAddress() + "?wsdl=1"); + HttpURLConnection connect = (HttpURLConnection)url.openConnection(); + assertEquals(500, connect.getResponseCode()); + Definition wsdl = wsdlReader.readWSDL(svrFactory.getAddress() + "?wsdl"); assertNotNull(wsdl);