cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r946667 - in /websites/production/cxf/content: cache/docs.pageCache docs/servlet-transport.html
Date Tue, 07 Apr 2015 15:47:25 GMT
Author: buildbot
Date: Tue Apr  7 15:47:24 2015
New Revision: 946667

Log:
Production update by buildbot for cxf

Modified:
    websites/production/cxf/content/cache/docs.pageCache
    websites/production/cxf/content/docs/servlet-transport.html

Modified: websites/production/cxf/content/cache/docs.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/cxf/content/docs/servlet-transport.html
==============================================================================
--- websites/production/cxf/content/docs/servlet-transport.html (original)
+++ websites/production/cxf/content/docs/servlet-transport.html Tue Apr  7 15:47:24 2015
@@ -117,19 +117,8 @@ Apache CXF -- Servlet Transport
          <td height="100%">
            <!-- Content -->
            <div class="wiki-content">
-<div id="ConfluenceContent"><h1 id="ServletTransport-Settingupyourweb.xml">Setting
up your web.xml</h1>
-
-<p>To create services that use this transport you can either use the CXF APIs (for
example, see <a shape="rect" href="developing-a-service.html">JAX-WS</a>) or create
an XML file which registers services for you.</p>
-
-<h2 id="ServletTransport-PublishinganendpointfromXML">Publishing an endpoint from XML</h2>
-
-<p>CXF uses <a shape="rect" href="configuration.html">Spring</a> to provide
XML configuration of services. This means that first we'll want to load Spring via a Servlet
listener and tell it where our XML configuration file is:</p>
-
-<p>Next, you'll need to add CXFServlet to your web.xml:</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;
+<div id="ConfluenceContent"><h1 id="ServletTransport-Settingupyourweb.xml">Setting
up your web.xml</h1><p>To create services that use this transport you can either
use the CXF APIs (for example, see <a shape="rect" href="developing-a-service.html">JAX-WS</a>)
or create an XML file which registers services for you.</p><h2 id="ServletTransport-PublishinganendpointfromXML">Publishing
an endpoint from XML</h2><p>CXF uses <a shape="rect" href="configuration.html">Spring</a>
to provide XML configuration of services. This means that first we'll want to load Spring
via a Servlet listener and tell it where our XML configuration file is:</p><p>Next,
you'll need to add CXFServlet to your web.xml:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;?xml
version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;
 &lt;!DOCTYPE web-app
     PUBLIC &quot;-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN&quot;
     &quot;http://java.sun.com/dtd/web-app_2_3.dtd&quot;&gt;
@@ -163,13 +152,8 @@ Apache CXF -- Servlet Transport
 
 &lt;/web-app&gt;
 ]]></script>
-</div></div>
-
-<p>Alternatively, you can point to the configuration file using a CXFServlet init parameter
:</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;
+</div></div><p>Alternatively, you can point to the configuration file using
a CXFServlet init parameter :</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;?xml
version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;
 &lt;!DOCTYPE web-app
     PUBLIC &quot;-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN&quot;
     &quot;http://java.sun.com/dtd/web-app_2_3.dtd&quot;&gt;
@@ -195,13 +179,8 @@ Apache CXF -- Servlet Transport
   
 &lt;/web-app&gt;
 ]]></script>
-</div></div>
-
-
-<p>The next step is to actually write the configuration file:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
+</div></div><p>The next step is to actually write the configuration file:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;beans
xmlns=&quot;http://www.springframework.org/schema/beans&quot;
       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
       xmlns:jaxws=&quot;http://cxf.apache.org/jaxws&quot;
       xmlns:jaxrs=&quot;http://cxf.apache.org/jaxrs&quot;
@@ -228,18 +207,8 @@ Apache CXF -- Servlet Transport
 
 &lt;/beans&gt;
 ]]></script>
-</div></div>
-<p>Here we're creating a JAX-WS endpoint based on our implementation class, GreeterImpl.</p>
-
-<p><strong>NOTE:</strong> We're publishing endpoints "http://localhost/mycontext/services/Greeter1"
and "http://localhost/mycontext/services/GreeterRest", but we set jaxws:endpoint/@address
and jaxrs:server/@address to relative values such as "/Greeter1" "/GreeterRest". </p>
-
-<h2 id="ServletTransport-SupportforAsynchronousRequests">Support for Asynchronous Requests</h2>
-
-<p>Enable an 'async-supported' servlet property if you work with Servlet3 API containers
and need to support asynchronous requests:</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-&lt;servlet&gt;
+</div></div><p>Here we're creating a JAX-WS endpoint based on our implementation
class, GreeterImpl.</p><p><strong>NOTE:</strong> We're publishing
endpoints "http://localhost/mycontext/services/Greeter1" and "http://localhost/mycontext/services/GreeterRest",
but we set jaxws:endpoint/@address and jaxrs:server/@address to relative values such as "/Greeter1"
"/GreeterRest".</p><h2 id="ServletTransport-SupportforAsynchronousRequests">Support
for Asynchronous Requests</h2><p>Enable an 'async-supported' servlet property
if you work with Servlet3 API containers and need to support asynchronous requests:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;servlet&gt;
     &lt;servlet-name&gt;CXFServlet&lt;/servlet-name&gt;
     &lt;display-name&gt;CXF Servlet&lt;/display-name&gt;
     &lt;servlet-class&gt;
@@ -253,43 +222,8 @@ Apache CXF -- Servlet Transport
     &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; 
 &lt;/servlet&gt;
 ]]></script>
-</div></div>
-
-<h2 id="ServletTransport-Redirectingrequestsandservingthestaticcontent">Redirecting
requests and serving the static content</h2>
-
-<p>Starting from CXF 2.2.5 it is possible to configure CXFServlet to redirect current
requests to other servlets or serve the static resources.</p>
-
-<p>"redirects-list" init parameter can be used to provide a space separated list of
URI patterns; if a given request URI matches one of the patterns then CXFServlet will try
to find a RequestDispatcher using the pathInfo of the current HTTP request and will redirect
the request to it.</p>
-
-<p>"redirect-servlet-path" can be used to affect a RequestDispatcher lookup, if specified
then it will concatenated with the pathInfo of the current request.  </p>
-
-<p>"redirect-servlet-name" init parameter can be used to enable a named RequestDispatcher
look-up, after one of the URI patterns in the "redirects-list" has matched the current request
URI.</p>
-
-<p>"static-resources-list" init parameter can be used to provide a space separated
list of static resource such as html, css, or pdf files which CXFServlet will serve directly.
</p>
-
-<p>One can have requests redirected to other servlets or JSP pages. </p>
-
-<p>CXFServlets serving both JAXWS and JAXRS based endpoints can avail of this feature.</p>
-
-<p>For example, please see this <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_dispatch/WEB-INF/web.xml">web.xml</a>.
</p>
-
-<p>The "http://localhost:9080/the/bookstore1/books/html/123" request URI will initially
be matched by the CXFServlet given that it has a more specific URI pattern than the RedirectCXFServlet.
After a current URI has reached a jaxrs:server endpoint, the response will be redirected by
the JAXRS <a shape="rect" href="http://cxf.apache.org/docs/jax-rs.html#JAX-RS-WithRequestDispatcherProvider">RequestDispatcherProvider</a>
to a "/book.html" address, see "dispatchProvider1" bean <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_dispatch/WEB-INF/beans.xml">here</a>.</p>
-
-<p>Next, the request URI "/book.html" will be handled by RedirectCXFServlet. Note that
a uri pattern can be a regular expression. This servlet redirects the request further to a
RequestDispatcher capable of handling a "/static/book.html".</p>
-
-<p>Finally, DefaultCXFServlet serves a requested book.html.</p>
-
-<h2 id="ServletTransport-Servingwelcomepages">Serving welcome pages</h2>
-
-<p>Starting from CXF 2.5.5 and 2.6.2 it is possible to configure CXFServlet to serve
welcome pages in a number of ways.</p>
-
-<p>For example, lets assume we have a web application called "webapp" which has a root
resource called "index.html". For CXFServlet to support both "/webapp" and "/webapp/index.html"
requests returning "index.html", while letting all other requests to proceed to the actual
endpoints, the following can be done.</p>
-
-<p>Option1. Delegating to Default Servlet</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-&lt;servlet&gt;
+</div></div><h2 id="ServletTransport-Redirectingrequestsandservingthestaticcontent">Redirecting
requests and serving the static content</h2><p>Starting from CXF 2.2.5 it is possible
to configure CXFServlet to redirect current requests to other servlets or serve the static
resources.</p><p>"redirects-list" init parameter can be used to provide a space
separated list of URI patterns; if a given request URI matches one of the patterns then CXFServlet
will try to find a RequestDispatcher using the pathInfo of the current HTTP request and will
redirect the request to it.</p><p>"redirect-servlet-path" can be used to affect
a RequestDispatcher lookup, if specified then it will concatenated with the pathInfo of the
current request.</p><p>"redirect-servlet-name" init parameter can be used to enable
a named RequestDispatcher look-up, after one of the URI patterns in the "redirects-list" has
matched the current request URI.</p><p>"static-resources-list" init parameter
can be used to provide a 
 space separated list of static resource such as html, css, or pdf files which CXFServlet
will serve directly.</p><p>One can have requests redirected to other servlets
or JSP pages.</p><p>CXFServlets serving both JAXWS and JAXRS based endpoints can
avail of this feature.</p><p>For example, please see this <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_dispatch/WEB-INF/web.xml">web.xml</a>.</p><p>The
"http://localhost:9080/the/bookstore1/books/html/123" request URI will initially be matched
by the CXFServlet given that it has a more specific URI pattern than the RedirectCXFServlet.
After a current URI has reached a jaxrs:server endpoint, the response will be redirected by
the JAXRS <a shape="rect" href="http://cxf.apache.org/docs/jax-rs.html#JAX-RS-WithRequestDispatcherProvider">RequestDispatcherProvider</a>
to a "/book.html" address, see "dispatchProvider1" bean <a shape="rect" class="external-link"
href="
 https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob;f=systests/jaxrs/src/test/resources/jaxrs_dispatch/WEB-INF/web.xml;h=a2212337bd6a9ed7a212b21a6826850581601121;hb=HEAD">here</a>.</p><p>Next,
the request URI "/book.html" will be handled by RedirectCXFServlet. Note that a uri pattern
can be a regular expression. This servlet redirects the request further to a RequestDispatcher
capable of handling a "/static/book.html".</p><p>Finally, DefaultCXFServlet serves
a requested book.html.</p><h2 id="ServletTransport-Servingwelcomepages">Serving
welcome pages</h2><p>Starting from CXF 2.5.5 and 2.6.2 it is possible to configure
CXFServlet to serve welcome pages in a number of ways.</p><p>For example, lets
assume we have a web application called "webapp" which has a root resource called "index.html".
For CXFServlet to support both "/webapp" and "/webapp/index.html" requests returning "index.html",
while letting all other requests to proceed to the actual endpoints, the following can be
do
 ne.</p><p>Option1. Delegating to Default Servlet</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;servlet&gt;
    &lt;servlet-name&gt;CXFServlet&lt;/servlet-name&gt;
    &lt;display-name&gt;CXF Servlet&lt;/display-name&gt;
    &lt;servlet-class&gt;
@@ -324,15 +258,8 @@ Apache CXF -- Servlet Transport
    &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
 &lt;/welcome-file-list&gt;
 ]]></script>
-</div></div>
-
-<p>Note that the redirects-list parameter has two space separated values, "/" and "index.html".
The request attribute 'javax.servlet.include.request_uri' might need to be set for the underlying
container like Jetty to successfully read "index.html".</p>
-
-<p>Option2. Using CXFServlet itself to read index.html</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-&lt;servlet&gt;
+</div></div><p>Note that the redirects-list parameter has two space separated
values, "/" and "index.html". The request attribute 'javax.servlet.include.request_uri' might
need to be set for the underlying container like Jetty to successfully read "index.html".</p><p>Option2.
Using CXFServlet itself to read index.html</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;servlet&gt;
    &lt;servlet-name&gt;CXFServlet&lt;/servlet-name&gt;
    &lt;display-name&gt;CXF Servlet&lt;/display-name&gt;
    &lt;servlet-class&gt;
@@ -353,15 +280,8 @@ Apache CXF -- Servlet Transport
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
 &lt;/servlet-mapping&gt;
 ]]></script>
-</div></div>
-
-
-<h2 id="ServletTransport-PublishinganendpointwiththeAPI">Publishing an endpoint with
the API</h2>
-
-<p>Once your Servlet is registered in your web.xml, you should set the default bus
with CXFServlet's bus to make sure that CXF uses it as its HTTP Transport. Simply publish
with the related path "Greeter" and your service should appear at the address you specify:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
-import javax.xml.ws.Endpoint;
+</div></div><h2 id="ServletTransport-PublishinganendpointwiththeAPI">Publishing
an endpoint with the API</h2><p>Once your Servlet is registered in your web.xml,
you should set the default bus with CXFServlet's bus to make sure that CXF uses it as its
HTTP Transport. Simply publish with the related path "Greeter" and your service should appear
at the address you specify:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[import
javax.xml.ws.Endpoint;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.transport.servlet.CXFServlet;
@@ -372,22 +292,8 @@ Bus bus = cxf.getBus();
 BusFactory.setDefaultBus(bus); 
 Endpoint.publish(&quot;/Greeter&quot;, new GreeterImpl());
 ]]></script>
-</div></div>
-<p>The one thing you must ensure is that your CXFServlet is set up to listen on that
path. Otherwise the CXFServlet will never receive the requests. </p>
-
-<p><strong>NOTE:</strong> </p>
-
-<p>Endpoint.publish(...) is a JAX-WS API for publishing JAX-WS endpoints.  Thus, it
would require the JAX-WS module and APIs to be present.   If you are not using JAX-WS or want
more control over the published endpoint properties, you should replace that call with the
proper calls to the appropriate ServerFactory.</p>
-
-<p>Since CXFServlet know nothing about the web container listening port and the application
context path, you need to specify the relative path instead of the full http address.</p>
-
-
-<h2 id="ServletTransport-UsingtheservlettransportwithoutSpring">Using the servlet transport
without Spring</h2>
-
-<p>A user who doesn't want to touch any Spring stuff could also publish the endpoint
with CXF servlet transport. First you should extend the CXFNonSpringServlet and then override
the method loadBus, e.g.:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
-import javax.xml.ws.Endpoint;
+</div></div><p>The one thing you must ensure is that your CXFServlet is
set up to listen on that path. Otherwise the CXFServlet will never receive the requests.</p><p><strong>NOTE:</strong></p><p>Endpoint.publish(...)
is a JAX-WS API for publishing JAX-WS endpoints. Thus, it would require the JAX-WS module
and APIs to be present. If you are not using JAX-WS or want more control over the published
endpoint properties, you should replace that call with the proper calls to the appropriate
ServerFactory.</p><p>Since CXFServlet know nothing about the web container listening
port and the application context path, you need to specify the relative path instead of the
full http address.</p><h2 id="ServletTransport-UsingtheservlettransportwithoutSpring">Using
the servlet transport without Spring</h2><p>A user who doesn't want to touch any
Spring stuff could also publish the endpoint with CXF servlet transport. First you should
extend the CXFNonSpringServlet and then override the method loadBu
 s, e.g.:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[import
javax.xml.ws.Endpoint;
 ...  
   
     @Override
@@ -407,12 +313,8 @@ import javax.xml.ws.Endpoint;
         factory.create();              
     }
 ]]></script>
-</div></div>
-
-<p>If you are using the Jetty as the embedded servlet engine, you could publish endpoint
like this:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
-import javax.xml.ws.Endpoint;
+</div></div><p>If you are using the Jetty as the embedded servlet engine,
you could publish endpoint like this:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[import
javax.xml.ws.Endpoint;
 ...
 
         // Setup the system properties to use the CXFBusFactory not the SpringBusFactory
@@ -453,23 +355,12 @@ import javax.xml.ws.Endpoint;
             }
         }
 ]]></script>
-</div></div>
-
-<h2 id="ServletTransport-AccessingtheMessageContextand/orHTTPRequestandResponse">Accessing
the MessageContext and/or HTTP Request and Response</h2>
-
-<p>Sometimes you'll want to access more specific message details in your service implementation.
 One example might be accessing the actual request or response object itself.  This can be
done using the WebServiceContext object.</p>
-
-<p>First, declare a private field for the <a shape="rect" class="external-link"
href="http://java.sun.com/javase/6/docs/api/javax/xml/ws/WebServiceContext.html" rel="nofollow">WebServiceContext</a>
in your service implementation, and annotate it as a resource:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
-@Resource
+</div></div><h2 id="ServletTransport-AccessingtheMessageContextand/orHTTPRequestandResponse">Accessing
the MessageContext and/or HTTP Request and Response</h2><p>Sometimes you'll want
to access more specific message details in your service implementation. One example might
be accessing the actual request or response object itself. This can be done using the WebServiceContext
object.</p><p>First, declare a private field for the <a shape="rect" class="external-link"
href="http://java.sun.com/javase/6/docs/api/javax/xml/ws/WebServiceContext.html" rel="nofollow">WebServiceContext</a>
in your service implementation, and annotate it as a resource:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@Resource
 private WebServiceContext context;
 ]]></script>
-</div></div>
-<p>Then, within your implementing methods, you can access the MessageContext, HttpServletRequest,
and HttpServletResponse as follows:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
-import javax.servlet.http.HttpServletRequest;
+</div></div><p>Then, within your implementing methods, you can access the
MessageContext, HttpServletRequest, and HttpServletResponse as follows:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[import
javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.xml.ws.handler.MessageContext;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
@@ -481,8 +372,7 @@ HttpServletRequest request = (HttpServle
 HttpServletResponse response = (HttpServletResponse) 
     ctx.get(AbstractHTTPDestination.HTTP_RESPONSE);
 ]]></script>
-</div></div>
-<p>Of course, it is always a good idea to program defensively if using transport-specific
entities like the HttpServletRequest and HttpServletResponse.  If the transport were changed
(for instance to the JMS transport), then these values would likely be null.</p></div>
+</div></div><p>Of course, it is always a good idea to program defensively
if using transport-specific entities like the HttpServletRequest and HttpServletResponse.
If the transport were changed (for instance to the JMS transport), then these values would
likely be null.</p></div>
            </div>
            <!-- Content -->
          </td>



Mime
View raw message