0

I have got an error during the request to an Web-service.

I used 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>
  • config


@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"));

    }
}

  • And an endpoint
@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;
    }
}

When I try to execute a query and pass Xml, I don't even get to the class where the web service endpoint is located.

I have an error :

08-06-2020 16:44:27.935 INFO 14660
o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'

XML-22103: (Fatal Error) DOMResult can not be this kind of node. 08-06-2020 16:44:27.936 DEBUG 14660
o.s.web.servlet.DispatcherServlet : Detected StandardServletMultipartResolver 08-06-2020 16:44:27.951 DEBUG 14660 o.s.web.servlet.DispatcherServlet : enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data 08-06-2020 16:44:27.951 INFO 14660
o.s.web.servlet.DispatcherServlet : Completed initialization in 15 ms 08-06-2020 16:44:27.952 DEBUG 14660
o.s.web.servlet.DispatcherServlet : "ERROR" dispatch for POST "/error", parameters={} 08-06-2020 16:44:27.955 DEBUG 14660
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest) 08-06-2020 16:44:27.976 DEBUG 14660
o.s.w.s.m.m.a.HttpEntityMethodProcessor : Using 'application/json', given [/] and supported [application/json, application/+json, application/json, application/+json] 08-06-2020 16:44:27.976 DEBUG 14660 o.s.w.s.m.m.a.HttpEntityMethodProcessor : Writing [{timestamp=Mon Jun 08 16:44:27 MSK 2020, status=500, error=Internal Server Error, message=, path=/ws (truncated)...] 08-06-2020 16:44:28.004 DEBUG 14660 o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 500

Any idea what it is and how to fix it ?

lexicore
  • 42,748
  • 17
  • 132
  • 221
skyho
  • 1,438
  • 2
  • 20
  • 47

1 Answers1

0

The cause is follow:

The adjoining system work by own xsd and to have a namespace uri that is mapped with documents that is send to web service.

The adjoining system is an mediator and recieve xml documents for sending to another system for processing.

First off she look up into and than she suppose, that an endpoint in a web-service (soap) имеет specific namespace, that is pointed into xsd , on based was built WSDL.

The adjiong system able to work with:

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

You must point such targetNamespace in:

@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();

...

You also must to use the xsd with able to work adjoining system (must not change nothig into the xsd)

If you are creating new Web-service Soap and from first to create an application that another clients will adhering your an xsd.

But in the my case I must adhere rules the enjoining system.

skyho
  • 1,438
  • 2
  • 20
  • 47