First, the jar used is first imported into the project,
Xbean-spring-2.8.jar, Wsdl4j-1.6.1.jar, Commons-httpclient-3.0.jar, Commons-codec-1.3.jar, Xfire-all-1.2.6.jar, Xmlschema-1.1.jar, Spring-1.2.6.jar,
Commons-logging-1.0.4.jar, Jdom-1.0.jar, these 9 packages are xfire implement server-side WebService primary packages that contain access WebService and build WebService
1. Access the WebService file:
Public Static throws exception{ new Client (new URL (URL_SPAC)); Client.settimeout (the); // access exceeds 5 seconds timeout // set methods and parameters for access Object[] results = Client.invoke (method, params); return results[0].tostring ();}
Very simple, just a few lines of code will be done. Url_space is Http://xxx:8080/WebServices/xxx.asmx?WSDL, is WebService's access address, but must go to? WSDL
Temporarily does not resolve the call side using array parameters.
2. Generate WebService
Create a new Meta-inf/xfire/services.xml file under SRC, which is written in the file
<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "http://xfire.codehaus.org/config/1.0"> <Service> <name>WebService name</name> <ServiceClass>Java Interface class path</ServiceClass> <ImplementationClass>Java Interface Implementation Classpath</ImplementationClass> <style>Wrapped</style> < Use>Literal</ Use> <Scope>Application</Scope> </Service></Bean>
Configure the Servlet class to start loading Xfire in Web. XML with the following code:
<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> <servlet-mapping> <Servlet-name>Xfireservlet</Servlet-name> <Url-pattern>/services/*</Url-pattern> </servlet-mapping>
In this way, a webservice that accesses the name WebService name starts up.
Use WebService in Java to simplify development (Xfire's WebService)