接口协议说明:SOAP1.1协议
1.请求报文
2. 引入包
org.apache.cxf
cxf-spring-boot-starter-jaxws
3.2.4
3.服务类接口
@WebService
public interface ESBShareODMDataService {
@WebMethod
String nopWlData(@WebParam(name = "ServiceCode") String ServiceCode,
@WebParam(name = "UserName") String UserName,
@WebParam(name = "IpAddress") String IpAddress,
@WebParam(name = "RoleID") String RoleID,
@WebParam(name = "AuthCode") String AuthCode,
@WebParam(name = "EventID") String EventID,
@WebParam(name = "ServiceParas") ServiceParas ServiceParas);
4.服务类接口子类
@Slf4j
@WebService(targetNamespace = "http://esb.service.uip.nokia.com/",
endpointInterface = "com.nokia.uip.service.esb.ESBShareODMDataService")
@Component
public class ESBShareODMDataServiceImpl implements ESBShareODMDataService{
@Autowired
private DataCenterFtpFileMapper dataCenterFtpFileMapper;
@Override
public String nopWlData(String ServiceCode,
String UserName,
String IpAddress,
String RoleID,
String AuthCode,
String EventID,
ServiceParas ServiceParas) {
log.info("客户端发来的参数:{}",ServiceParas);
}
5.接收对象
import javax.xml.bind.annotation.XmlElement;
import java.util.List;
/**
* @auther DUJW
* @create 2020/3/10
*/
public class ServiceParas {
private List attribute;
@XmlElement
public List getAttribute() {
return attribute;
}
public void setAttribute(List attribute) {
this.attribute = attribute;
}
@Override
public String toString() {
return "ServiceParas{" +
"attribute=" + attribute.toString() +
'}';
}
}
import javax.xml.bind.annotation.XmlAttribute;
/**
* @auther DUJW
* @create 2020/3/10
*/
public class Attribute {
private String name;
private String value;
@XmlAttribute
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlAttribute
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String toString() {
return "Attribute{" +
"name='" + name + '\'' +
", value='" + value + '\'' +
'}';
}
}
6.配置类
import com.nokia.uip.service.esb.ESBShareODMDataService;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.xml.ws.Endpoint;
/**
* @auther DUJW
* @create 2020/3/10
*/
@Configuration
public class ESBShareODMDataConfig {
@Autowired
private Bus bus;
@Autowired
private ESBShareODMDataService esbShareODMDataService;
@Bean
public Endpoint endpoint(){
EndpointImpl endpoint = new EndpointImpl(bus,esbShareODMDataService);
endpoint.publish("/sendFtpInfo");
return endpoint;
}
}
7.访问
配置好后,启动服务器
http://localhost:8080/xxx/services/sendFtpInfo?WSDL
测试可以通过工具postman测试。
8.如果想把接收的@WebParam(name = "ServiceParas") ServiceParas ServiceParas改为@WebParam(name = "ServiceParas") String ServiceParas
需要把发送的报文字符串用
包含