JAVA6 WebService using Complex objects

Source: Internet
Author: User
Tags tostring

Complex objects can represent more powerful semantics than simple objects, and here's a look at how complex object parameters are used in Java6 WebService.

Here the parameters are divided into two classes, one is the incoming parameter, the other is the return value.

Complex objects are not as simple as they think, and there are some mystery. Take a look at the example:

1, development services, all in the service side

package lavasoft.server;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
/**
* Java6开发的WebService服务端
*
* @author leizhimin 2009-11-16 10:24:13 
*/
@WebService
public class Java6WS {
         //返回一个复杂对象
         public UserBean doSomething1(String username, String address, boolean flag) {
                 return new UserBean(username, address, flag);
         }
         //接收一个复杂对象
         public String doSomething2(Foo foo) {
                 return foo.toString();
         }
         public static void main(String[] args) {
                 //发布一个WebService
                 Endpoint.publish("http://192.168.14.117:9999/java6ws/Java6WS", new Java6WS());
         }
}

Package Lavasoft.server
/**
* User Information
*
* @author leizhimin 2009-11-16 16:43:35
*/
Public C          Lass UserBean {
Private String username;
Private String address;
Private Boolean flag;
Public UserBean () {
}
Public UserBean (string username, string address, Boolean FLA                  g) {
This.username = Username;
this.address = address;
This.flag = flag;         
}
Public String getusername () {
return username
        
public void Setusername (String username) {
This.username = Username;
        
Public String getaddress () {
return address;
        
public void setaddress (String address) {
This.address = address;
               
Public boolean Isflag () {
  return flag;         
}
public void Setflag (Boolean flag) {
This.flag = flag;
                                
@Override
Public String toString () {
return "userbean{" +
 "Username= '" + username + ' \ ' +
", address= '" + address + ' \ ' +
", flag=" + Flag +
'} ';
}
}

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.