发帖    主题    评论    推荐    标签    作者    订阅    查搜    注册   登陆   关注
 
面向对象 设计模式 领域驱动设计 企业架构 框架 开发教程 微服务 CQRS 扩展性 并发编程 事件溯源 分布式 SOA

axis客户端调用服务器端方法,返回对象数组(web service求助)

2007-04-03 22:26
赞助商链接

我在网上找了个公开的web service wsdl地址为:http://www.fundxy.com/fundxy/Common/FundxyService.asmx?WSDL

客户端用java编写

web service公开一方法为GetNewFundValue , 是接收三个整形参数(FundType,SortType,AscFlag),然后返回一个对象数组,对象为FundValue

我在客户端进行了FundValue对象自定义序列化,写了个javabean

我在客户端的axis代码是:

public class returnFundValue {
public static void main(String[] args) {
try {

Integer i = new Integer(1);
Integer j = new Integer(0);
Integer z = new Integer(0);

String endpoint="http://www.fundxy.com/fundxy/Common/FundxyService.asmx";

Service service = new Service();
Call call = (Call)service.createCall();

//注册对象
QName qn=new QName("http://www.fundxy.com/fundxy/common/fundxyservice", "FundValue");
call.registerTypeMapping(FundValue.class, qn,
new org.apache.axis.encoding.ser.
BeanSerializerFactory(FundValue.class, qn),
new org.apache.axis.encoding.ser.
BeanDeserializerFactory(FundValue.class, qn));

//注册对象数组
QName qname=new QName("http://www.fundxy.com/fundxy/common/fundxyservice","ArrayOfFundValue");
call.registerTypeMapping(FundValue[].class,qname,
new org.apache.axis.encoding.ser.BeanSerializerFactory(FundValue[].class,qname),
new org.apache.axis.encoding.ser.BeanDeserializerFactory(FundValue[].class,qname));

call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("http://www.fundxy.com/fundxy/common/fundxyservice","GetNewFundValue"));


//添加参数:
call.addParameter("FundType",new QName("http://www.w3.org/2001/XMLSchema","int"),javax.xml.rpc.ParameterMode.IN);
call.addParameter("SortType",new QName("http://www.w3.org/2001/XMLSchema","int"),javax.xml.rpc.ParameterMode.IN);
call.addParameter("AscFlag",new QName("http://www.w3.org/2001/XMLSchema","int"),javax.xml.rpc.ParameterMode.IN);

//call.setReturnType(org.apache.axis.encoding.XMLType.SOAP_ARRAY);
//call.setReturnType(new QName("http://www.fundxy.com/fundxy/common/fundxyservice","GetNewFundValue"),FundValue[].class);
call.setReturnType(qname);

call.setUseSOAPAction(true);
call.setSOAPActionURI("http://www.fundxy.com/fundxy/common/fundxyservice/GetNewFundValue");


FundValue[] k= (FundValue[])call.invoke(new Object[]{i,j,z});
System.out.println( "result is " + k[1].getFundID());

}

catch (Exception e) {System.err.println(e.toString()); }

}
}

但是执行的时候就报下面的错误:


org.xml.sax.SAXException: Unable to create JavaBean of type [LFundValue;. Missi
ng default constructor? Error was: java.lang.InstantiationException: [LFundValu
e;.
at org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeseri
alizer.java:147)
at org.apache.axis.encoding.DeserializationContext.startElement(Deserial
izationContext.java:1048)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.client.Call.invoke(Call.java:2467)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at returnFundValue.main(returnFundValue.java:75)
org.xml.sax.SAXException: Unable to create JavaBean of type [LFundValue;. Missi
ng default constructor? Error was: java.lang.InstantiationException: [LFundValu
e;.

能看出问题吗?

2007-04-05 10:01

把wsdl的schema贴给我看!


解决ws的问题,肯定从wsdl入手,用jaxb生成测试类,然后单步求解!

赞助商链接

赞助商链接

返回顶部

移动版 关于本站 使用帮助 联系管理员 最佳分辨率1366x768
OpenSource JIVEJDON Powered by JdonFramework Code © 2002-20 jdon.com