Introduction to JAVA6 Development WebService

Source: Internet
Author: User
Tags soap xmlns wsdl

Used to develop Web service applications using CXF, AXIS2, Xfire, etc., the benefits are wide and flexible, and another important reason is that our production environment is JAVA5.

But in fact Java6 has been supported in Java development WebService applications, and very convenient. This greatly reduces the cost of installing the project, because the choice of open source framework relies on a large number of third-party packages, and the size of the program doubles.

The following is an introductory example of a JAVA6 development Web service.

package lavasoft;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
/**
* Java6开发WebService入门
*
* @author leizhimin 2009-11-13 16:10:44
*/
@WebService
public class Java6WebService {
         /**
          * Web服务中的业务方法
          *
          * @return 一个字符串
          */
         public String doSomething() {
                 return "Hello Java6 WebService!";
         }
         public static void main(String[] args) {
                 //发布一个WebService
                 Endpoint.publish("http://192.168.14.117:8080/java6ws/lavasoft.Java6WebService", new Java6WebService());
         }
}

After running, accessing HTTP://192.168.14.117:8080/JAVA6WS/LAVASOFT.JAVA6WEBSERVICE?WSDL in the browser will get the WSDL as follows:

<?xml version= "1.0" encoding= UTF-8 "?>"


<!--published by Jax-ws RI at Http://jax-ws.dev.java.net. Ri ' s version is Jax-ws ri 2.1.6 in JDK 6.


-->


<!--generated by Jax-ws RI at Http://jax-ws.dev.java.net. Ri ' s version is Jax-ws ri 2.1.6 in JDK 6.


-->


<definitions xmlns:soap= "http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns= "http://lavasoft/"


xmlns:xsd= "Http://www.w3.org/2001/XMLSchema" xmlns= "http://schemas.xmlsoap.org/wsdl/"


targetnamespace= "http://lavasoft/" name= "Java6webserviceservice" >


<types>


<xsd:schema>


<xsd:import namespace= "http://lavasoft/"


schemalocation= "Http://192.168.14.117:8080/java6ws/lavasoft.Java6WebService?xsd=1"/>


</xsd:schema>


</types>


<message name= "dosomething" >


<part name= "parameters" element= tns:dosomething "/>"


</message>


<message name= "Dosomethingresponse" >


<part name= "parameters" element= tns:dosomethingresponse "/>"


</message>


<porttype name= "Java6webservice" >


<operation name= "dosomething" >


<input message= "tns:dosomething"/>


<output message= "Tns:dosomethingresponse"/>


</operation>


</portType>


<binding name= "java6webserviceportbinding" type= "Tns:java6webservice" >


<soap:binding transport= "http://schemas.xmlsoap.org/soap/http" style= "document"/>


<operation name= "dosomething" >


<soap:operation soapaction= ""/>


<input>


<soap:body use= "literal"/>


</input>


<output>


<soap:body use= "literal"/>


</output>


</operation>


</binding>


<service name= "Java6webserviceservice" >


<port name= "Java6webserviceport" binding= "tns:java6webserviceportbinding" >


<soap:address location= "Http://192.168.14.117:8080/java6ws/lavasoft. Java6webservice "/>


</port>


</service>


</definitions>

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.