首页 > 解决方案 > 如何使用 spring-boot-ws 为 XML 创建 XSD?

问题描述

我创建我的 XSD 来为我的服务创建域(方法和参数)。这是我的 XSD

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.baeldung.com/springsoap/gen"
    xmlns:imp="http://www.baeldung.com/springsoap/gen"
               targetNamespace="http://www.baeldung.com/springsoap/gen" elementFormDefault="qualified">
    <xs:element name="reqCountry">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="name" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="resCountry">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="name" type="xs:string"/>
                 <xs:element name="population" type="xs:int"/>
                 <xs:element name="capital" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

但问题是它不会生成方法,但如果我将名称“ reqCountry ”替换为“ reqCountryRequest ”是可以的,但名称应该是reqCountry

这是端点类

@Endpoint
public class CountryEndpoint {
    
    @PayloadRoot(namespace = "http://www.baeldung.com/springsoap/gen", localPart = "reqCountry")
    @ResponsePayload
    public ResCountry getCountry(@RequestPayload ReqCountry request) {
        ResCountry response = new ResCountry();
        response.setCapital("ESpain");
        return response;
    }

}

标签: javaspringspring-bootweb-services

解决方案


推荐阅读