@XmlAttribute(name) SoapUI 中的无效名称
@XmlAttribute(name) invalid name in SoapUI
我正在制作 SOAP 网络服务以及何时使用
@XmlAttribute(name = "asd:resource")
private String asdResource;
我无法在 SoapUI 中导入我的 wsdl。表明:
错误:值 'asd:resource' 是无效名称。
当我只使用 @XmlAttribute
时,我可以导入我的项目,但在响应中我收到的就像没有 : 的 asdResource。
这就是为什么我使用 XmlAttribute(name= "asd:resource")
我的问题是什么会导致这个问题,我该如何解决它。
显然您想在特定命名空间中创建名称为 resource
的属性。这应该是:
@XmlAttribute(name = "resource", namespace="http://...")
namespace
应该是与前缀 asd
.
关联的命名空间
编组时,JAXB 通常会 "invent" 它自己的名称空间前缀(如 ns0
等)。如果您想控制名称空间前缀,请参阅以下问题:
Is it possible to customize the namespace prefix that JAXB uses when marshalling to a String?
你可以试试这个class。
@javax.xml.bind.annotation.XmlSchema(namespace = "yournamespace", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
xmlns = {
@XmlNs(prefix="asd", namespaceURI="yournamespace"),
})
package example;
import javax.xml.bind.annotation.XmlNs;
并且
@XmlAttribute(namespace = "yournamespace")
private String resource;
我正在制作 SOAP 网络服务以及何时使用
@XmlAttribute(name = "asd:resource")
private String asdResource;
我无法在 SoapUI 中导入我的 wsdl。表明: 错误:值 'asd:resource' 是无效名称。
当我只使用 @XmlAttribute
时,我可以导入我的项目,但在响应中我收到的就像没有 : 的 asdResource。
这就是为什么我使用 XmlAttribute(name= "asd:resource")
我的问题是什么会导致这个问题,我该如何解决它。
显然您想在特定命名空间中创建名称为 resource
的属性。这应该是:
@XmlAttribute(name = "resource", namespace="http://...")
namespace
应该是与前缀 asd
.
编组时,JAXB 通常会 "invent" 它自己的名称空间前缀(如 ns0
等)。如果您想控制名称空间前缀,请参阅以下问题:
Is it possible to customize the namespace prefix that JAXB uses when marshalling to a String?
你可以试试这个class。
@javax.xml.bind.annotation.XmlSchema(namespace = "yournamespace", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
xmlns = {
@XmlNs(prefix="asd", namespaceURI="yournamespace"),
})
package example;
import javax.xml.bind.annotation.XmlNs;
并且
@XmlAttribute(namespace = "yournamespace")
private String resource;