Getting started with xfire-based Web Services Development Using myeclipse

Source: Internet
Author: User

Today, the technology is updated too fast, so you will miss a lot of things. Today I spent some time researching xfire, but when I finished the demo, when Baidu found that xfire had been updated, cxf, as the next-generation xfire product, would completely replace xfire. It seems that I am outdated. Since the demo has been completed, share it with me, although cxf has started to operate, xfire will still occupy a certain market in a short time. As for why I didn't select axis, I chose xfire because it was too difficult to get started with axis and heard it was slow. As a first developer of Web Services, I tried to write the most concise sample code to get started. I just wrote a super simple example, but a wide range of examples won't work, good tools are always much better than manual coding. Let's talk about development tools. At first I wanted to use WTP, because I was trying to give up myeclipse. I vaguely remember that WTP's new project contains the Web Services option, so after some attempts, we found that WTP is based on axis, which is depressing. Only myeclipse is picked up. You may find that there is a Web Services Project option in the new project wizard dialog box of myeclipse. The following describes it step by step: 1. new-> Project-> myeclipse-> JAVA enterprise projects-> Web Service Project-> name the project, and I name it webservicesdemo, in Web Service & J2EE details, select xfire (Deprecated). Note that I did not see it when I wrote the demo. 2. click Next and enter the Servlet Information used to provide the service. Because I keep the default value for the first attempt, we recommend that you download the dependent jar package from the official website, do not use what myeclipse provides. Official Website address http://xfire.codehaus.org/download xfire-distribution-1.2.6.zip and xfire-all-1.2.6.jar dependency package introduction http://xfire.codehaus.org/Dependency+Guide here there is an introduction to those packages that must be cited that can be cited. Click Finish after you import the package. 3. Compile the test code: PackageCom. syj. WS;/*** <p> title: Service Interface </P> *** <p> * copyright: Reprinted please indicate the source http://blog.csdn.net/sunyujia/ * </P> ** @ AuthorSun Xiaojia * @ MainSunyujia@yahoo.cn * @ DateJul13, 200812: 25: 41pm */ Public InterfaceMyserver { PublicString getteststr ();} PackageCom. syj. WS;/**** <p> * Title: service implementation * </P> ** <p> * copyright: Reprinted please indicate the source http://blog.csdn.net/sunyujia/ * </P> ** @ AuthorSun Xiaojia * @ MainSunyujia@yahoo.cn * @ DateJul13, 200812: 26: 19 pm */ Public ClassMyserverimpl ImplementsMyserver { PublicString getteststr (){ Return"This is Demo" ;}} 4. Configure services. xml. This button was found before you tried web services, but I still don't know its actual use yesterday. Click the first one here to generate related configurations in services. xml. Later, the second client program will be generated. The content of services. xml generated is as follows <? XML version = "1.0" encoding = "UTF-8"?> <Beans xmlns = "http://xfire.codehaus.org/config/1.0"> <service> <Name> demo </Name> <serviceclass> COM. syj. WS. myserver </serviceclass> <implementationclass> COM. syj. WS. myserverimpl </implementationclass> <style> wrapped </style> <use> literal </use> <scope> application </scope> </service> </beans> 5. publish the application to Tomcat and use myeclipse to publish the application. Note: Normally services. xml should be copied to the WEB-INF/classes/META-INF/xfire directory using a browser to access http: // 127.0.0.1: 8080/webservicesdemo/services/demo? If the WSDL file is displayed, the operation is successful.

Write client programs

First, use myeclipse to generate the client code. As mentioned above, it is similar to generating the services configuration. To generate a client, make sure that Tomcat is the client code generated by enabling status testing.
publicstaticvoid main(String[] args) {        DemoClient client = new DemoClient();        DemoPortType service = client.getDemoHttpPort();        System.out.println(service.getTestStr());        System.out.println("test client completed");        System.exit(0);    }

Wait a moment after running democlient (Web Services is really slow). The console prints this is demotest client completed, indicating that the execution is successful! Finally, we recommend some information http://xfire.codehaus.org/Quick+Starthttp://xfire.codehaus.org/Dependency+Guide

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.