我使用 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.project.sample.registration.services.getcountry.GetCountryRequest@219baf0b null null 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());
并得到空指针异常。
这可能是什么原因。
谢谢,班纳特。