问题描述
我的 XSD 是
<element name="GetCertificateByServiceName" >
<complexType>
<sequence>
<element ref="tns:ServiceName" />
</sequence>
</complexType>
</element>
<element name="ServiceName" type="string" />
尽管以 S 为大写,子元素仍生成为“serviceName”
POJO 类:
@XmlAccessorType(XmlAccesstype.FIELD)
@XmlType(name = "",propOrder = {
"serviceName"
})
@XmlRootElement(name = "GetCertificateByServiceName")
public class GetCertificateByServiceName {
@XmlElement(name = "ServiceName",required = true)
protected String serviceName;
public String getServiceName() {
return serviceName;
}
public void setServiceName(String value) {
this.serviceName = value;
}
XML 生成
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header />
<S:Body>
<ns2:GetCertificateByServiceName xmlns:ns2="http://example.com/xsd/1.0">
<serviceName>ManagerService</serviceName>
</ns2:GetCertificateByServiceName>
</S:Body>
</S:Envelope>
预期 它应该是 ServiceName 而不是 serviceName 并且 ns2 应该与 ServiceName 相关联:
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header />
<S:Body>
<ns2:GetCertificateByServiceName xmlns:ns2="http://example.com/xsd/1.0">
<ns2:ServiceName>ManagerService</ns2:ServiceName>
</ns2:GetCertificateByServiceName>
</S:Body>
</S:Envelope>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)