1
我正在與JDOM一起使用Spring-WS。spring-ws jdom錯誤響應
代碼:
@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>
正如你所看到的,沒有孩子返回,只是根元素。有任何想法嗎?
上面的代碼看起來很好......在方法之外還有別的事情發生。你可以在return語句中調試該方法嗎?然後按照XML返回到輸出的位置? – rolfl
第二個評論,兒童元素應該是在NO-命名空間或命名空間'http:// example.pl/gb/schemas' – rolfl
感謝您的輸入,我提供瞭解決方案作爲答案。 – meliniak