我正在努力使用与 JDOM 一起使用的 Spring-WS。
代码:
@Endpoint
@Namespace(uri = "http://example.pl/gb/schemas", prefix = "gb")
public class PdfCheckStatusEndPoint {
private static final String NAMESPACE_URI = "http://example.pl/gb/schemas";
...
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "PdfStatusRequest")
@Namespace(uri = NAMESPACE_URI, prefix = "sch")
@ResponsePayload
public Element getPdfStatus(@XPathParam("//sch:policyNr") String policyNr) {
org.jdom2.Namespace javaxml2Namespace = org.jdom2.Namespace.getNamespace("http://example.pl/gb/schemas");
Element responseElement = new Element("PersonResponse", javaxml2Namespace);
Element childElement1 = new Element("FullName");
childElement1.setText("john doe");
Element childElement2 = new Element("SSN");
childElement2.setText("12345");
responseElement.addContent(childElement1);
responseElement.addContent(childElement2);
return responseElement;
}
}
端点自行工作,但响应与预期不同:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<PersonResponse xmlns="http://example.pl/gb/schemas"/>
</env:Body>
</env:Envelope>
如您所见,没有返回子元素,只返回根元素。有任何想法吗?