Use WebService in Java to simplify development (Xfire's WebService)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.