Hi Willem,

Thanks for your help.  Where do I find the hello_world JAX-WS example?

I've been hacking away.  This is partially working:

Bus bus = BusFactoryHelper.newInstance().createBus();

SoapTransportFactory soap = new SoapTransportFactory();
soap.setBus(bus);

HTTPTransportFactory http = new HTTPTransportFactory();
http.setBus(bus);

JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
sf.setBus(bus);
sf.setAddress("http://localhost:9000/hello";);
//        sf.setServiceClass(Hello.class);
Hello hello = new Hello();
hello.addGreeting("hola");
sf.setServiceBean(hello);
sf.create();

Attached is the whole StartCxf.java as well as the modified
Hello.java.  The problem I am having now is that a new Hello instance
gets created for each SOAP request.  I was hoping that it would use
the service bean that I set with setServiceBean().  Anyway to make
this happen?

Just a note, the  cxf-rt-transports-http works as expected and I can
get the WSDL at:
http://localhost:9000/hello?wsdl

But the cxf-rt-transports-http2 seams to default to the rest style, I
think.  I can't get the WSDL at the above URL, but these URL's work:
http://localhost:9000/getGrettings
http://localhost:9000/sayHi?text=Cameron

cheers,
Cameron

On 1/17/07, Willem Jiang <[EMAIL PROTECTED]> wrote:
Hi Cameron,

Just as Jervis had said, you can use the JAX-WS API as the hello_world
sample had showed to create Web Services.
I just read quick look at your code. If you want to use the
JaxWsServiceFactoryBean, I can give you some points about the
BusExtension stuff.

1.  The Bus keeps all the extension stuff in it hashmap, so the rt-code
can know nothing about the binding and transport , in that way we can
make our CXF more pluggable.
2.  The Bus will automatically register the extension by look up the
spring configuration file cxf-extension-* in the classpath. (Seeing
SpringBusFactory and BusApplicationContext for more detail things)
3.  You can hack the bus extension by write the hard code, just like
AbstractJaxWsTest.

I checked your code, you had created the bus and setup the bus to the
JaxWsServiceFactoryBean .
I think the real reason which you can't get the DestinationFactory with
the namespace "http://schemas.xmlsoap.org/wsdl/soap/http"; is your
project did not add the cxf-rt-transport-http as your depended project.
I guess you just add this code in the cxf-rt-frontend-jaxws project. And
In the cxf-rt-frontend-jaxws, we skip the cxf-rt-transport-http and
using the local transport for sending message, so the namespace
"http://schemas.xmlsoap.org/wsdl/soap/http";  will not be resisted with
the bus. If you want to do this with code, you can find the detail codes
in AbstractJaxWsTest.

Enjoy your hacking work in CXF.

Willem.



Cameron Taggart wrote:
> I'm having trouble getting started with the JAX-WS front end, so I
> voted for:
> https://issues.apache.org/jira/browse/CXF-52
>
> I've read through the Architecture Guide
> (http://cwiki.apache.org/CXF/architecture-guide.html) and checked out
> svn head, imported into Eclipse, and have been looking around the
> code.
>
> My current problem is:
> Exception in thread "main" org.apache.cxf.BusException: No
> DestinationFactory was found for the namespace
> http://schemas.xmlsoap.org/wsdl/soap/http.
>     at
> 
org.apache.cxf.transport.DestinationFactoryManagerImpl.getDestinationFactory(DestinationFactoryManagerImpl.java:99)
>
>     at test.StartCxf.main(StartCxf.java:28)
>
>
> I was looking at JaxWsServerFactoryBeanTest for inspiration.  Any idea
> how to register a destination factory for
> http://schemas.xmlsoap.org/wsdl/soap/http.
>
> Thanks,
> Cameron
> ------------------------------------------------------------------------
>
> package test;
>
> import org.apache.cxf.Bus;
> import org.apache.cxf.BusException;
> import org.apache.cxf.BusFactoryHelper;
> import org.apache.cxf.binding.BindingFactoryManager;
> import org.apache.cxf.bus.spring.SpringBusFactory;
> import org.apache.cxf.endpoint.Server;
> import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
> import org.apache.cxf.jaxws.service.Hello;
> import org.apache.cxf.transport.DestinationFactory;
> import org.apache.cxf.transport.DestinationFactoryManager;
>
> public class StartCxf {
>
>       public static void main(String[] args) throws BusException {
>               JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
> //        sf.setBus(getBus());
>
>               Bus bus = BusFactoryHelper.newInstance().createBus();
> //            SpringBusFactory sbf = new SpringBusFactory();
> //            Bus bus = sbf.createBus();
>
>       BindingFactoryManager bfm = 
bus.getExtension(BindingFactoryManager.class);
>       System.out.println("binding factory: 
"+bfm.getBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/http";));
>
>       DestinationFactory destinationFactory = 
bus.getExtension(DestinationFactoryManager.class)
>         .getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http";);
>       System.out.println("destinationFactory: "+destinationFactory);
>
>       sf.setBus(bus);
>
>         sf.setAddress("http://localhost:9000/test";);
>         sf.setServiceClass(Hello.class);
> //        sf.setStart(false);
>
>         Server server = sf.create();
>       }
>
> }
>


package test;

import org.apache.cxf.Bus;
import org.apache.cxf.BusException;
import org.apache.cxf.BusFactory;
import org.apache.cxf.BusFactoryHelper;
import org.apache.cxf.binding.soap.SoapTransportFactory;
import org.apache.cxf.bus.cxf.CXFBusFactory;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.apache.cxf.jaxws.service.Hello;
import org.apache.cxf.transport.http.HTTPTransportFactory;

public class StartCxf {

        public static void main(String[] args) throws BusException {
                
                Bus bus = BusFactoryHelper.newInstance().createBus();
        
                SoapTransportFactory soap = new SoapTransportFactory();
                soap.setBus(bus);
                
        HTTPTransportFactory http = new HTTPTransportFactory();
        http.setBus(bus);
        
        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
        sf.setBus(bus);
        sf.setAddress("http://localhost:9000/hello";);
//        sf.setServiceClass(Hello.class);
        Hello hello = new Hello();
        hello.addGreeting("hola");
        sf.setServiceBean(hello);
        sf.create();
        }

}
/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.cxf.jaxws.service;

import java.util.ArrayList;
import java.util.List;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public class Hello {
        
        private List<String> greetings = new ArrayList<String>();
        
        public Hello(){
        greetings.add("Hello");
        greetings.add("Bonjour");
        }
        
    @WebMethod
    public String sayHi(String text) {
        return text;
    }
    
    @WebMethod
    public List<String> getGreetings() {
        return greetings;
    }
    
    public void addGreeting(String greeting){
        greetings.add(greeting);
    }
}

Reply via email to