I would like to create a test for calling a service that is created from a Java
first approach. I have tried the below test code as an example without
success. I get an error complaining about the local protocol.
java.net.MalformedURLException: unknown protocol: local
at java.net.URL.<init>(URL.java:574)
at java.net.URL.<init>(URL.java:464)
at org.apache.cxf.tools.util.URLFactory.createURL(URLFactory.java:42)
at org.apache.cxf.tools.util.URLFactory.createURL(URLFactory.java:36)
Back in the Xfire days I could use the XFireProxyFactory to create a service
from an interface using the local transport. I have even tried using the
JaxWsClientFactoryBean.create but I got a ClassCastException.
Any suggestions on how to use a local client would be very helpful. I'd prefer
to avoid embedded Jetty and http for now if possible.
Thanks,
Brandon
@Before
public void before() throws Exception {
endpoint = Endpoint.publish("local://Echo", new EchoImpl());
URL wsdl = URLFactory.createURL("local://Echo?wsdl");
//URL wsdl = new URL("local://Echo?wsdl"); //didn't work. complained that
local was unknown
QName serviceName = new QName("org.foo", "EchoImpl");
Service service = Service.create(wsdl, serviceName);
echoClient = service.getPort(Echo.class);
}
@Test
public void testService() {
Assert.assertEquals("Hello World", echoClient.echo("Hello World"));
}
@After
public void after() {
endpoint.stop();
}