ibm.com/developerWorks
Presented by developerWorks, your source for great tutorials
new HelloServiceLocator().getRemoteHelloService();
}
catch (javax.xml.rpc.ServiceException jre) {
if(jre.getLinkedCause()!=null)
jre.getLinkedCause().printStackTrace();
throw new AssertionFailedError("JAX RPC ServiceException caught: " + jre);
}
assertNotNull("binding is null", binding);
// Time out after a minute
binding.setTimeout(60000);
// Test operation
java.lang.String[] value = null;
value = binding.getGreetings();
// TBD validate results
}
}
You will use the above as an example to create your very own client.
Note that if you do not like the default packages that get created with
axis wsdl2java
, you can use a nested mapping tag to map a namespace to a
custom package name. For example:
output="gen.client"
testcase="true"
verbose="true"
url="${local.wsdl}" >
namespace="http://localhost:8080/ns/foobar"
package="rick.foobar" />
This would map the namespace
http://localhost:8080/ns/foobar
to package
rick.foobar
, which is much better than the default.
Write a Web service client for your EJB component
The code that Axis
wsdl2java
task generates is test code that is very specific to Axis.
To create a more portable client, you should use reflection to dynamically load the
Service Locator
as follows:
Page 20 of 33
Service enable EJB SessionBeans with the IBM ETTK
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved