Return-Path: X-Original-To: apmail-cxf-users-archive@www.apache.org Delivered-To: apmail-cxf-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 98C914D87 for ; Fri, 13 May 2011 18:28:23 +0000 (UTC) Received: (qmail 16035 invoked by uid 500); 13 May 2011 18:28:22 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 15974 invoked by uid 500); 13 May 2011 18:28:22 -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 15966 invoked by uid 99); 13 May 2011 18:28:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 May 2011 18:28:22 +0000 X-ASF-Spam-Status: No, hits=2.8 required=5.0 tests=FREEMAIL_FROM,HK_RANDOM_ENVFROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RFC_ABUSE_POST,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [98.139.213.138] (HELO nm18-vm0.bullet.mail.bf1.yahoo.com) (98.139.213.138) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 13 May 2011 18:28:15 +0000 Received: from [98.139.212.150] by nm18.bullet.mail.bf1.yahoo.com with NNFMP; 13 May 2011 18:27:54 -0000 Received: from [98.139.212.234] by tm7.bullet.mail.bf1.yahoo.com with NNFMP; 13 May 2011 18:27:54 -0000 Received: from [127.0.0.1] by omp1043.mail.bf1.yahoo.com with NNFMP; 13 May 2011 18:27:54 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 604501.11602.bm@omp1043.mail.bf1.yahoo.com Received: (qmail 7272 invoked by uid 60001); 13 May 2011 18:27:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1305311274; bh=2SxpG1g8M/vhpfNZAS7kd57PON/imA4udQSs5nXIPcA=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=HbjpirWl1OBjEsi/lo+rPxAyOGvjl/woGSzI38hhbI2ywK2/N5F5ofd+OcOIvnGtyvfXmNmN9TzqKO2zuD2GVbqjHfb3TIVmh6OpOq/7YhYOAwTS9oA5I1xOriot4MgXMPpL8U0G54zaUOvWuFUGS6EKRRz/7/IxqzDwNKYXFRU= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=D5ZB6WRl1A19iyy81Tns/MJdwUod/ZvhMAyUFxtgyROLhggPsmgUp9aSblFWjDlNg83vAvE2BYWUF7iwSwOzvquFwStm2kAEkN6RXpHM6o4dr52IvCfNzsrFunftD1u96KGjcmmkqpNLotGJj5xoRnaLLPTa/iA6KvV/zd/mv5o=; Message-ID: <419402.87516.qm@web161809.mail.bf1.yahoo.com> X-YMail-OSG: TB7tHZgVM1mX_wFr4Y5j9N1f0YUMBu0xaAtPtd1P7_i_nR. n0MAhuaNfpYabneEI_Jo2uVnoCw2qWppr8yIURokRwef5_1_TKIpKuHzTxru GEGOEtFyth1CIzjRiO8SFFM8t.9xss4ybkFHZ9aohqbhzF0NT3qcgTG6yFK2 R.nPE8GsdeDoBgtICbH29d0LqpjVNRxjDKSlsh.65uKhYRoPBH5JsN8zR3iE dcmWtSM2M3DZiliwvXkdTrE.DukEWYBWecBdpTb9W0b_5BfDduFMlFKNlhT6 y9T8V1tBJoCB8Qwcc4BiTmmU_P01gH2NVxu0NwoEHJb4XBEwvqQ3Ar9UwNET IP2AH.350awsnVaXmwpStt5CuUcTNEBCvWGyzr2tTOnWz0DHP7tXZS6DARs2 kMhcZPDNj8c50F5pAeaGOM7TfAYpfhiFkutWe3ATHupoqefLHorklvruS04g WDCPEhfTv.rcnndsvJle4i6ZIuzXwu3RxdX4iSmQpRs6I1wgbbsCCNg3fszH gPF.TbVP0PeoBEWMT7p_.1clAz24jYoyVjx9pmsYUfRrU3lKA_mkfA9juMv8 SxxzHzh6XN6o27Sq4CeVj.O7dRH9R8ih2ebQG24cnMp0- Received: from [173.8.68.30] by web161809.mail.bf1.yahoo.com via HTTP; Fri, 13 May 2011 11:27:54 PDT X-Mailer: YahooMailWebService/0.8.111.303096 References: <336777.89685.qm@web161807.mail.bf1.yahoo.com> <176BAC3A-0773-4392-9291-A364895EABC6@gmail.com> Date: Fri, 13 May 2011 11:27:54 -0700 (PDT) From: Kevin McClusky Reply-To: Kevin McClusky Subject: Re: Two questions To: "users@cxf.apache.org" , Freeman Fang In-Reply-To: <176BAC3A-0773-4392-9291-A364895EABC6@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1806619037-1305311274=:87516" --0-1806619037-1305311274=:87516 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi,=0A=C2=A0=C2=A0 Thanks for the responses.=0A=0A=C2=A0=C2=A0 For #2, how = would I go about finding what the resulting class of the client.invoke will= be at runtime?=C2=A0 (Looking to find it using programming instead of gene= rating a code stub and manually looking through it.)=0A=0AThanks,=0AKevin= =0A=0A=0A=0A________________________________=0AFrom: Freeman Fang =0ATo: users@cxf.apache.org=0ASent: Thursday, May 12, 2011 1= 0:24 PM=0ASubject: Re: Two questions=0A=0AHi,=0A=0AMy comment inline=0AOn 2= 011-5-13, at =E4=B8=8A=E5=8D=889:47, Kevin McClusky wrote:=0A=0A> 1) After = a dynamic client is created using a WSDL (with JaxWsDynamicClientFactory), = how do I change the URL that it's using for the web service?=0Aclient.getCo= nduit().getTarget().getAddress().setValue("http://new_url_you_want");=0A> = =0A> 2) client.invoke() is giving me back a different class than getTypeCla= ss() is giving me.=C2=A0 How do I make these match?=0A> =0AgetTypeClass() w= ill return wrapped type which is useful for jaxb to do marshall/unmarshall,= but the expected result here for client.invoke is the String, you can use = the wsdl2java tool to generate code stub from that wsdl which you can find = out the correct signature for that method.=0A=0AFreeman=0A> =0A> =0A> My co= de for #2 follows.=0A> =0A> =0A>=C2=A0 =C2=A0 public static void main(Stri= ng[] args) throws Exception {=0A> =0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 String w= sdlUrl =3D "http://www.webservicex.net/stockquote.asmx?WSDL";=0A> =0A>=C2= =A0 =C2=A0 =C2=A0 =C2=A0 // Select the WSI-BP compliant port=0A>=C2=A0 =C2= =A0 =C2=A0 =C2=A0 ServiceInfo serviceInfo =3D getServices(wsdlUrl).get(1);= =0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 QName service =3D serviceInfo.getName();= =0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 QName port=C2=A0 =C2=A0 =3D serviceInfo.ge= tBindings().iterator().next().getName();=0A> =0A>=C2=A0 =C2=A0 =C2=A0 =C2= =A0 // Create the client=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ClientImpl client= =3D (ClientImpl)JaxWsDynamicClientFactory.newInstance().createClient(wsdlU= rl, service, port);=0A> =0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 // Get the Class f= or the only input message part=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 Class inputC= lass =3D client.getEndpoint().getEndpointInfo().getBinding().getOperations(= ).iterator().next().getOperationInfo().getInput().getMessageParts().get(0).= getTypeClass();=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 System.out.println("Class: = "+inputClass);=0A> =0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 // Get the Class for th= e only output message part=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 Class outputClas= s =3D client.getEndpoint().getEndpointInfo().getBinding().getOperations().i= terator().next().getOperationInfo().getOutput().getMessageParts().get(0).ge= tTypeClass();=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 System.out.println("Class: "+= outputClass);=0A> =0A> =0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 // Set the input ob= ject to request GOOGle's stock quote information=0A>=C2=A0 =C2=A0 =C2=A0 = =C2=A0 Object getQuote =3D inputClass.newInstance();=0A>=C2=A0 =C2=A0 =C2= =A0 =C2=A0 for (Method m : getQuote.getClass().getMethods()) {=0A>=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (m.getName().equals("setSymbol")) {= =0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 m.invoke(getQu= ote, "GOOG");=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 S= ystem.out.println(" Method: "+m.getName()+" invoked");=0A>=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 }=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 }=0A> =0A>=C2= =A0 =C2=A0 =C2=A0 =C2=A0 BindingOperationInfo boi =3D client.getEndpoint()= .getEndpointInfo().getBinding().getOperations().iterator().next();=0A>=C2= =A0 =C2=A0 =C2=A0 =C2=A0 Object[] objects =3D client.invoke(boi, getQuote)= ;=0A> =0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 // We expect the output to be a GetQ= uoteResponse object, which is what outputClass is, but it comes back as a S= tring=0A> =0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (Object o : objects) {=0A>= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 System.out.println("Object: "+o.= getClass());=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (o instanceof= String) {=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Stri= ng s =3D (String) o;=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 System.out.println(s);=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= }=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 }=0A>=C2=A0 =C2=A0 }=0A> =0A>=C2=A0 = =C2=A0 public static List getServices(String url) {=0A>=C2=A0= =C2=A0 =C2=A0 =C2=A0 WSDLServiceFactory sf =3D new WSDLServiceFactory(CXF= BusFactory.getThreadDefaultBus(), url);=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 Def= inition definition =3D sf.getDefinition();=0A> =0A>=C2=A0 =C2=A0 =C2=A0 =C2= =A0 List services;=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 services = =3D new WSDLServiceBuilder(CXFBusFactory.getThreadDefaultBus()).buildServic= es(definition);=0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0 System.out.println(services= .size() + " services in Service List");=0A> =0A>=C2=A0 =C2=A0 =C2=A0 =C2=A0= return services;=0A>=C2=A0 =C2=A0 }=0A> =0A> =0A> =0A> =0A> =0A> Thank y= ou!=0A> Kevin=0A=0A---------------------------------------------=0AFreeman = Fang=0A=0AFuseSource=0AEmail:ffang@fusesource.com=0AWeb: fusesource.com=0AT= witter: freemanfang=0ABlog: http://freemanfang.blogspot.com=0AConnect at Ca= melOne May 24-26=0AThe Open Source Integration Conference --0-1806619037-1305311274=:87516--