个人心得:Axis2发布webservice

1.在pom.xml中添加对webservice的依赖

<dependency>
	<groupId>com.ibm.websphere.appserver</groupId>
	<artifactId>com.ibm.jaxws.thinclient</artifactId>
	<version>7.0</version>
	<scope>test</scope>
</dependency>

 

2.传入参数

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "requestType", namespace = "http://aaservice.services.aa.com.it/", propOrder = {
		"stuNumber","birthDay"})
public class requestType {
	@XmlElement(required = true)
	private String stuNumber;
	@XmlElement(required = true)
	@XmlSchemaType(name = "date")
	private XMLGregorianCalendar birthDay;
	public String getStuNumber() {
		return stuNumber;
	}
	public void setStuNumber(String stuNumber) {
		this.stuNumber = stuNumber;
	}
	public XMLGregorianCalendar getBirthDay() {
		return birthDay;
	}
	public void setBirthDay(XMLGregorianCalendar birthDay) {
		this.birthDay = birthDay;
	}
	
}

 

3.返回参数ResponseType.java

import java.util.Date;

public class ResponseType {
	private String stuNumber;
	private Date birthDay;
	public String getStuNumber() {
		return stuNumber;
	}
	public void setStuNumber(String stuNumber) {
		this.stuNumber = stuNumber;
	}
	public Date getBirthDay() {
		return birthDay;
	}
	public void setBirthDay(Date birthDay) {
		this.birthDay = birthDay;
	}	
}

 

4.接口StudentService.java

import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.ParameterStyle;
import javax.jws.soap.SOAPBinding.Style;
import javax.jws.soap.SOAPBinding.Use;

@WebService(name = "Student")
@SOAPBinding(style = Style.DOCUMENT, use = Use.LITERAL, parameterStyle = ParameterStyle.WRAPPED)
public interface StudentService {
	/**
	 * Create Student
	 */
	public ResponseType createStudent(@WebParam(name = "studentParam") requestType requestType);
	
}

 

5.实现类StudentServiceImpl.java

@WebService(serviceName = "StudentService", targetNamespace = "http://aaservice.services.aa.com.it/", endpointInterface = "it.com.aa.services.aaservice.StudentService")
public class StudentServiceImpl implements StudentService {

	/**
	 * Create Student	 
        */
	@Override
	public ResponseType createStudent(RequestType requestType) {
                 //逻辑代码
         }
}

 

你可能感兴趣的:(webservice)