java webservice xfire 窄接口方法参数为集合类型,客户端调用报错,信息如下:
Exceptioninthread"main"org.codehaus.xfire.fault.XFireFault:Fault:java.lang.NullPointe...
Exception in thread "main" org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException
at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:83)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
at org.codehaus.xfire.client.Client.invoke(Client.java:336)
at org.codehaus.xfire.client.Client.invoke(Client.java:368)
at com.dhcc.itsm.bp.webservice.client.clientTest.testClient(clientTest.java:59)
at com.dhcc.itsm.bp.webservice.client.clientTest.main(clientTest.java:45)
Caused by: java.lang.NullPointerException
at org.codehaus.xfire.aegis.type.basic.ObjectType.writeObject(ObjectType.java:192)
at org.codehaus.xfire.aegis.AegisBindingProvider.writeParameter(AegisBindingProvider.java:229)
at org.codehaus.xfire.service.binding.AbstractBinding.writeParameter(AbstractBinding.java:273)
at org.codehaus.xfire.service.binding.WrappedBinding.writeMessage(WrappedBinding.java:90)
at org.codehaus.xfire.soap.SoapSerializer.writeMessage(SoapSerializer.java:80)
at org.codehaus.xfire.transport.http.HttpChannel.writeWithoutAttachments(HttpChannel.java:56)
at org.codehaus.xfire.transport.http.CommonsHttpMessageSender.getByteArrayRequestEntity(CommonsHttpMessageSender.java:422)
at org.codehaus.xfire.transport.http.CommonsHttpMessageSender.send(CommonsHttpMessageSender.java:360)
at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:123)
at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
... 5 more
客户端代码如下:
public class clientTest {
public static void main(String[] args) throws Exception {
clientTest test=new clientTest();
test.testClient();
}
public void testClient() throws Exception {
String serviceUrl = "http://10.3.59.17:9000/itsm/service/dbicDataInterface?wsdl";
Client client = new Client(new URL(serviceUrl));
HashMap map = new HashMap();
List ls = new ArrayList();
map.put("0", "123");
map.put("1", "456");
map.put("2", "789");
map.put("3", "0");
ls.add(0,map);
//调用特定的Web Service方法
Object[] i = client.invoke("setDbicDate",new Object[] { ls });
//int i = client.invoke("testWebService", ls);
System.out.println("result: " + i);
}
}
没有分可以给,希望高手们不吝赐教,小弟在此先谢过!!! 展开
at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:83)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
at org.codehaus.xfire.client.Client.invoke(Client.java:336)
at org.codehaus.xfire.client.Client.invoke(Client.java:368)
at com.dhcc.itsm.bp.webservice.client.clientTest.testClient(clientTest.java:59)
at com.dhcc.itsm.bp.webservice.client.clientTest.main(clientTest.java:45)
Caused by: java.lang.NullPointerException
at org.codehaus.xfire.aegis.type.basic.ObjectType.writeObject(ObjectType.java:192)
at org.codehaus.xfire.aegis.AegisBindingProvider.writeParameter(AegisBindingProvider.java:229)
at org.codehaus.xfire.service.binding.AbstractBinding.writeParameter(AbstractBinding.java:273)
at org.codehaus.xfire.service.binding.WrappedBinding.writeMessage(WrappedBinding.java:90)
at org.codehaus.xfire.soap.SoapSerializer.writeMessage(SoapSerializer.java:80)
at org.codehaus.xfire.transport.http.HttpChannel.writeWithoutAttachments(HttpChannel.java:56)
at org.codehaus.xfire.transport.http.CommonsHttpMessageSender.getByteArrayRequestEntity(CommonsHttpMessageSender.java:422)
at org.codehaus.xfire.transport.http.CommonsHttpMessageSender.send(CommonsHttpMessageSender.java:360)
at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:123)
at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
... 5 more
客户端代码如下:
public class clientTest {
public static void main(String[] args) throws Exception {
clientTest test=new clientTest();
test.testClient();
}
public void testClient() throws Exception {
String serviceUrl = "http://10.3.59.17:9000/itsm/service/dbicDataInterface?wsdl";
Client client = new Client(new URL(serviceUrl));
HashMap map = new HashMap();
List ls = new ArrayList();
map.put("0", "123");
map.put("1", "456");
map.put("2", "789");
map.put("3", "0");
ls.add(0,map);
//调用特定的Web Service方法
Object[] i = client.invoke("setDbicDate",new Object[] { ls });
//int i = client.invoke("testWebService", ls);
System.out.println("result: " + i);
}
}
没有分可以给,希望高手们不吝赐教,小弟在此先谢过!!! 展开
3个回答
展开全部
myeclipse中自带有xfire,在使用wsdl生成客户端时选择使用xfire生成,然后会有一个验证wsdl的,生成时如果不报错,就会成功。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
myeclipse中自带有xfire,在使用wsdl生成客户端时选择使用xfire生成,然后会有一个验证wsdl的过程,验证通过,生成时如果不报错,就会成功。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这是xfire的局限性,xfire里涉及到复杂类型都要用JXAB转的.对于list来说,用泛型吧,泛型可以的.比如说一个User对象 . List<User> list=new ArrayList<User> 用这个list就可以通关
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询