Date: Tue, 19 Mar 2024 01:07:57 +0000 (UTC) Message-ID: <1548226517.52590.1710810477723@cwiki-he-fi.apache.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_52589_1401939412.1710810477723" ------=_Part_52589_1401939412.1710810477723 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
CXF includes a "local" transport. This transport allows you to send mess= sages more efficiently inside a JVM. The messages will serialized and piped= from one endpoint to another.
The local transport supports URIs of the structure "local://{endpoint_na= me}" where {endpoint_name} is any set of characters. To use the local trans= port you simply need to set your address to a local URI.
This code shows how to publish on a local endpoint:
import javax.= xml.ws.Endpoint; HelloServiceImpl serverImpl =3D new HelloServiceImpl(); Endpoint.publish("local://hello", serverImpl);
Or with XML:
<beans xml= ns=3D"http://www.springframework.org/schema/beans" xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" xmlns:simple=3D"http://cxf.apache.org/simple" xmlns:soap=3D"http://cxf.apache.org/bindings/soap" xsi:schemaLocation=3D" http://www.springframework.org/schema/beans http://www.springframework.org/= schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configura= tion/soap.xsd http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd"> <import resource=3D"classpath:META-INF/cxf/cxf.xml"/> <import resource=3D"classpath:META-INF/cxf/cxf-extension-soap.xml"/>= ; =20 <bean class=3D"org.apache.cxf.transport.local.LocalTransportFactory" l= azy-init=3D"false"> <property name=3D"transportIds"> <list> <value>http://cxf.apache.org/transports/local</value= > <value>http://schemas.xmlsoap.org/soap/http</value&g= t; <value>http://schemas.xmlsoap.org/wsdl/soap/http</va= lue> </list> </property> </bean> =20 <jaxws:endpoint name=3D"helloWorld" address=3D"local://hello" implemen= tor=3D"org.example.HelloServiceImpl"/> </beans>
Before you use the local transport , you need to register the default so= ap transportURI with the local transport factory in the bus
Bus bus =3D BusFactory.getDefaultBus(); LocalTransportFactory localTransport =3D new LocalTransportFactory(); dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", loca= lTransport); dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http",= localTransport); dfm.registerDestinationFactory("http://cxf.apache.org/bindings/xformat", lo= calTransport); dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", lo= calTransport); ConduitInitiatorManager extension =3D bus.getExtension(ConduitInitiatorMana= ger.class); extension.registerConduitInitiator("http://cxf.apache.org/transports/local"= , localTransport); extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/ht= tp", localTransport); extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", = localTransport); extension.registerConduitInitiator("http://cxf.apache.org/bindings/xformat"= , localTransport);
You can also pass in a local://address to the server and client factory = beans:
import org.ap= ache.cxf.frontend.ServerFactoryBean; ServerFactoryBean sf =3D new ServerFactoryBean(); sf.setAddress("local://hello"); sf.setServiceBean(new HelloServiceImpl()); sf.setServiceClass(HelloService.class); // Optionally specify the service i= nterface sf.create();
import org.ap= ache.cxf.frontend.ClientProxyFactoryBean; ClientProxyFactoryBean cf =3D new ClientProxyFactoryBean(); cf.setAddress("local://hello"); cf.setServiceClass(HelloService.class); // Optionally specify the service i= nterface HelloService h =3D (HelloService) cf.create();