SOAP协议分为两个版本 1.1 1.2
默认支持1.1
实现方式:
1.编写接口
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") @BindingType(value =SOAPBinding.SOAP12HTTP_BINDING) public class ServiceTestImpl implements ISerivceTest { @Override public String sayHello(String name) { return "hello:" + name; } }
注意这个需要写在实现类上。
3.需要增加类
<dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-jaxws_2.2_spec</artifactId> <version>1.0</version> </dependency>
4.soap 包格式
soap1.1
<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.2
<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>
时间: 2024-11-05 22:32:17