SOAP-只保留父/根命名空间



我有几个xsd文件,用于创建一个SOAP消息的组合。问题是,每当构建对象时,它都会导入所有继承的xmln。我没有发现任何关于这个问题的信息。有没有办法只留下根xmlns?

示例:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<testRes xmlns="http://xxx/xxx/xxx/v1" xmlns:ns2="http://yyy/yyy/yyy/v1" xmlns:ns3="http://zzz/zzz/zzz/v1">
<status>B</status>
<opisBledu>Error msg...</opisBledu>
</testRes>
</S:Body>
</S:Envelope>

我需要的信息是:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<testRes xmlns="http://xxx/xxx/xxx/v1"
<status>B</status>
<opisBledu>Error msg...</opisBledu>
</testRes>
</S:Body>
</S:Envelope>

有必要xmlns:SOAP-ENV=";http://schemas.xmlsoap.org/soap/envelope/"从S:信封xmlns:ns2=";http://yyy/yyy/yyy/v1"xmlns:ns3=";http://zzz/zzz/zzz/v1"必须从testRes中删除。有什么办法做到这一点吗?

是的,您可以在类中的注释@XmlRootElement@XmlElement@XmlTypepackage-info.java中指定xmlns。例如:

@XmlRootElement (name = "testRes", namespace = "http://xxx/xxx/xxx/v1")
public class TestRes 

在您的情况下,需要删除不必要的定义

最新更新