我们在Web Sphere 7.0.0.19服务器上托管了JAX-WS服务。该服务使用@WebService注释实现。如果我们点击服务要求WSDL,我们成功地将XML返回给我们。但是,如果我们调用Web服务方法,则会返回以下错误:
javax.xml.ws.soap.SOAPFaultException: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: class com.penske.newreuse.vo.ApplicationConfigVO nor any of its super class is known to this context.]
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:171)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:94)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:240)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:103)
查看我们的日志记录,我们的代码被成功调用,并返回预期的数据。但是,正在编组数据以便将故障发送回客户端。
ApplicationConfigVO类位于一个单独的jar文件中,我们尝试将其拉出并直接包含源代码,无需更改。
我将@XmlSeeAlso(ApplicationConfigVO.class)添加到ApplicationConfigVO对象,但仍然没有更改。
这是网络服务代码:
@WebService(serviceName="WebServiceConfigService")
public class WebServiceConfig {
private static Logger log = Logger.getLogger(WebServiceConfig.class);
public ApplicationConfigVO[] loadWsControlMode(int applicationId,String appsId) throws Exception {
log.info("loadWsControlMode WebService Invoked Application ID :"+ appsId);
List returnList = null;
ApplicationConfigVO[] resultArray = null;
try {
ApplicationConfigVO modelObj = new ApplicationConfigVO();
modelObj.setApplicationId(applicationId);
IApplicationConfigDAO daoObj = DAOFactory.getApplicationConfigDAO();
returnList = daoObj.loadWsControlMode(modelObj);
if(null != returnList && returnList.size()>0){
resultArray = new ApplicationConfigVO[returnList.size()];
//Populate the ApplicationConfigVO array from arraylist
modelObj = new ApplicationConfigVO();
for(int i=0;i<returnList.size();i++){
modelObj = (ApplicationConfigVO)returnList.get(i);
resultArray[i] = modelObj;
}//End of for loop
}
} catch (Exception e) {
log.error(DAWebServiceUtil.stackTraceToString(e));
throw e;
}
return resultArray;
}
这是ApplicationConfigVO类:
public class ApplicationConfigVO implements Serializable{
private int applicationId;
private String webServiceControlMode = null;
private int webServiceId;
private String webServiceName = null;
private int webServiceMethodId;
private int opModeId;
private String webServiceMethodDesc = null;
private int dataBaseTypeId;
private String dataBaseTypeDesc = null;
... // various getters and setters following java bean rules
}
答案 0 :(得分:0)
好吧,我尝试过任何事情都无济于事。所以我发誓,我修改了方法以返回List而不是ApplicationConfigVO []。此时我认为这是一个类加载器问题,但我无法确定。在任何一种情况下,切换到列表最终都更容易,希望没有其他任何东西会咬我们