2 whipjeans whipjeans 于 2013.07.08 16:49 提问

axis1.4调用webservice 传递自定义对象参数出错

调用客户端后出现:
org.xml.sax.SAXException: Invalid element in cn.services.QueryEquipmentRequest - queryEquipmentRequest

客户端代码(其中queryEquipmentRequest,QueryEquipmentResponse是我自定义的对象):
call.addParameter(new QName(nameSpace, "queryEquipmentRequest"), new QName(nameSpace, "queryEquipmentRequest"), ParameterMode.IN);
// // @@需修改成对应的输出参数名
call.setReturnType(new QName(nameSpace, "queryEquipmentResponse"),
QueryEquipmentResponse.class);
//

// // 需要根据xsd生成的bean,对输入输出的XSD文件定义的类型进行注册映射关系
//// // @@如本服务输入输出XSD文件中有四个自定义类型 queryEquipmentRequest、queryEquipmentResponse、deviceItem、deviceItemList,配置如下
QName queryEquipmentRequest = new QName(nameSpace, "queryEquipmentRequest");
call.registerTypeMapping(QueryEquipmentRequest.class, queryEquipmentRequest,
new BeanSerializerFactory(QueryEquipmentRequest.class,
queryEquipmentRequest), new BeanDeserializerFactory(
QueryEquipmentRequest.class, queryEquipmentRequest));
//
QName queryEquipmentResponse = new QName(nameSpace, "queryEquipmentResponse");
call.registerTypeMapping(QueryEquipmentResponse.class, queryEquipmentResponse,
new BeanSerializerFactory(QueryEquipmentResponse.class,
queryEquipmentResponse), new BeanDeserializerFactory(
QueryEquipmentResponse.class, queryEquipmentResponse));

服务端的wsdl文件为:

<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->wsdl:types/wsdl:types/wsdl:message/wsdl:message/wsdl:operation/wsdl:portType/wsdl:input/wsdl:output/wsdl:operation/wsdl:binding /wsdl:port/wsdl:service/wsdl:definitions

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!