Return-Path: Delivered-To: apmail-cxf-users-archive@www.apache.org Received: (qmail 51634 invoked from network); 1 Jul 2008 17:41:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Jul 2008 17:41:15 -0000 Received: (qmail 93662 invoked by uid 500); 1 Jul 2008 17:41:15 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 93618 invoked by uid 500); 1 Jul 2008 17:41:14 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 93607 invoked by uid 99); 1 Jul 2008 17:41:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Jul 2008 10:41:14 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [64.79.199.57] (HELO server.dankulp.com) (64.79.199.57) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Jul 2008 17:40:22 +0000 Received: by server.dankulp.com (Postfix, from userid 5000) id 89961197C007; Tue, 1 Jul 2008 13:40:42 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on server.dankulp.com X-Spam-Level: X-Msg-File: /tmp/mailfilter.gnzfIn6hjN Received: from [192.168.1.148] (c-24-147-10-180.hsd1.ma.comcast.net [24.147.10.180]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by server.dankulp.com (Postfix) with ESMTP id 26E08197C007 for ; Tue, 1 Jul 2008 13:40:41 -0400 (EDT) Message-Id: <80320DA5-0CA5-45AE-A638-2B5872C4BE79@apache.org> From: Daniel Kulp To: users@cxf.apache.org In-Reply-To: <486A69FB.9040202@duke.edu> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v926) Subject: Re: why does cxf-codegen-plugin v2.1/wsdl2java put hardcoded WSDL path into autogenerated service class? suggested fix? Date: Tue, 1 Jul 2008 13:40:39 -0400 References: <486A4EBF.8070608@duke.edu> <486A6693.8030808@duke.edu> <486A69FB.9040202@duke.edu> X-Mailer: Apple Mail (2.926) X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=0.3 required=3.0 tests=BAYES_00,RCVD_IN_PBL, RCVD_IN_SORBS_DUL,RDNS_DYNAMIC autolearn=no version=3.2.4 If the code is generated from a "correct" WSDL, then you don't really need the WSDL at all at runtime. You can specify a "null" URL for the wsdl in the constructor. The runtime will then use the annotations that the code generator added to the code for everything it needs. The exception to that is the actual URL that is hit. That is not recorded in the annotations. However, that's settable via standard JAX-WS API's: ((BindingProvider)portType).getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_URL, "https://blah/blah/blah"); Dan On Jul 1, 2008, at 1:31 PM, Gary Weaver wrote: > One sidenote and also a big thanks to Dan and Glen for their > comments!: > > Even though I'm just trying to get over this issue by specifying the > WSDL on the service and trying to get the call to get that WSDL to > deal with the non-matching CN on the certificate, I just want to > clarify that the heart of the issue is not really in CXF or its > wsdl2java, but that the service I'm dealing with stinks - the WSDL > it generates and hosts has a bad endpoint, has the wrong namespace > defined for the response (it doesn't match what comes back), and > I'm forced to use a hostname (cname) for the server that doesn't > match the server certificate. So far, CXF has helped me overcome all > of those issues when I test the client locally with a local WSDL. I > really wish that there would be some way to keep the client from > having to access the WSDL at all (since I've customized the WSDLs > for the services I'm integrating with by changing the response > namespace to match what comes back, and don't really feel the need > or responsibility to host the modified WSDLs on a webserver). But, > worst case, I can host the WSDL on a separate webserver if needed. > However, any ideas for having to avoid that would be appreciated. > > Thanks, > Gary > > > Gary Weaver wrote: >> Ok, it looks like you can override the WSDL in the constructor of >> the autogenerated service object, like: >> >> String wsdlUrl = "https://somehost:someport/path/to/the/wsdl/MyService.wsdl >> "; >> MyService service = new MyService(new URL(wsdlUrl)); >> >> However, that let me to a new problem: >> >> junit.framework.AssertionFailedError: error: >> javax.xml.ws.WebServiceException: >> org.apache.cxf.service.factory.ServiceConstructionException: Failed >> to create service. >> at org.apache.cxf.jaxws.ServiceImpl.(ServiceImpl.java: >> 134) >> at >> org >> .apache >> .cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java: >> 65) >> at javax.xml.ws.Service.(Service.java:56) >> at ... (autogenerated client code) >> at ... >> Caused by: >> org.apache.cxf.service.factory.ServiceConstructionException: Failed >> to create service. >> at >> org >> .apache >> .cxf.wsdl11.WSDLServiceFactory.(WSDLServiceFactory.java:83) >> at >> org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java: >> 140) >> at org.apache.cxf.jaxws.ServiceImpl.(ServiceImpl.java: >> 132) >> ... 31 more >> Caused by: javax.wsdl.WSDLException: WSDLException: >> faultCode=PARSER_ERROR: Problem parsing 'https://somehost:someport/path/to/the/wsdl/MyService.wsdl' >> .: java.io.IOException: HTTPS hostname wrong: should be >> >> at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source) >> at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) >> at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) >> at >> org >> .apache >> .cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:206) >> at >> org >> .apache >> .cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:170) >> at >> org >> .apache >> .cxf.wsdl11.WSDLServiceFactory.(WSDLServiceFactory.java:81) >> ... 33 more >> Caused by: java.io.IOException: HTTPS hostname wrong: should be >> >> at >> sun >> .net >> .www.protocol.https.HttpsClient.checkURLSpoofing(HttpsClient.java: >> 490) >> at >> sun >> .net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java: >> 415) >> at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect >> (AbstractDelegateHttpsURLConnection.java:166) >> at >> sun >> .net >> .www >> .protocol >> .http.HttpURLConnection.getInputStream(HttpURLConnection.java:934) >> at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream >> (HttpsURLConnectionImpl.java:234) >> at >> com >> .sun >> .org >> .apache >> .xerces >> .internal >> .impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:973) >> at >> com >> .sun >> .org >> .apache >> .xerces >> .internal >> .impl >> .XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:184) >> at >> com >> .sun >> .org >> .apache >> .xerces >> .internal.parsers.XML11Configuration.parse(XML11Configuration.java: >> 798) >> at >> com >> .sun >> .org >> .apache >> .xerces >> .internal.parsers.XML11Configuration.parse(XML11Configuration.java: >> 764) >> at >> com >> .sun >> .org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java: >> 148) >> at >> com >> .sun >> .org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java: >> 250) >> at >> com >> .sun >> .org >> .apache >> .xerces >> .internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java: >> 292) >> ... >> >> This error occurs when the wsdl URL's hostname does not match the >> Common Name (CN) on the server certificate. >> >> I'm already doing the following which combatted the issue >> previously when I was using a local WSDL file and wasn't having to >> use HTTPS to get access to it: >> >> Client client = ClientProxy.getClient(portType); >> HTTPConduit conduit = (HTTPConduit) client.getConduit(); >> HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); >> TLSClientParameters params = conduit.getTlsClientParameters(); >> if (params == null) { >> params = new TLSClientParameters(); >> conduit.setTlsClientParameters(params); >> } >> >> // NOTE! ONLY DO THIS FOR TESTING, NOT PRODUCTION! >> // this is to get around the error: >> // The https URL hostname does not match the Common Name (CN) >> on the server certificate. To disable this check (NOT recommended >> for production) set the CXF client TLS configuration property >> "disableCNCheck" to true. >> params.setDisableCNCheck(true); >> >> However, now that I'm accessing the WSDL via HTTPS, it would appear >> that there should be some mechanism to allow me to tell the client >> to not crap out (disable the CN check) for the get WSDL over HTTPS >> check in addition to the actual service usage call. >> >> Unfortunately I'm at a loss for how to do that. >> >> Thanks in advance for any help you can provide, >> >> Gary >> >> >> >> Gary Weaver wrote: >>> Hello again, >>> >>> Anyone know why the client code generated by cxf-codegen-plugin >>> v2.1 + JAXB is hardcoding the original WSDL file's path into the >>> client classes, and then looking for that file when the client is >>> used? >>> >>> Any idea how to keep it from doing that? >>> >>> For example, in one of the autogenerated client service classes it >>> has a static block that looks like: >>> >>> ... >>> static { >>> URL url = null; >>> try { >>> url = new URL("file:/path/to/my/project/trunk/src/main/ >>> wsdl/MyService.wsdl"); >>> } catch (MalformedURLException e) { >>> System.err.println("Can not initialize the default wsdl >>> from file:/path/to/my/project/trunk/src/main/wsdl/MyService.wsdl"); >>> // e.printStackTrace(); >>> } >>> WSDL_LOCATION = url; >>> } >>> ... >>> >>> And in the pom.xml looks like: >>> >>> ... >>> >>> org.apache.cxf >>> cxf-codegen-plugin >>> ${cxf.version} >>> >>> >>> checklist >>> generate-sources >>> >>> ${basedir}/target/generated/ >>> src/main/java >>> >>> >>> ${basedir}/src/main/wsdl/ >>> MyService.wsdl >>> >>> >>> >>> >>> wsdl2java >>> >>> >>> ... >>> >>> >>> ... >>> >>> >>> And the error that occurs when you run this in an environment >>> where that path/file (/path/to/my/project/trunk/src/main/wsdl/ >>> MyService.wsdl) doesn't exist is: >>> >>> javax.xml.ws.WebServiceException: >>> org.apache.cxf.service.factory.ServiceConstructionException: >>> Failed to create service. >>> at org.apache.cxf.jaxws.ServiceImpl.(ServiceImpl.java: >>> 134) >>> at >>> org >>> .apache >>> .cxf >>> .jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:65) >>> at javax.xml.ws.Service.(Service.java:56) >>> at ... (autogenerated client code) >>> at ... >>> Caused by: >>> org.apache.cxf.service.factory.ServiceConstructionException: >>> Failed to create service. >>> at >>> org >>> .apache >>> .cxf.wsdl11.WSDLServiceFactory.(WSDLServiceFactory.java:83) >>> at >>> org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java: >>> 140) >>> at org.apache.cxf.jaxws.ServiceImpl.(ServiceImpl.java: >>> 132) >>> ... >>> Caused by: javax.wsdl.WSDLException: WSDLException: >>> faultCode=PARSER_ERROR: Problem parsing 'file:/path/to/my/project/ >>> trunk/src/main/wsdl/MyService.wsdl'.: >>> java.io.FileNotFoundException: /path/to/my/project/trunk/src/main/ >>> wsdl/MyService.wsdl (No such file or directory) >>> at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source) >>> at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) >>> at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) >>> at >>> org >>> .apache >>> .cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:206) >>> at >>> org >>> .apache >>> .cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:170) >>> at >>> org >>> .apache >>> .cxf.wsdl11.WSDLServiceFactory.(WSDLServiceFactory.java:81) >>> ... >>> Caused by: java.io.FileNotFoundException: /path/to/my/wsdl/ >>> MyService.wsdl (No such file or directory) >>> at java.io.FileInputStream.open(Native Method) >>> at java.io.FileInputStream.(FileInputStream.java:106) >>> at java.io.FileInputStream.(FileInputStream.java:66) >>> at >>> sun >>> .net >>> .www >>> .protocol.file.FileURLConnection.connect(FileURLConnection.java:70) >>> at >>> sun >>> .net >>> .www >>> .protocol >>> .file.FileURLConnection.getInputStream(FileURLConnection.java:161) >>> at >>> org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown >>> Source) >>> at >>> org >>> .apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown >>> Source) >>> at >>> org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) >>> at >>> org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) >>> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) >>> at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) >>> at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown >>> Source) >>> ... >>> >>> Thanks in advance! >>> >>> Gary >>> >> >> > > > -- > Gary Weaver > Internet Framework Services > Office of Information Technology > Duke University > --- Daniel Kulp dkulp@apache.org http://www.dankulp.com/blog