XFire Java SOAP Framework Overview (excerpt: http://tech.it168.com/j/e/2006-10-28/200610281432707.shtml)
MyEclipse Web Services is based on the Xfire Java SOAP Framework and tools, and Xfire is an open-source Java SOAP Framework. It has a lightweight information processing module that is combined with soap information through Stax. Provides a simple API that works under Web services to support Pojo and schema development. Xfire supports Web Services standards,spring consolidation, supports JBI, supports JAXB, Xmlbeans,java 5, and Jax-ws. and supports HTTP, JMS, XMPP, in-memory transport protocols
First, environment configuration: MyEclipse7.0
JDK1.6
Second, create a web Service Project
1) Select File->new->other in MyEclipse, select Web Service Project
2) Project Name:webserviceserver,framework:xfire, other options default
3) Next, this step remains the default value
4) Project Library selection, select Xfire 1.2 Core Libraries
5) Finish, after successful creation, see the following project catalog:
6) After completing the above 5 steps, view Webroot/web-inf/web.xml
This indicates that when a/services/* request is encountered, Xfireconfigurableservlet will be used to handle
Third, create a web Service Code
1) Create Java CODE with File->new->other->web services->web Service Wizard
2) Choose to create a Web Service from Java class
3) Create the Hellowebservice.java, create the Com.service package with new, and the wizard will automatically create the corresponding interface class and implementation class for the project
After a successful creation, view the Webservices/services.xml and discover that the configuration file contains the following:
4) Modify Hellowebserviceimpl.java
Package com.service;
Generated by METEORWJ
public class Hellowebserviceimpl implements Ihellowebservice {
public string Example (String message) {
return Getauthor () + "," +message;
}
Private String Getauthor () {
return "METEORWJ";
}
}
Iv. deployment and testing of Websericeserver
1) Deploy Webserviceserver
In the Deployment Wizard, select Project, Server
2) Start the server
3) Test WebService
MyEclipse provides a Web service Explorer to test the Web service
Launch SOAP Web Services Explorer in the select list
4) Select WSDL mode
5) Select WSDL Main in the Explorer and enter it in the URL on the right
Http://localhost:9090/WebServiceServer/services/HelloWebService?WSDL, click "Go"
Where 9090 is the server port number, services is specified in the previous web. xml
Test succeeds if open WSDL file is displayed successfully in status
V. Create a WebService Client
After a few steps, we have successfully released a webservice, and now we need to create a client to invoke the service
1) Create Java project:webserviceclient
2) Introduction of MyEclipse Libraries
Right-click Webserviceclient->build path->add Libraries
Select Xfire 1.2 HTTP Client Libraries
3) Create Hellowebservice.java
Create Com.client.HelloWebService.java in src directory
Package com.client;
Import Java.net.URL;
Import org.codehaus.xfire.client.Client;
public class Hellowebservice {
public static void Main (string[] args) throws Exception
{
Client client = new Client (new URL ("http://localhost:9090/WebServiceServer/services/HelloWebService?wsdl"));
Object[] results = Client.invoke ("Example", new object[] {"Hello"});
System.out.println (String) results[0]);
}
}
4) Run Hellowebservice.java when confirming server startup
Right-click on Run As>java application to see the output shown in the console
WebService example of Xfire development under MyEclipse