我使用Apache CXF編寫了一個WS,並在實現類中獲取請求數據時,它提供了所有的空值。Apache CXF WS中的請求爲空
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.sample.project.com.au/registration/services/GetCountry/GetCountryRequest/v1" xmlns:v11="http://www.sample.project.com.au/common/message/Request/v1">
<soapenv:Header/>
<soapenv:Body>
<v1:getCountryRequest>
<v11:header>
<from>?</from>
<to>?</to>
<eventTime>?</eventTime>
<requestId>?</requestId>
<channelCode>?</channelCode>
<enduserCode>?</enduserCode>
<usecaseName>?</usecaseName>
</v11:header>
<v1:message>
<v1:id>123</v1:id>
<v1:name>123</v1:name>
<v1:code>213</v1:code>
</v1:message>
<v1:id>213</v1:id>
</v1:getCountryRequest>
</soapenv:Body>
</soapenv:Envelope>
au.com.pr[email protected]219baf0b 空 空 顯示java.lang.NullPointerException
我試圖打印的價值
System.out.println(request);
System.out.println(request.getHeader());
System.out.println(request.getHeader().getFrom());
System.out.println(request.getMessage());
System.out.println(request.getMessage().getId());
System.out.println(request.getMessage().getName());
System.out.println(request.getMessage().getCode());
並得到空指針異常。
這可能是什麼原因造成的。
謝謝, 班尼特。
請檢查請求,即時發送Header和Messages,它是空的。找到這個鏈接的代碼http://www.filehosting.org/file/details/393799/sampleWS.rar – Bennet