Dear all,

I publish some soap-WS through CXF (v. 2.5.0 - bundled into OSGi equinox) on
the following URI:

 

http://10.0.2.243:8160/Persistence

 

The problem is that when a Silverlight client tries to consume my WS, a
"get" request for a resource called clientaccesspolicy.xml is generated,
namely

http:// 10.0.2.243:8160/clientaccesspolicy.xml
<http://%2010.0.2.243:8160/clientaccesspolicy.xml> 

 

Is there a way to configure Jetty to serve this file? I should perform this
programmatically. I tried with something like (sorry for that, I know it is
a very awkward attempt of mine to reproduce the
<http://cxf.apache.org/docs/standalone-http-transport.html>
http://cxf.apache.org/docs/standalone-http-transport.html example):

 

String address = "http:// 10.0.2.243:8160";

Bus _defaultBUS = BusFactory.getDefaultBus();

JettyHTTPServerEngineFactory jettyFactory = 

 
_defaultBUS.getExtension(JettyHTTPServerEngineFactory.class);

// get the jetty server form the destination                          

EndpointInfo ei = new EndpointInfo();

ei.setAddress(address);

DestinationFactoryManager dfm = 

_defaultBUS.getExtension(DestinationFactoryManager.class);

DestinationFactory df = dfm.getDestinationFactoryForUri(address);

JettyHTTPDestination destination = 

        (JettyHTTPDestination) df.getDestination(ei);

 

JettyHTTPDestination jettyDestination = (JettyHTTPDestination) destination;

ServerEngine engine = jettyDestination.getEngine();

Handler handler = engine.getServant(new URL(address));

org.eclipse.jetty.server.Server server = handler.getServer(); // The Server

 

// We have to create a HandlerList structure that includes both a
ResourceHandler for the static

// content as well as the ContextHandlerCollection created by CXF (which we
retrieve as serverHandler). 

Handler serverHandler = server.getHandler();

HandlerList handlerList = new HandlerList();

ResourceHandler resourceHandler = new ResourceHandler();

handlerList.addHandler(resourceHandler);

handlerList.addHandler(serverHandler);

 

// replace the CXF servlet connect collection with the list.

server.setHandler(handlerList);

// and tell the handler list that it is alive.

handlerList.start();

 

// setup the resource handler

File staticContentFile = new File(staticContentPath); // ordinary pathname.

URL targetURL = new URL("file://" + staticContentFile.getCanonicalPath());

FileResource fileResource = new FileResource(targetURL);

resourceHandler.setBaseResource(fileResource);

 

But unfortunately it does not work and it spoils my endpoint. 

 

Could you suggest an alternative java-based approach to serve the
clientaccesspolicy.xml file? 

 

Thank you very much.

 

Matteo Rulli

 

Reply via email to