我想形成这种XML,但没有希望。
<soap:Envelope
xmlns:soap="http://www.w3.zzz/2003/05/soap-envelope"
xmlns:ns="http://abc.zzz/1234">
<soap:Body>
<ns:RequestSecurityToken xmlns:trust="http://abc.zzz/1234">
<trust:KeyType>foo</trust:KeyType>
<trust:RequestType>bar</trust:RequestType>
<trust:TokenType>foo2</trust:TokenType>
</ns:RequestSecurityToken>
</soap:Body>
</soap:Envelope>
请帮忙,我目前在下课中的输出是这个...
<soap:Envelope
xmlns:soap="http://www.w3.zzz/2003/05/soap-envelope"
xmlns:ns="http://abc.zzz/1234">
<soap:Body>
<ns:RequestSecurityToken>
<ns:KeyType>foo</trust:KeyType>
<ns:RequestType>bar</trust:RequestType>
<ns:TokenType>foo2</trust:TokenType>
</ns:RequestSecurityToken>
</soap:Body>
</soap:Envelope>
Envelop.class
@Root(name = "soap:Envelop")
@NamespaceList({
@Namespace(prefix = "soap", reference = "http://www.w3.zzz/2003/05/soap-envelope"),
@Namespace(prefix = "ns", reference = "http://abc.zzz/1234")
public class Envelop {
@Namespace(reference = "http://www.w3.zzz/2003/05/soap-envelope")
@Element(name = "Body")
private Body body;
// Getter & Setter
}
Body.class
@Root(name = "soap:Body")
public class Body {
@Element(name = "ns:RequestSecurityToken")
@Namespace(prefix = "trust", reference = "http://abc.zzz/1234")
private SecurityToken securityToken;
// Getter & Setter
}
SecurityToken.class
@Root(name = "ns:RequestSecurityToken")
public class SecurityToken {
@Element(name = "KeyType")
@Namespace(prefix = "trust", reference = "http://abc.zzz/1234")
private String keyType;
@Element(name = "RequestType)
@Namespace(prefix = "trust", reference = "http://abc.zzz/1234")
private String requestType;
@Element(name = "TokenType")
@Namespace(prefix = "trust", reference = "http://abc.zzz/1234")
private String tokenType;
}
谢谢。