gpt4 book ai didi

java - Spring配置Web服务: get XsdSchema from wsdl

转载 作者:太空宇宙 更新时间:2023-11-04 13:52:03 25 4
gpt4 key购买 nike

我有 Spring Web 服务配置。

public class WSConfig extends WsConfigurerAdapter {
@Bean
public XsdSchema getSchema() {
return new SimpleXsdSchema(new ClassPathResource("wsdl/types/ewstypes.xsd"));
}
...

如何从 wsdl 获取 xsd?因为我需要 wsdl 中的元素,并且无法更改此文件(例如从中创建新的 xsd 并在 @bean 中返回它)。

...
<wsdl:types>
<xsd:schema xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0"
elementFormDefault="qualified"
targetNamespace="http://foo/equeue/ws/"
>

<xsd:import namespace="http://foo/equeue/ws/types/" schemaLocation="../types/etypes.xsd"/>
<xsd:import namespace="http://bar/123" schemaLocation="../types/ewstypes.xsd" />

<xsd:element name="getRequest" type="smev:GetRequestType"/>
...

最佳答案

您可以做的一件简单的事情就是复制标签

<xsd:schema>

从 WSDL 及其所有内容到文件“ewstypes.xsd”,从而生成完全有效的 XSD 架构。

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0"
elementFormDefault="qualified"
targetNamespace="http://foo/equeue/ws/"
>

<xsd:import namespace="http://foo/equeue/ws/types/" schemaLocation="../types/etypes.xsd"/>
<xsd:import namespace="http://bar/123" schemaLocation="../types/ewstypes.xsd" />

<xsd:element name="getRequest" type="smev:GetRequestType"/>
....
</xsd:schema>

然后将其公开为 Bean,就像您现在所做的那样。希望这有帮助!

关于java - Spring配置Web服务: get XsdSchema from wsdl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30198320/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com