如何使用 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;
    }

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)