cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Mao <james....@iona.com>
Subject Re: svn commit: r478826 - in /incubator/cxf/trunk/rt/frontend/jaxws/src: main/java/org/apache/cxf/jaxws/servlet/ test/java/org/apache/cxf/jaxws/servlet/
Date Wed, 29 Nov 2006 03:10:40 GMT
I think the http://localhost/services/  might direct to a richer html 
page, you can see the bloglines.com services page
and basically i think we can use ?serviceList ?operationList to get the 
information, and the HTML is not the only choice.
we should also be able to generate other formats, like XML, so maybe we 
can also generate the ATOM/RSS/OPML formats. that's more easier for 
other service to consume the services.

just my personal thought for reference.

-James.

> I'm not real keen on ?serviceList - why not just have it at the URL we 
> map
> the servlet to? i.e. http://localhost/services/
>
> - Dan
>
> On 11/24/06, James Mao <james.mao@iona.com> wrote:
>>
>> Hi Willem,
>>
>> I suggest we use ?serviceList to retrieve the service list
>> just like we use ?wsdl to retrieve the wsdl
>>
>> Cheers,
>> James.
>>
>> > Author: ningjiang
>> > Date: Fri Nov 24 02:11:33 2006
>> > New Revision: 478826
>> >
>> > URL: http://svn.apache.org/viewvc?view=rev&rev=478826
>> > Log:
>> > [JIRA CXF-266] Let servlet control can return list of services 
>> which are
>> published by servlet
>> > Now we can get the services list from http://localhost/services
>> >
>> > Modified:
>> >
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java

>>
>> >
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletController.java

>>
>> >
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java

>>
>> >
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletTransportFactory.java

>>
>> >
>> incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/servlet/CXFServletTest.java

>>
>> >
>> > Modified:
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java

>>
>> > URL:
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java?view=diff&rev=478826&r1=478825&r2=478826

>>
>> >
>> ============================================================================== 
>>
>> > ---
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java

>>
>> (original)
>> > +++
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java

>>
>> Fri Nov 24 02:11:33 2006
>> > @@ -59,7 +59,7 @@
>> >   *
>> >   */
>> >  public class CXFServlet extends HttpServlet {
>> > -
>> > +    static final String ADDRESS_PERFIX = "http://localhost/services";
>> >      static final Map<String, WeakReference<Bus>> BUS_MAP = new
>> Hashtable<String, WeakReference<Bus>>();
>> >      static final Logger LOG = 
>> Logger.getLogger(CXFServlet.class.getName
>> ());
>> >      protected Bus bus;
>> > @@ -189,28 +189,7 @@
>> >                                String urlPat) throws 
>> ServletException {
>> >
>> >          try {
>> > -
>> > -            // TODO: This wasn't doing anything before. We need to 
>> pass
>> this to
>> > -            // the
>> > -            // EndpointImpl so the service factory can use it...
>> > -            // URL url = null;
>> > -            // if (wsdlName != null && wsdlName.length() > 0) {
>> > -            // try {
>> > -            // url =
>> > -            //
>> getServletConfig().getServletContext().getResource(wsdlName);
>> > -            // } catch (MalformedURLException ex) {
>> > -            // try {
>> > -            // url = new URL(wsdlName);
>> > -            // } catch (MalformedURLException ex2) {
>> > -            // try {
>> > -            // url =
>> getServletConfig().getServletContext().getResource("/" +
>> > -            // wsdlName);
>> > -            // } catch (MalformedURLException ex3) {
>> > -            // url = null;
>> > -            // }
>> > -            // }
>> > -            // }
>> > -            // }
>> > +
>> >              Class cls = ClassLoaderUtils.loadClass(implName,
>> getClass());
>> >              Object impl = cls.newInstance();
>> >
>> > @@ -218,7 +197,7 @@
>> >              LOG.info("publish the servcie to {context}/ " + (
>> urlPat.charAt(0) == '/' ? "" : "/") + urlPat);
>> >
>> >              // TODO we may need to get the url-pattern from servlet
>> context
>> > -            ep.publish("http://localhost/services" + 
>> (urlPat.charAt(0)
>> == '/' ? "" : "/") + urlPat);
>> > +            ep.publish(ADDRESS_PERFIX + (urlPat.charAt(0) == '/' ? 
>> "" :
>> "/") + urlPat);
>> >
>> >          } catch (ClassNotFoundException ex) {
>> >              throw new ServletException(ex);
>> >
>> > Modified:
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletController.java

>>
>> > URL:
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletController.java?view=diff&rev=478826&r1=478825&r2=478826

>>
>> >
>> ============================================================================== 
>>
>> > ---
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletController.java

>>
>> (original)
>> > +++
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletController.java

>>
>> Fri Nov 24 02:11:33 2006
>> > @@ -70,7 +70,7 @@
>> >          boolean xsd = false;
>> >          if (request.getQueryString() != null && 
>> request.getQueryString().trim().equalsIgnoreCase("wsdl"))
>> {
>> >              wsdl = true;
>> > -        }
>> > +        }
>> >          String xsdName = request.getRequestURI().substring(
>> >              request.getRequestURI().lastIndexOf("/") + 1);
>> >          if (xsdName != null
>> > @@ -86,11 +86,15 @@
>> >              if (d.getMessageObserver() == null) {
>> >                  if (xsd) {
>> >                      generateXSD(request, res, xsdName);
>> > -                } else {
>> > -                    LOG.warning("Can't find the the request for"
>> > -                         + "http://localhost" + 
>> request.getServletPath
>> ()
>> > -                         + request.getPathInfo() + " 's Observer ");
>> > -                    generateNotFound(request, res);
>> > +                } else {
>> > +                    if 
>> (request.getRequestURI().endsWith("services")) {
>> > +                        generateServiceList(request, res);
>> > +                    } else {
>> > +                        LOG.warning("Can't find the the request for"
>> > +                                    + "http://localhost" +
>> request.getServletPath()
>> > +                                    + request.getPathInfo() + " 's
>> Observer ");
>> > +                        generateNotFound(request, res);
>> > +                    }
>> >                  }
>> >              } else if (wsdl) {
>> >                  generateWSDL(request, res, d);
>> > @@ -100,6 +104,28 @@
>> >          } catch (IOException e) {
>> >              throw new ServletException(e);
>> >          }
>> > +    }
>> > +
>> > +    private void generateServiceList(HttpServletRequest request,
>> HttpServletResponse response)
>> > +        throws IOException {
>> > +        List<ServletDestination> destinations =
>> transport.getDestinations();
>> > +        response.setContentType("text/html");
>> > +        response.getWriter().write("<html><body>");
>> > +        if (destinations.size() > 0) {
>> > +            for (ServletDestination sd : destinations) {
>> > +                if (null != sd.getEndpointInfo().getName()) {
>> > +                    String address = sd.getAddress
>> ().getAddress().getValue();
>> > +                    int bi = 
>> address.indexOf(CXFServlet.ADDRESS_PERFIX
>> );
>> > +                    address = request.getRequestURL()
>> > +                        + address.substring(bi +
>> CXFServlet.ADDRESS_PERFIX.length());
>> > +                    response.getWriter().write("<a href=\"" + 
>> address +
>> "\">");
>> > +                    
>> response.getWriter().write(sd.getEndpointInfo().getName()
>> + "</a>");
>> > +                }
>> > +            }
>> > +        } else {
>> > +            response.getWriter().write("No service was found.");
>> > +        }
>> > +        response.getWriter().write("</body></html>");
>> >      }
>> >
>> >      private void generateXSD(HttpServletRequest request,
>> HttpServletResponse response, String xsdName)
>> >
>> > Modified:
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java

>>
>> > URL:
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java?view=diff&rev=478826&r1=478825&r2=478826

>>
>> >
>> ============================================================================== 
>>
>> > ---
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java

>>
>> (original)
>> > +++
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java

>>
>> Fri Nov 24 02:11:33 2006
>> > @@ -155,7 +155,7 @@
>> >       * @param observer the observer to notify on receipt of incoming
>> >       */
>> >      public synchronized void setMessageObserver(MessageObserver
>> observer) {
>> > -        LOG.info("!!! set the observer for address " +
>> getAddress().getAddress().getValue());
>> > +        LOG.info("set the observer for address " +
>> getAddress().getAddress().getValue());
>> >          incomingObserver = observer;
>> >      }
>> >
>> > @@ -262,8 +262,7 @@
>> >
>> >              setHeaders(inMessage);
>> >
>> > -            inMessage.setDestination(this);
>> > -
>> > +            inMessage.setDestination(this);
>> >
>> >              incomingObserver.onMessage(inMessage);
>> >
>> >
>> > Modified:
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletTransportFactory.java

>>
>> > URL:
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletTransportFactory.java?view=diff&rev=478826&r1=478825&r2=478826

>>
>> >
>> ============================================================================== 
>>
>> > ---
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletTransportFactory.java

>>
>> (original)
>> > +++
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletTransportFactory.java

>>
>> Fri Nov 24 02:11:33 2006
>> > @@ -21,8 +21,10 @@
>> >  package org.apache.cxf.jaxws.servlet;
>> >
>> >  import java.io.IOException;
>> > -import java.util.HashMap;
>> > +import java.util.ArrayList;
>> > +import java.util.List;
>> >  import java.util.Map;
>> > +import java.util.concurrent.ConcurrentHashMap;
>> >
>> >  import javax.annotation.Resource;
>> >
>> > @@ -36,7 +38,8 @@
>> >      implements DestinationFactory {
>> >
>> >      private Bus bus;
>> > -    private Map<String, ServletDestination> destinations = new
>> HashMap<String, ServletDestination>();
>> > +    private Map<String, ServletDestination> destinations =
>> > +        new ConcurrentHashMap<String, ServletDestination>();
>> >
>> >      public ServletTransportFactory(Bus b) {
>> >          bus = b;
>> > @@ -54,7 +57,7 @@
>> >          this.bus = bus;
>> >      }
>> >
>> > -    public synchronized Destination getDestination(EndpointInfo
>> endpointInfo)
>> > +    public Destination getDestination(EndpointInfo endpointInfo)
>> >          throws IOException {
>> >          ServletDestination d = 
>> destinations.get(endpointInfo.getAddress
>> ());
>> >          if (d == null) {
>> > @@ -62,5 +65,13 @@
>> >              destinations.put(endpointInfo.getAddress(), d);
>> >          }
>> >          return d;
>> > +    }
>> > +
>> > +    public List<ServletDestination> getDestinations() {
>> > +        List<ServletDestination> result = new
>> ArrayList<ServletDestination>();
>> > +        for (ServletDestination sd : destinations.values()) {
>> > +            result.add(sd);
>> > +        }
>> > +        return result;
>> >      }
>> >  }
>> >
>> > Modified:
>> incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/servlet/CXFServletTest.java

>>
>> > URL:
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/servlet/CXFServletTest.java?view=diff&rev=478826&r1=478825&r2=478826

>>
>> >
>> ============================================================================== 
>>
>> > ---
>> incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/servlet/CXFServletTest.java

>>
>> (original)
>> > +++
>> incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/servlet/CXFServletTest.java

>>
>> Fri Nov 24 02:11:33 2006
>> > @@ -24,6 +24,7 @@
>> >
>> >  import com.meterware.httpunit.GetMethodWebRequest;
>> >  import com.meterware.httpunit.PostMethodWebRequest;
>> > +import com.meterware.httpunit.WebLink;
>> >  import com.meterware.httpunit.WebRequest;
>> >  import com.meterware.httpunit.WebResponse;
>> >  import com.meterware.servletunit.ServletUnitClient;
>> > @@ -72,6 +73,32 @@
>> >
>> >          assertValid("/s:Envelope/s:Body", doc);
>> >          assertValid("//h:sayHiResponse", doc);
>> > +    }
>> > +
>> > +    public void testGetServiceList() throws Exception {
>> > +        ServletUnitClient client = newClient();
>> > +
>> > +        JaxWsServerFactoryBean svr = new JaxWsServerFactoryBean();
>> > +        URL resource =
>> getClass().getResource("/wsdl/hello_world.wsdl");
>> > +        assertNotNull(resource);
>> > +        svr.getServiceFactory().setWsdlURL(resource);
>> > +        svr.setBus(getBus());
>> > +        svr.setServiceClass(GreeterImpl.class);
>> > +        svr.setAddress("http://localhost/services/Greeter");
>> > +
>> > +        GreeterImpl greeter = new GreeterImpl();
>> > +        BeanInvoker invoker = new BeanInvoker(greeter);
>> > +        svr.getServiceFactory().setInvoker(invoker);
>> > +
>> > +        svr.create();
>> > +
>> > +        client.setExceptionsThrownOnErrorStatus(false);
>> > +
>> > +        WebResponse res = 
>> client.getResponse("http://localhost/services
>> ");
>> > +        WebLink[] links = res.getLinks();
>> > +        assertEquals("There should get one link for service",
>> links.length, 1);
>> > +        assertEquals(links[0].getURLString(), "
>> http://localhost/services/Greeter");
>> > +        assertEquals("text/html", res.getContentType());
>> >      }
>> >
>> >      public void testInvalidServiceUrl() throws Exception {
>> >
>> >
>> >
>> >
>>
>>
>
>


Mime
View raw message