blob: ec36fd002d64c985bf7f2121b73bc5c625cd5e59 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
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.
-->
<html>
<head>
<link type="text/css" rel="stylesheet" href="/resources/site.css">
<script src='/resources/space.js'></script>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta name="keywords" content="business integration, EAI, SOA, Service Oriented Architecture, web services, SOAP, JBI, JMS, WSDL, XML, EDI, Electronic Data Interchange, standards support, integration standards, application integration, middleware, software, solutions, services, CXF, open source">
<meta name="description" content="Apache CXF, Services Framework - Standalone HTTP Transport">
<link type="text/css" rel="stylesheet" href="/resources/highlighter/styles/shCoreCXF.css">
<link type="text/css" rel="stylesheet" href="/resources/highlighter/styles/shThemeCXF.css">
<script src='/resources/highlighter/scripts/shCore.js'></script>
<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script>
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
</script>
<title>
Apache CXF -- Standalone HTTP Transport
</title>
</head>
<body onload="init()">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td id="cell-0-0" colspan="2">&nbsp;</td>
<td id="cell-0-1">&nbsp;</td>
<td id="cell-0-2" colspan="2">&nbsp;</td>
</tr>
<tr>
<td id="cell-1-0">&nbsp;</td>
<td id="cell-1-1">&nbsp;</td>
<td id="cell-1-2">
<!-- Banner -->
<div class="banner" id="banner"><div><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td align="left" colspan="1" nowrap>
<a shape="rect" href="http://cxf.apache.org/" title="Apache CXF"><span style="font-weight: bold; font-size: 170%; color: white">Apache CXF</span></a>
</td><td align="right" colspan="1" nowrap>
<a shape="rect" href="http://www.apache.org/" title="The Apache Sofware Foundation"><img border="0" alt="ASF Logo" src="http://cxf.apache.org/images/asf-logo.png"></a>
</td></tr></table></div></div>
<!-- Banner -->
<div id="top-menu">
<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr>
<td>
<div align="left">
<!-- Breadcrumbs -->
<a href="index.html">Index</a>&nbsp;&gt;&nbsp;<a href="transports.html">Transports</a>&nbsp;&gt;&nbsp;<a href="http-transport.html">HTTP Transport</a>&nbsp;&gt;&nbsp;<a href="standalone-http-transport.html">Standalone HTTP Transport</a>
<!-- Breadcrumbs -->
</div>
</td>
<td>
<div align="right">
<!-- Quicklinks -->
<div id="quicklinks"><p><a shape="rect" href="http://cxf.apache.org/download.html">Download</a> | <a shape="rect" href="http://cxf.apache.org/docs/index.html">Documentation</a></p></div>
<!-- Quicklinks -->
</div>
</td>
</tr>
</table>
</div>
</td>
<td id="cell-1-3">&nbsp;</td>
<td id="cell-1-4">&nbsp;</td>
</tr>
<tr>
<td id="cell-2-0" colspan="2">&nbsp;</td>
<td id="cell-2-1">
<table>
<tr valign="top">
<td height="100%">
<div id="wrapper-menu-page-right">
<div id="wrapper-menu-page-top">
<div id="wrapper-menu-page-bottom">
<div id="menu-page">
<!-- NavigationBar -->
<div id="navigation"><ul class="alternate"><li><a shape="rect" href="overview.html">Overview</a></li><li><a shape="rect" href="how-tos.html">How-Tos</a></li><li><a shape="rect" href="frontends.html">Frontends</a></li><li><a shape="rect" href="databindings.html">DataBindings</a></li><li><a shape="rect" href="transports.html">Transports</a></li><li><a shape="rect" href="configuration.html">Configuration</a></li><li><a shape="rect" href="debugging-and-logging.html">Debugging and Logging</a></li><li><a shape="rect" href="tools.html">Tools</a></li><li><a shape="rect" href="restful-services.html">RESTful Services</a></li><li><a shape="rect" href="wsdl-bindings.html">WSDL Bindings</a></li><li><a shape="rect" href="service-routing.html">Service Routing</a></li><li><a shape="rect" href="dynamic-languages.html">Dynamic Languages</a></li><li><a shape="rect" href="ws-support.html">WS-* Support</a></li><li><a shape="rect" href="advanced-integration.html">Advanced Integration</a></li><li><a shape="rect" href="deployment.html">Deployment</a></li><li><a shape="rect" href="schemas-and-namespaces.html">Use of Schemas and Namespaces</a></li></ul><hr><ul class="alternate"><li><p>Search</p></li></ul><form enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box" action="http://www.google.com/cse">
<div>
<input type="hidden" name="cx" value="002890367768291051730:o99qiwa09y4">
<input type="hidden" name="ie" value="UTF-8">
<input type="text" name="q" size="21">
<input type="submit" name="sa" value="Search">
</div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script><hr><ul class="alternate"><li><a shape="rect" href="http://cxf.apache.org/javadoc/latest/">API 3.2.x (Javadoc)</a></li><li><a shape="rect" href="http://cxf.apache.org/javadoc/latest-3.1.x/">API 3.1.x (Javadoc)</a></li><li><a shape="rect" href="http://cxf.apache.org/">CXF Website</a></li></ul><p>&#160;</p><p><a shape="rect" class="external-link" href="http://www.apache.org/events/current-event.html"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://www.apache.org/events/current-event-125x125.png" data-image-src="http://www.apache.org/events/current-event-125x125.png"></span></a></p></div>
<!-- NavigationBar -->
</div>
</div>
</div>
</div>
</td>
<td height="100%">
<!-- Content -->
<div class="wiki-content">
<div id="ConfluenceContent"><h1 id="StandaloneHTTPTransport-ConfiguringSSL">Configuring SSL</h1><p>To configure the standalone HTTP transport to use SSL, you'll need to add an &lt;http:destination&gt; definition to your XML configuration file. See the <a shape="rect" href="configuration.html">Configuration</a> guide to learn how to supply your own XML configuration file to CXF. If you are already using Spring, this can be added to your existing beans definitions. For more information about configuring TLS, see the <a shape="rect" href="https://cwiki.apache.org/confluence/display/CXF20DOC/TLS+Configuration">Configuring TLS</a> page.</p><p>Destinations in CXF are responsible for listening for server side requests.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">&lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sec="http://cxf.apache.org/configuration/security"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xsi:schemaLocation="
http://cxf.apache.org/configuration/security
http://cxf.apache.org/schemas/configuration/security.xsd
http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://cxf.apache.org/transports/http-jetty/configuration
http://cxf.apache.org/schemas/configuration/http-jetty.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"&gt;
&lt;http:destination name="{http://apache.org/hello_world}GreeterImplPort.http-destination"&gt;
&lt;/http:destination&gt;
&lt;httpj:engine-factory bus="cxf"&gt;
&lt;!-- you just need to specify the TLS Server configuration for the certain port --&gt;
&lt;httpj:engine port="9003"&gt;
&lt;httpj:tlsServerParameters&gt;
&lt;sec:keyManagers keyPassword="password"&gt;
&lt;sec:keyStore type="JKS" password="password"
file="src/test/java/org/apache/cxf/systest/http/resources/Tarpin.jks"/&gt;
&lt;/sec:keyManagers&gt;
&lt;sec:trustManagers&gt;
&lt;sec:keyStore type="JKS" password="password"
file="src/test/java/org/apache/cxf/systest/http/resources/Truststore.jks"/&gt;
&lt;/sec:trustManagers&gt;
&lt;sec:cipherSuitesFilter&gt;
&lt;!-- these filters ensure that a ciphersuite with
export-suitable or null encryption is used,
but exclude anonymous Diffie-Hellman key change as
this is vulnerable to man-in-the-middle attacks --&gt;
&lt;sec:include&gt;.*_EXPORT_.*&lt;/sec:include&gt;
&lt;sec:include&gt;.*_EXPORT1024_.*&lt;/sec:include&gt;
&lt;sec:include&gt;.*_WITH_DES_.*&lt;/sec:include&gt;
&lt;sec:include&gt;.*_WITH_AES_.*&lt;/sec:include&gt;
&lt;sec:include&gt;.*_WITH_NULL_.*&lt;/sec:include&gt;
&lt;sec:exclude&gt;.*_DH_anon_.*&lt;/sec:exclude&gt;
&lt;/sec:cipherSuitesFilter&gt;
&lt;sec:clientAuthentication want="true" required="true"/&gt;
&lt;/httpj:tlsServerParameters&gt;
&lt;/httpj:engine&gt;
&lt;/httpj:engine-factory&gt;
&lt;/bean&gt;
</pre>
</div></div><h1 id="StandaloneHTTPTransport-Addthestaticcontentpagesintothejettyserver">Add the static content pages into the jetty server</h1><p>The CXF standalone http transport is based on the jetty server. The code below shows how to get the jetty server from the destination and how to add the static content path to the jetty server.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default"> // get the jetty server form the destination
EndpointInfo ei = new EndpointInfo();
ei.setAddress(serviceFactory.getAddress());
Destination destination = df.getDestination(ei);
JettyHTTPDestination jettyDestination = (JettyHTTPDestination) destination;
ServerEngine engine = jettyDestination.getEngine();
Handler handler = engine.getServant(new URL(serviceFactory.getAddress()));
org.mortbay.jetty.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);
</pre>
</div></div><h1 id="StandaloneHTTPTransport-ConfiguringStandaloneJettyinOSGi">Configuring Standalone Jetty in OSGi</h1><p>An OSGi application can use the standalone transport by incorporating&#160;cxf-rt-transports-http-jetty, which is an OSGi bundle, and&#160;creating<br clear="none">services with endpoint URLs like <code>http://0.0.0.0:8181/rest/v1/entities</code>.&#160;<br clear="none"><br clear="none">If your application needs to configure Jetty, is has to communicate with CXF's mechanism for this purpose, which lives in <br clear="none"><code>org.apache.cxf.transport.http_jetty.osgi.HTTPJettyTransportActivator</code>.<br clear="none"><br clear="none">CXF allows an application to use different configuration parameters for different 'engines'. An engine is <br clear="none">specified by three properties:<br clear="none"><br clear="none"></p><ul><li>HTTP vs. HTTPS (protocol)</li><li>host</li><li>port</li></ul><p><br clear="none">For each endpoint, CXF allows you to specify:<br clear="none"><br clear="none"></p><ul><li>sessionSupport</li><li>continuationsEnabled</li><li>reuseAddress</li><li>maxIdleTime</li><li>a giant, complex, raft of TLS parameters for HTTPS.</li></ul><p><br clear="none">Each of these engines is a shared resource, in that many endpoints can coexist on an engine. Thus, these shared<br clear="none">parameters can't be configured as part of launching an endpoint.<br clear="none"><br clear="none">Instead, CXF (in HTTPJettyTransportActivator), creates an OSGi <code>ManagedServiceFactory</code>. Usually, a managed service<br clear="none">factory is a creature that creates multiple OSGi services on demand, each with a particular configuration. <br clear="none">CXF doesn't really do that. Instead, each time that an application publishes a configuration, CXF sets the parameters<br clear="none">for the engine described by the configuration properties.<br clear="none"><br clear="none">Concretely, if an application calls the <code>createFactoryConfiguration</code>&#160;method of the `ConfigurationAdmin` service for PID<br clear="none">`org.apache.cxf.http.jetty`, CXF looks in the properties. It expects to find `host` and `port`. If it finds<br clear="none">any TLS parameters, it configures for HTTPS. If not, it configures for HTTP. It then applies all the other parameters<br clear="none">to the engine for that [protocol,host,port] triple.</p><p>If your application needs to create such a configuration and then modify if (all before CXF actually starts up the engine), you must use code like:</p><pre><span style="color: rgb(128,128,128);">configurationAdmin.listConfigurations(String.format("(&amp;(service.factoryPid=%s)(%s=%s))", <br clear="none"></span><span style="color: rgb(128,128,128);"> parsed[0], ConfigurationFileReaderImpl.INSTANCE_ID, parsed[1]));</span></pre><p>&#160;</p><p>to locate the configuration you created before, where "ConfigurationFileReaderImpl.INSTANCE_ID" is just an example of how you would use a property of your own choice to uniquely specify the configuration.</p><p>&#160;</p><p>&#160;</p></div>
</div>
<!-- Content -->
</td>
</tr>
</table>
</td>
<td id="cell-2-2" colspan="2">&nbsp;</td>
</tr>
<tr>
<td id="cell-3-0">&nbsp;</td>
<td id="cell-3-1">&nbsp;</td>
<td id="cell-3-2">
<div id="footer">
<!-- Footer -->
<div id="site-footer">
<a href="http://cxf.apache.org/privacy-policy.html">Privacy Policy</a> -
(<a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=49945">edit page</a>)
(<a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49945&amp;showComments=true&amp;showCommentArea=true#addcomment">add comment</a>)<br>
Apache CXF, CXF, Apache, the Apache feather logo are trademarks of The Apache Software Foundation.<br>
All other marks mentioned may be trademarks or registered trademarks of their respective owners.
</div>
<!-- Footer -->
</div>
</td>
<td id="cell-3-3">&nbsp;</td>
<td id="cell-3-4">&nbsp;</td>
</tr>
<tr>
<td id="cell-4-0" colspan="2">&nbsp;</td>
<td id="cell-4-1">&nbsp;</td>
<td id="cell-4-2" colspan="2">&nbsp;</td>
</tr>
</table>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-4458903-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>