Hi, Dan, 
Following your suggestion, I've implemented a BusLifeCycleListener like this:

   @Override
    public void initComplete() {
        Bus bus = BusFactory.getThreadDefaultBus();
        if (null != bus){
            final Configurer origConf = bus.getExtension(Configurer.class);
            bus.setExtension(new Configurer(){

                @Override
                public void configureBean(Object arg0) {
                    if (arg0 instanceof EndpointImpl){
                        EndpointImpl ei = (EndpointImpl)arg0;
                        QName serviceName = ei.getServiceName();
                        String wsdlLocation = "http://localhost:8099/registry/"; 
+ serviceName.getLocalPart() + ".wsdl";
                        System.out.println("wsdlLocation: " + wsdlLocation);
                        ei.setWsdlLocation(wsdlLocation);

                    }
                    if (arg0 instanceof JaxWsServerFactoryBean){
                        JaxWsServerFactoryBean serverFactory = 
(JaxWsServerFactoryBean)arg0;
                        QName serviceName = serverFactory.getServiceName();
                        String wsdlLocation = "http://localhost:8099/registry/"; 
+ serviceName.getLocalPart() + ".wsdl";
                        System.out.println("wsdlLocation: " + wsdlLocation);
                        serverFactory.setWsdlLocation(wsdlLocation);
                    }
                    origConf.configureBean(arg0);
                }

                @Override
                public void configureBean(String arg0, Object arg1) {
                    origConf.configureBean(arg0, arg1);
                }}, Configurer.class);
        }
        
    }

And add one line "my.BusListenerImpl::true"
To the META-INF/cxf/bus-extensions.txt of this bundle.

But unfortunately, seems this listener didn't take effect when I deployed other 
service bundle (with jaxws:endpoint) into the same Osgi container :(

Thanks.
Xilai
-----Original Message-----
From: Daniel Kulp [mailto:[email protected]] 
Sent: Tuesday, July 10, 2012 11:24 AM
To: [email protected]
Cc: XiLai Dai
Subject: Re: How to set wsdlLocation using API

On Tuesday, July 10, 2012 01:47:36 AM XiLai Dai wrote:
> Thanks Dan!
> Really don't understand what the meaning of your codes :( but I try to
> find another way like this: 
 
> public class ServiceListenerImpl implements ServerLifeCycleListener{
>     String wsdlURL = ......;
>     public void startServer(Server server) {
>         String origAddress =
> server.getEndpoint().getEndpointInfo().getAddress();
 ServerFactoryBean
> factoryBean = new ServerFactoryBean();
> factoryBean.setServiceClass(server.getEndpoint().getBinding().getBindingI
> nfo().getService().getInterface().getService().getClass());
> factoryBean.setAddress(origAddress);
>         factoryBean.setServer(server);
>         factoryBean.setWsdlURL(wsdlURL);
>         server = factoryBean.create();
>     }
> }
> 
> Is it feasible in this way?

Not really, no.  That will create a second service on the same address.   
That will likely result in exceptions in the logs as only one of the 
services will be allowed to be activated and such.



-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to