新建项目
pom
配置类
启动类配置类WSDL接口soap1.1协议实现类soap1.2协议实现类
新建项目打开idea,新建Springboot项目 File->New->Project->选择Spring Initializr->next
的
配置org.springframework.boot spring-boot-starter-parent2.2.1.RELEASE com.demo demo0.0.1-SNAPSHOT jar 1.8 3.2.4 1.4.8 org.springframework.boot spring-boot-starterorg.springframework.boot spring-boot-starter-weborg.springframework.boot spring-boot-starter-testtest org.springframework.boot spring-boot-starter-loggingorg.apache.cxf cxf-rt-frontend-jaxws${cxf.version} org.apache.cxf cxf-rt-transports-http${cxf.version} com.thoughtworks.xstream xstream${xstream.version} com.alibaba.nacos nacos-client1.2.1 javax.json javax.json-api1.1 org.springframework.boot spring-boot-maven-pluginorg.apache.maven.plugins maven-jar-plugin3.1.2 application.properties default.properties demo
server.port=8058 spring.application.name=demo server.tomcat.uri-encoding=UTF-8类 启动类
package com.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication{
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
配置类
package com.demo.ws.wsInterface;
import com.demo.ws.wsInterface.impl.WebServicesImpl1_1;
import com.demo.ws.wsInterface.impl.WebServicesImpl1_2;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.xml.ws.Endpoint;
@Configuration
public class WebServicesConfiguration {
@Bean(name = Bus.DEFAULT_BUS_ID)
public SpringBus springBus() {
return new SpringBus();
}
@Bean(name = "wbsBean")
public ServletRegistrationBean dispatcherServlet() {
ServletRegistrationBean wbsServlet = new ServletRegistrationBean(new CXFServlet(), "/demo
@Bean
public Endpoint endpointPurchase1_1(SpringBus springBus, WebServicesImpl1_1 service) {
EndpointImpl endpoint = new EndpointImpl(springBus, service);
endpoint.publish("/services");
System.out.println("soap1.1服务发布成功!地址为:http://127.0.0.1:8058/demo/services");
return endpoint;
}
@Bean
public Endpoint endpointPurchase1_2(SpringBus springBus, WebServicesImpl1_2 service) {
EndpointImpl endpoint = new EndpointImpl(springBus, service);
endpoint.publish("/services");
System.out.println("soap1.2服务发布成功!地址为:http://127.0.0.1:8058/demo/services");
return endpoint;
}
}
WSDL接口
package com.demo.ws.wsInterface;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService
public interface IWebServices {
@WebMethod(action = "http://wsInterface.ws.demo.com/MethodName")
String MethodName(@WebParam(targetNamespace = "http://wsInterface.ws.demo.com/") String inParamXml);
}
soap1.1协议实现类
package com.demo.ws.wsInterface.impl;
import com.demo.ws.wsInterface.IWebServices;
import org.springframework.stereotype.Service;
import javax.jws.WebService;
import javax.xml.ws.BindingType;
import javax.xml.ws.soap.SOAPBinding;
@BindingType(value = SOAPBinding.SOAP11HTTP_BINDING)
@WebService
@Service
public class WebServicesImpl1_1 implements IWebServices{
@Override
public String WebMethod(String inParamXml) {
return "";
}
}
soap1.2协议实现类
package com.demo.ws.wsInterface.impl;
import com.demo.ws.wsInterface.IWebServices;
import org.springframework.stereotype.Service;
import javax.jws.WebService;
import javax.xml.ws.BindingType;
import javax.xml.ws.soap.SOAPBinding;
@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
@WebService
@Service
public class WebServicesImpl1_2 implements IWebServices{
@Override
public String WebMethod(String inParamXml) {
return "";
}
}



