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

ej83mcc0  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(336)

我在请求web服务时出错。
我用的是Spring Boot3.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服务端点所在的类。
我有个错误:
2020年6月8日16:44:27.935信息14660
o、 s.web.servlet.dispatcherservlet:初始化servlet'dispatcherservlet'
xml-22103:(致命错误)domresult不能是此类节点。2020年6月8日16:44:27.936调试14660
o、 s.web.servlet.dispatcherservlet:检测到standardservletmultipartresolver 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”dispatch for post“/error”,参数={}08-06-2020 16:44:27.955调试14660
s、 w.s.m.m.a.requestmappinghandlermapping:Map到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,application/json,application/+json]08-06-2020 16:44:27.976调试14660 o.s.s.m.a.httpentitymethodprocessor:写入[{timestamp=mon jun 08 16:44:27 msk 2020,status=500,error=internal server error,message=,path=/ws(截断)…]08-06-2020 16:44:28.004调试14660 o.s.web.servlet.dispatcherservlet:退出“错误”调度,状态500
知道是什么吗?怎么修?

sd2nnvve

sd2nnvve1#

原因如下:
相邻的系统通过自己的xsd工作,并拥有一个命名空间uri,该uri与发送到web服务的文档Map。
相邻的系统是一个中介器,它接收xml文档以发送到另一个系统进行处理。
首先,她查看了web服务(soap)中的一个端点имеет 特定的命名空间(指向xsd)是基于wsdl构建的。
邻接系统能够处理:

<?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">
....

注意:targetnamespace=“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(不得在xsd中更改任何内容)
如果您正在创建新的web服务soap并从第一个开始创建一个应用程序,那么另一个客户机将使用xsd。
但就我而言,我必须遵守禁止制度的规定。

相关问题