SOAP協議分爲兩個版本 1.1 1.2java
默認支持1.1apache
實現方式:ide
1.編寫接口xml
import javax.jws.WebService; @WebService public interface ISerivceTest { String sayHello(String name); }
2.編寫實現方式接口
import javax.jws.WebService; import javax.xml.ws.BindingType; import javax.xml.ws.soap.SOAPBinding; import com.hotent.mini.ext.service.ISerivceTest; @WebService(serviceName="HelloWorld") public class ServiceTestImpl implements ISerivceTest { @Override public String sayHello(String name) { return "hello:" + name; } }
注意這個須要寫在實現類上。it
3.須要增長類io
<dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-jaxws_2.2_spec</artifactId> <version>1.0</version> </dependency>
4.soap 包格式class
soap1.1import
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.ext.mini.hotent.com/"> <soapenv:Header/> <soapenv:Body> <ser:sayHello> <!--Optional:--> <arg0>?</arg0> </ser:sayHello> </soapenv:Body> </soapenv:Envelope>
soap1.2service
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="http://service.ext.mini.hotent.com/"> <soap:Header/> <soap:Body> <ser:sayHello> <!--Optional:--> <arg0>dddd</arg0> </ser:sayHello> </soap:Body> </soap:Envelope>