首页 > 解决方案 > 从 RestController Spring,Java 8 使用 SOAP Web 服务

问题描述

对不起,很长的问题!

我有一个测试,使用 GET 动词和 JSON 使用服务,该服务使用 SOAP 服务和 XML。我需要翻译 JSON 以便使用 XML 来使用 SOAP 服务。

我的休息控制器

@Controller
public class CustomerController {
    
    @Autowired
    IEmpleadoService empleadoService;

    @Autowired
    EmpleadoValidator empleadoValidator;
    
    @RequestMapping(value = "create", method=RequestMethod.GET, consumes = "application/json", produces = "application/json")
    public String getCustomer( @RequestBody Empleado1 empleado1, BindingResult result, Model model) {
        empleadoValidator.validate(empleado1, result);
        if (result.hasErrors()) {
            System.out.println("We can't continue");
        }
        System.out.println("empleado1:" + empleado1);
        empleadoService.guardarEmpleado(empleado1);
        return "listar";
    }

}

现在我有一个服务接口:

public interface IEmpleadoService {
    public void guardarEmpleado(Empleado1 empleado1);
}

和实施...

@Service
public class EmpleadoServiceImpl implements IEmpleadoService {
    @Override
    public void guardarEmpleado(Empleado1 empleado1) {
        //INTERFACE SOAP SERVICE
        IWebService webService = new WebServiceImplService().getWebServiceImplPort();
        webService.create(empleado1);
    }
}

SOAP Service的URL是: http://localhost:8080/WebServiceImplService/WebServiceImpl?wsdl

生成的Empleado1

package org.bz.soap.client.service;

import javax.validation.constraints.NotEmpty;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;


/**
 * <p>Java class for empleado1 complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="empleado1"&gt;
 *   &lt;complexContent&gt;
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
 *       &lt;sequence&gt;
 *         &lt;element name="apellidos" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
 *         &lt;element name="cargo" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
 *         &lt;element name="fechaNacimiento" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/&gt;
 *         &lt;element name="fechaVinculacion" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/&gt;
 *         &lt;element name="id" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/&gt;
 *         &lt;element name="nombres" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
 *         &lt;element name="numeroDocumento" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
 *         &lt;element name="salario" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
 *         &lt;element name="tipoDocumento" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
 *       &lt;/sequence&gt;
 *     &lt;/restriction&gt;
 *   &lt;/complexContent&gt;
 * &lt;/complexType&gt;
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "empleado1", propOrder = {
    "apellidos",
    "cargo",
    "fechaNacimiento",
    "fechaVinculacion",
    "id",
    "nombres",
    "numeroDocumento",
    "salario",
    "tipoDocumento"
})
public class Empleado1 {

    protected Long id;
    @NotEmpty
    protected String nombres;
    @NotEmpty
    protected String apellidos;
    @NotEmpty
    protected String tipoDocumento;
    @NotEmpty
    protected String numeroDocumento;
    
    @XmlSchemaType(name = "dateTime")
    protected XMLGregorianCalendar fechaNacimiento;

    @NotEmpty
    @XmlSchemaType(name = "dateTime")
    protected XMLGregorianCalendar fechaVinculacion;

    @NotEmpty
    protected String cargo;

    @NotEmpty
    protected Double salario;

    /**
     * Gets the value of the apellidos property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getApellidos() {
        return apellidos;
    }

    /**
     * Sets the value of the apellidos property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setApellidos(String value) {
        this.apellidos = value;
    }

    /**
     * Gets the value of the cargo property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCargo() {
        return cargo;
    }

    /**
     * Sets the value of the cargo property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setCargo(String value) {
        this.cargo = value;
    }

    /**
     * Gets the value of the fechaNacimiento property.
     * 
     * @return
     *     possible object is
     *     {@link XMLGregorianCalendar }
     *     
     */
    public XMLGregorianCalendar getFechaNacimiento() {
        return fechaNacimiento;
    }

    /**
     * Sets the value of the fechaNacimiento property.
     * 
     * @param value
     *     allowed object is
     *     {@link XMLGregorianCalendar }
     *     
     */
    public void setFechaNacimiento(XMLGregorianCalendar value) {
        this.fechaNacimiento = value;
    }

    /**
     * Gets the value of the fechaVinculacion property.
     * 
     * @return
     *     possible object is
     *     {@link XMLGregorianCalendar }
     *     
     */
    public XMLGregorianCalendar getFechaVinculacion() {
        return fechaVinculacion;
    }

    /**
     * Sets the value of the fechaVinculacion property.
     * 
     * @param value
     *     allowed object is
     *     {@link XMLGregorianCalendar }
     *     
     */
    public void setFechaVinculacion(XMLGregorianCalendar value) {
        this.fechaVinculacion = value;
    }

    /**
     * Gets the value of the id property.
     * 
     * @return
     *     possible object is
     *     {@link Long }
     *     
     */
    public Long getId() {
        return id;
    }

    /**
     * Sets the value of the id property.
     * 
     * @param value
     *     allowed object is
     *     {@link Long }
     *     
     */
    public void setId(Long value) {
        this.id = value;
    }

    /**
     * Gets the value of the nombres property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getNombres() {
        return nombres;
    }

    /**
     * Sets the value of the nombres property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setNombres(String value) {
        this.nombres = value;
    }

    /**
     * Gets the value of the numeroDocumento property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getNumeroDocumento() {
        return numeroDocumento;
    }

    /**
     * Sets the value of the numeroDocumento property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setNumeroDocumento(String value) {
        this.numeroDocumento = value;
    }

    /**
     * Gets the value of the salario property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public Double getSalario() {
        return salario;
    }

    /**
     * Sets the value of the salario property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setSalario(Double value) {
        this.salario = value;
    }

    /**
     * Gets the value of the tipoDocumento property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getTipoDocumento() {
        return tipoDocumento;
    }

    /**
     * Sets the value of the tipoDocumento property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setTipoDocumento(String value) {
        this.tipoDocumento = value;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("Empleado1 [id=");
        builder.append(id);
        builder.append(", \nnombres=");
        builder.append(nombres);
        builder.append(", \napellidos=");
        builder.append(apellidos);
        builder.append(", \ntipoDocumento=");
        builder.append(tipoDocumento);
        builder.append(", \nnumeroDocumento=");
        builder.append(numeroDocumento);
        builder.append(", \nfechaNacimiento=");
        builder.append(fechaNacimiento);
        builder.append(", \nfechaVinculacion=");
        builder.append(fechaVinculacion);
        builder.append(", \ncargo=");
        builder.append(cargo);
        builder.append(", \nsalario=");
        builder.append(salario);
        builder.append("]");
        return builder.toString();
    }
}

IWebService界面_

package org.bz.soap.client.service;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.Action;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;


/**
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.3.2
 * Generated source version: 2.2
 * 
 */
@WebService(name = "IWebService", targetNamespace = "http://ws.soap.bz.org/")
@XmlSeeAlso({
    ObjectFactory.class
})
public interface IWebService {


    /**
     * 
     * @param arg0
     */
    @WebMethod
    @RequestWrapper(localName = "create", targetNamespace = "http://ws.soap.bz.org/", className = "org.bz.soap.client.service.Create")
    @ResponseWrapper(localName = "createResponse", targetNamespace = "http://ws.soap.bz.org/", className = "org.bz.soap.client.service.CreateResponse")
    @Action(input = "http://ws.soap.bz.org/IWebService/createRequest", output = "http://ws.soap.bz.org/IWebService/createResponse")
    public void create(
        @WebParam(name = "arg0", targetNamespace = "")
        Empleado1 arg0);

}

WebServiceImplService实施。

package org.bz.soap.client.service;

import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;


/**
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.3.2
 * Generated source version: 2.2
 * 
 */
@WebServiceClient(name = "WebServiceImplService", targetNamespace = "http://ws.soap.bz.org/", wsdlLocation = "http://localhost:8080/WebServiceImplService/WebServiceImpl?wsdl")
public class WebServiceImplService
    extends Service
{

    private final static URL WEBSERVICEIMPLSERVICE_WSDL_LOCATION;
    private final static WebServiceException WEBSERVICEIMPLSERVICE_EXCEPTION;
    private final static QName WEBSERVICEIMPLSERVICE_QNAME = new QName("http://ws.soap.bz.org/", "WebServiceImplService");

    static {
        URL url = null;
        WebServiceException e = null;
        try {
            url = new URL("http://localhost:8080/WebServiceImplService/WebServiceImpl?wsdl");
        } catch (MalformedURLException ex) {
            e = new WebServiceException(ex);
        }
        WEBSERVICEIMPLSERVICE_WSDL_LOCATION = url;
        WEBSERVICEIMPLSERVICE_EXCEPTION = e;
    }

    public WebServiceImplService() {
        super(__getWsdlLocation(), WEBSERVICEIMPLSERVICE_QNAME);
    }

    public WebServiceImplService(WebServiceFeature... features) {
        super(__getWsdlLocation(), WEBSERVICEIMPLSERVICE_QNAME, features);
    }

    public WebServiceImplService(URL wsdlLocation) {
        super(wsdlLocation, WEBSERVICEIMPLSERVICE_QNAME);
    }

    public WebServiceImplService(URL wsdlLocation, WebServiceFeature... features) {
        super(wsdlLocation, WEBSERVICEIMPLSERVICE_QNAME, features);
    }

    public WebServiceImplService(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public WebServiceImplService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
        super(wsdlLocation, serviceName, features);
    }

    /**
     * 
     * @return
     *     returns IWebService
     */
    @WebEndpoint(name = "WebServiceImplPort")
    public IWebService getWebServiceImplPort() {
        return super.getPort(new QName("http://ws.soap.bz.org/", "WebServiceImplPort"), IWebService.class);
    }

    /**
     * 
     * @param features
     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features</code> parameter will have their default values.
     * @return
     *     returns IWebService
     */
    @WebEndpoint(name = "WebServiceImplPort")
    public IWebService getWebServiceImplPort(WebServiceFeature... features) {
        return super.getPort(new QName("http://ws.soap.bz.org/", "WebServiceImplPort"), IWebService.class, features);
    }

    private static URL __getWsdlLocation() {
        if (WEBSERVICEIMPLSERVICE_EXCEPTION!= null) {
            throw WEBSERVICEIMPLSERVICE_EXCEPTION;
        }
        return WEBSERVICEIMPLSERVICE_WSDL_LOCATION;
    }

}

完整pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>org.bz</groupId>
    <artifactId>rest-services</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>rest-services</name>
    <description>Rest Test</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
        <dependency>
            <groupId>javax.jws</groupId>
            <artifactId>javax.jws-api</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <!-- <version>2.3.1</version> -->
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
        <dependency>
            <groupId>javax.xml.ws</groupId>
            <artifactId>jaxws-api</artifactId>
            <!-- <version>2.3.1</version> -->
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.main.appclient/gf-client -->
        <!-- <dependency>
                <groupId>org.glassfish.main.appclient</groupId>
                <artifactId>gf-client</artifactId>
                <version>5.0</version>
            </dependency> -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <!-- https://mvnrepository.com/artifact/org.codehaus.mojo/jaxws-maven-plugin -->
            <!-- <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxws-maven-plugin</artifactId> 
                <version>2.6</version> <executions> <execution> <goals> <goal>wsimport</goal> 
                </goals> </execution> </executions> <configuration> <wsdlUrls> <wsdlUrl>http://localhost:8080/WebServiceImplService/WebServiceImpl?wsdl</wsdlUrl> 
                </wsdlUrls> <keep>true</keep> <packageName>org.bz.soap.client.service</packageName> 
                <sourceDestDir>${basedir}/src/main/java</sourceDestDir> </configuration> 
                </plugin> -->
        </plugins>
    </build>

</project>

在http://localhost:8081/create中使用 REST 服务 GET

在此处输入图像描述

我得到这个输出:

empleado1:Empleado1 [id=null, 
nombres=Fernando Ariel, 
apellidos=Lopez Martinez, 
tipoDocumento=CC, 
numeroDocumento=99258732, 
fechaNacimiento=1984-03-15T00:00:00.000Z, 
fechaVinculacion=2020-09-21T00:00:00.000Z, 
cargo=Constructor, 
salario=6000000.0]
2020-09-19 16:50:45.509 ERROR 25376 --- [nio-8081-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/ws/Service] with root cause

java.lang.NoClassDefFoundError: javax/xml/ws/Service
    at org.bz.rest.api.models.service.EmpleadoServiceImpl.guardarEmpleado(EmpleadoServiceImpl.java:13) ~[classes/:na]
    at org.bz.rest.api.controllers.CustomerController.getCustomer(CustomerController.java:30) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:626) ~[tomcat-embed-core-9.0.38.jar:4.0.FR]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) ~[tomcat-embed-core-9.0.38.jar:4.0.FR]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.38.jar:9.0.38]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[na:na]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
    at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]

为了使用来自 RestController 的 SOAP 服务的一些建议?

标签: jsonxmlspring-mvcjax-rsjax-ws

解决方案


而不是使用

    <!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
    <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>jaxws-api</artifactId>
        <!-- <version>2.3.1</version>
    </dependency>

或使用:

    <!-- https://mvnrepository.com/artifact/javax.xml.ws/com.springsource.javax.xml.ws -->
    <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>com.springsource.javax.xml.ws</artifactId>
        <version>2.1.1</version>
    </dependency>

更好的使用(对我来说):

    <!-- https://mvnrepository.com/artifact/com.sun.xml.ws/jaxws-rt -->
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.3.3</version>
    </dependency>

推荐阅读