关于webService的接口类型转换问题
工作中用到了webService的接口问题,自己做个笔记:
在按照接口传输信息时,报错如下:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Aug 07 09:48:38 CST 2018
There was an unexpected error (type=Internal Server Error, status=500).
javax.xml.bind.JAXBElement cannot be cast to com.wyait.ws.domain.GetUserResponse
结果最后得到的解决方案是:
将原来的
GetUserResponse response = (GetUserResponse) getWebServiceTemplate()
.marshalSendAndReceive(
"http://117.29.161.2:3358/services/UUVService?wsdl",
request);
改写为
JAXBElement<GetUserResponse> response2 = (JAXBElement<GetUserResponse>) getWebServiceTemplate().marshalSendAndReceive(
"http://117.29.161.2:3358/services/UUVService?wsdl",
request);
System.out.println(response2.getValue().getReturn());
String response = response2.getValue().getReturn();
即可完成要求的类型转换问题
自己做下笔记以防日后