XML-22103:(致命错误)DOMResult 不能是这种节点



我在请求 Web 服务时遇到错误。

我用了 Spring boot 3.x

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<id>apps</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<target>2.1</target>
<episodeFileName>episode_apps</episodeFileName>
<xjbSources>
<xjbSource>src/main/resources/appstms.xjb</xjbSource>
</xjbSources>
<sources>
<source>src/main/resources/xsd/schema-apps.xsd</source>
</sources>
<outputDirectory>${basedir}/src/main/java</outputDirectory>
<!--
<outputDirectory>
${project.parent.relativePath}/src/main/java/by/*/reception/electronic/docs/service/
</outputDirectory>-->
<packageName>*.reception.electronic.docs.service.generated.xml.entrypoint</packageName>
<!--    <outputDirectory>*.reception.electronic.docs.service.generate
</outputDirectory>-->
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</executions>
</plugin>
  • 配置

@EnableWs
@Configuration
public class WebServiceConfig {
private static final String NAMESPACE_URI = "http://*.com/apps";

@SuppressWarnings({"rawtypes", "unchecked"})
@Bean(name = "apsMessage")
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext appContext){
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(appContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/ws/*");
}
@Bean
public SaajSoapMessageFactory messageFactory() {
SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory();
messageFactory.setSoapVersion(SoapVersion.SOAP_12);
return messageFactory;
}

/* localhost:8080/ws/appsTms.wsdl
* */
@Bean(name = "appsTms")
public DefaultWsdl11Definition defaultWsdl11Definition(@Qualifier("appsTmsSchema") XsdSchema schema){
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("ApsPort");
wsdl11Definition.setLocationUri("/ws");
wsdl11Definition.setTargetNamespace(NAMESPACE_URI);
wsdl11Definition.setSchema(schema);
wsdl11Definition.setCreateSoap11Binding(true);
wsdl11Definition.setCreateSoap12Binding(true);
return wsdl11Definition;
}
@Bean(name = "appsTmsSchema")
public XsdSchema moviesSchema(){
return new SimpleXsdSchema(new ClassPathResource("xsd/schema-apps.xsd"));
}
}
  • 和一个端点
@Endpoint
public class MessageEndpoint {
private static final Logger LOGGER  = LoggerFactory.getLogger( MessageEndpoint.class );
private static final String NAMESPACE_URI = "http://*.com";

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "Multiply")
@ResponsePayload
public MultiplyResponse getMultiplyResponse(@RequestPayload Multiply messageRequest) throws Exception {
String fileName1 = messageRequest.getFileName1();
System.out.println(fileName1);
MultiplyResponse response = new MultiplyResponse();
response.setReturn("");
return response;
}
}

当我尝试执行查询并传递 XML 时,我甚至无法到达 Web 服务终结点所在的类。

我有一个错误:

08-06-2020 16:44:27.935 信息 14660
o.s.web.servlet.DispatcherServlet : 初始化 Servlet 'dispatcherServlet'

XML-22103:(致命错误(DOMResult 不能是这种节点。 08-06-2020 16:44:27.936 调试 14660
o.s.web.servlet.DispatcherServlet : 检测到 标准 Servlet多部分解析器 08-06-2020 16:44:27.951 调试 14660 o.s.web.servlet.DispatcherServlet : enableLoggingRequestDetails='false':请求参数和标头 将被屏蔽以防止不安全地记录潜在的敏感数据 08-06-2020 16:44:27.951 信息 14660
o.s.web.servlet.DispatcherServlet : 已完成初始化 15 毫秒 08-06-2020 16:44:27.952 调试 14660
o.s.web.servlet.DispatcherServlet : 开机自检的"错误"调度 "/error", parameters={} 08-06-2020 16:44:27.955 调试 14660
s.w.s.m.m.a.请求映射处理程序映射:映射到 org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest( 08-06-2020 16:44:27.976 调试 14660
o.s.w.s.m.m.a.HttpEntityMethodProcessor : 使用 'application/json', 给定 [/] 并支持 [application/json, application/+json, 应用程序/json, 应用程序/+json] 08-06-2020 16:44:27.976 调试 14660 o.s.w.s.m.m.a.HttpEntityMethodProcessor : Writing [{时间戳=MSK 2020 年 6 月 8 日星期一 16:44:27,状态 = 500,错误 = 内部 服务器错误,消息=,路径=/ws(截断(...] 08-06-2020 16:44:28.004 调试 14660 o.s.web.servlet.DispatcherServlet : 从"错误"派单退出,状态 500

知道它是什么以及如何解决它吗?

原因如下:

相邻系统由自己的 xsd 工作,并具有与发送到 Web 服务的文档映射的命名空间 URI。

相邻系统是调解器,接收 xml 文档以发送到另一个系统进行处理。

首先,她抬头了看,比她想象的,一个端点在一个 Web 服务 (soap( имеет 特定的命名空间, 指向 xsd , 基于 是构建的 WSDL.

adjiong系统能够与以下系统配合使用:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://ws.transit.ls.com"
targetNamespace="http://ws.transit.ls.com"
elementFormDefault="qualified">
<xs:element name="Multiply">
....
  • 注意:目标命名空间="http://ws.transit.ls.com">

您必须将此类targetNamespace指向:

@Endpoint
public class MessageEndpoint {
private static final Logger LOGGER  = LoggerFactory.getLogger( MessageEndpoint.class );
private static final String NAMESPACE_URI = "http://ws.transit.ls.com";

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "Multiply")
@ResponsePayload
public MultiplyResponse getMultiplyResponse(@RequestPayload Multiply messageRequest) throws Exception {
String fileName = messageRequest.getFileName1();
...

您还必须将 xsd 与能够工作的相邻系统一起使用(不得将 nothig 更改为 xsd(

如果您正在创建新的 Web 服务 Soap,并且从一开始就创建一个其他客户端将遵循的应用程序,那么您就是 xsd。

但就我而言,我必须遵守规则的命令系统

最新更新