我必须实现一个使用 AXIS2 1.4 方法的 AXIS 1.4 客户端。AXIS 1.4 客户端是通过创建存根来制作的。客户端发送一个请求并从带有一些附件 (MTOM) 的服务返回一个响应。当我通过 AXIS 1.4 端口类型对象调用方法(操作)时,出现错误:
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
我认为 MTOM 搞砸了 AXIS。那么问题来了:我是如何获得 AXIS2 1.4 (MTOM) Web 服务返回给我的附件的?TIA。
弗朗切斯科
PS:这里是代码。有 WSDL 生成的存根。问题是:当我调用端口的存根方法时出现异常。我收到的邮件中有附件。
String codistat = "CODISTAT";
OrdinanzeViabilitaLocator ovlocretreive = new OrdinanzeViabilitaLocator();
ovlocretreive.setOrdinanzeViabilitaHttpSoap11EndpointEndpointAddress(".. the service url + action..");
try {
OrdinanzeViabilitaPortType ovretreive = ovlocretreive.getOrdinanzeViabilitaHttpSoap11Endpoint();
((Stub) ovretreive)._setProperty(javax.xml.rpc.Call.USERNAME_PROPERTY, "username");
((Stub) ovretreive)._setProperty(javax.xml.rpc.Call.PASSWORD_PROPERTY, "password");
//problems began here
MessageReqOrdinanze mrq = new MessageReqOrdinanze();
mrq.setCodistat(codistat);
Calendar date_from = Calendar.getInstance();
date_from.setTimeInMillis(0);
Calendar date_to = Calendar.getInstance();
date_from.setTimeInMillis(0);
mrq.setDate_from(date_from);
mrq.setDate_to(date_to);
// the next line generate the exception
MessageOrdinanze mretreive = ovretreive.getOrdinanze(mrq);
} catch (AxisFault e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
}
我收到的消息有
<xop:include href="cid... >...< ../xop/include"/>
里面的标签,它是MTOM(我猜它会导致异常)。希望这可以帮助。