You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by da...@free.fr on 2008/04/01 13:28:48 UTC

restservice without httpbinding


hi

i  use the samples/restful_http_binding code and it works very well with this
code :
package mypackage

public final class GeolocServer {

public GeolocServer() {
    	try {
    		logger.info("Starting WebService!");
    		start();
    		logger.info("WebService ready...");
    	}  catch (RuntimeException e) {
    		started=false;
    		logger.warn("can not start Webservice",e.getCause());
    		e.printStackTrace();
    	}

    }
start(){

        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
	sf.setServiceClass(IGeolocService.class);
	sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
	sf.setAddress("http://localhost:8090/services/");
	sf.getServiceFactory().setInvoker(new BeanInvoker(serviceObj));
     	sf.getServiceFactory().setWrapped(wrapped);
	sf.create();
...
===>web.xml

    <servlet>
		<servlet-name>CXFServlet</servlet-name>
		<servlet-class>
			org.apache.cxf.transport.servlet.CXFServlet
		</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>CXFServlet</servlet-name>
		<url-pattern>/services/*</url-pattern>
	</servlet-mapping>

 <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath*:/applicationContext.xml
        </param-value>
    </context-param>

==> applicationContext.xml
....
<bean id="geolocServer" class="mypackage.GeolocServer"/>
...


then i start my jetty on localhost:8080, and when i go to
http://localhost:8090/services/geolocservice =>my service works and when i ask
for http://localhost:8080/services it tells me that there is 'No service was
found' (strange?) but if i change
sf.setAddress("http://localhost:8090/services/"); to
sf.setAddress("http://localhost:8080/services/");

when i start my jetty it say adress already in use...

i found the solution by creating  an xml file  cxf-servlet.xml with the content
of 'applicationContext.xml' and place it in WEB-INF dir, then the
localhost:8080/services tells me that there is some services but can't see wsdl
or anything. so i change the address :

 sf.setAddress("/services/xml"); and i see something on the output but it is
binary data. so my problem is how can i make it serialize in XML as the service
in HTTPbinding do?