(i) Release of WebService services through Xfire 1. Add Xfire related jar packages (Maven for example): <dependency> <groupid>org.codehaus.xfire</grou Pid> <artifactId>xfire-all</artifactId> <version>1.2.6</version> </dependency>2. Configuration web.xml <servlet> < servlet-name>xfireservlet</servlet-name> <servlet-class >org.codehaus.xfire.transport.http.XFireConfigurableServlet</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> < servlet-name>xfireservlet</servlet-name> <url-pattern> /services/*</url-pattern>//Service Release match address </servlet-mapping>3. Create a service interface &NBSP;&NBSP;&NBSp; package Demo; public Interface Servertest { void Say (String str); } 4. Creating an implementation class implementationServertestpackage Demo;public class Servertestimpl implements Servertest {public void Say (String str) {System. Out.println (str); }}5. Definition Services.xml--[Web-inf\classes\meta-inf\xfire ] Publish WebService Configuration No this file need to create <?xml version= "1.0" encoding= "UTF-8"? ><beans xmlns= "/http xfire.codehaus.org/config/1.0 "> <service> <name>Test</name> //define the publication name of the WebService <namespace>haople</namespace> //defines the WebService namespace <serviceclass>demo. servertest</serviceclass> //Interface Classes < Implementationclass>demo. servertestimpl</implementationclass> //Implementation Classes </service> </beans> After starting service: Access http://127.0.0.1:8080/demo/ SERVICES/TEST?WSDL (ii) Xfire Client Call WebService service method one: package demo;import org. Codehaus.xfire.client.xfireproxyfactory;import Org.codehaus.xfire.service.service;import Org.codehaus.xfire.service.binding.objectservicefactory;public class Clienttest { public static void Main (string[] args) { try { service Service=new objectservicefactory (). Create (Servertest.class); Create service servertest test= (servertest) New Xfireproxyfactory (). Create (Service, " Http://127.0.0.1:8080/demo/services/Test "); Proxy Service (not WSDL address here) Test.say ("Hello word!"); Execution methods } catch (Exception e) { & Nbsp;e.printstacktrace (); } } } Method Two: Package Demo;import Java.net.url;import Org.codehaus.xfire.client.client;public class Clienttest { public static void Main (string[] ARGS) { try { client client=new Client (New URL ("http://127.0.0.1:8080/demo/services/Test?wsdl")); The WSDL address is accessed here client.invoke ("Say", New object[]{"Hello World! "}); The first parameter is the execution method name, the second parameter is the executed argument, the return is object[] } catch (Exception e) { e.printstacktrace (); } }}
Xfire Demo Instance