Metro In-VM Transport

In-VM local transport allows TCP loop-back like SOAP communication between the client and the server in the same virtual machine. It is primarily designed to enable testing of web service endpoints without using a fully-fledged web container.

Using Maven

In your pom file you would need to add in-vm transport to the test classpath and after calling Wsgen and Wsimport you can use it in your tests.

<project>
    ...
    <dependencies>
        ...
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-local-transport</artifactId>
            <version>2.2.8</version>
            <scope>test</scope>
        </dependency>
        ...
    </dependencies>
    ...
</project>
        

See the sample maven pom.xml and the complete maven based sample here.

Using Ant

In your ant build file you would need to define classpath to include Metro jars and call Wsimport and Wsgen targets.

 <!-- setup Metro runtime classpath -->
<path id="runtime.cp">
    <fileset dir="${lib.home}" includes="*.jar" excludes="webservices-tools.jar"/>
    <fileset dir="${basedir}/../lib" includes="invm-transport.jar"/>
    <pathelement location="${build.classes}"/>
</path>

<!-- setup Metro tooltime classpath -->
<path id="tool.cp">
    <path refid="runtime.cp"/>
    <pathelement location="${lib.home}/webservices-tools.jar"/>
</path>

<!-- Setup Wsimport ant task. You would use this task in WSDL to Java case
to compile a WSDL and generate Java classes.
-->
<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
    <classpath refid="tool.cp"/>
</taskdef>

<!-- Setup Wsgen ant task. You would use this task in Java to WSDL case to
generate a WSDL or wrapper classes.
-->
<taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen">
    <classpath refid="tool.cp"/>
</taskdef>

See the sample ant build script and the complete ant based sample here.

Using Spring

To use this transport with , you need to declare one more namespace URI:

<beans ...
  xmlns:wsl="http://jax-ws.java.net/spring/local-transport"
  xsi:schemaLocation="
    http://jax-ws.java.net/spring/local-transport
    http://jax-ws.java.net/spring/local-transport.xsd">
        
Then you can export a bunch of services by using an ID of your choice:
<wsl:bindings id="test-local-endpoint">
  <wsl:endpoints>

    <ws:service ... />       <!-- either define a service inline -->
    <ref bean="myService" /> <!-- or refer to another bean -->
  </wsl:endpoints>
</wsl:bindings>
        
These services can be accessed by setting the endpoint address URI as in-vm://test-local-endpoint/ (the spring bean ID becomes a part of the URI.) If multiple endpoints are deployed in a single local transport server, you can distinguish them by using the local name of the port QName as the query parameter, like ?port1

Source Repository

In-Vm transport code lives in JAX-WS RI code base. The module in the JAX-WS RI sources is transport/local.

Binaries

You can get the In-Vm transport jar from here and put in the Metro or JAX-WS RI classpath, tryout and let us know.

Terms of Use; Privacy Policy; Copyright ©2013-2014 (revision 20131025.e7cbc9d)
 
 
Close
loading
Please Confirm
Close