问题描述
wsdl地址:http://169.169.19.128:8070/axis/services/ShipArrive?wsdl内容如下:<?xmlversion="1.0"encoding="UTF-8"?>-<wsdl:definitionstargetNamespace="http://169.169.19.128:8070/axis/services/ShipArrive"xmlns:apachesoap="http://xml.apache.org/xml-soap"xmlns:impl="http://169.169.19.128:8070/axis/services/ShipArrive"xmlns:intf="http://169.169.19.128:8070/axis/services/ShipArrive"xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"xmlns:tns1="urn:AnalyzeShipArriveTime"xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:xsd="http://www.w3.org/2001/XMLSchema">-<!--WSDLcreatedbyApacheAxisversion:1.4BuiltonApr22,2006(06:55:48PDT)-->-<wsdl:types>+<schematargetNamespace="http://169.169.19.128:8070/axis/services/ShipArrive"xmlns="http://www.w3.org/2001/XMLSchema"><importnamespace="urn:AnalyzeShipArriveTime"/><importnamespace="http://schemas.xmlsoap.org/soap/encoding/"/>-<complexTypename="ArrayOf_xsd_string">-<complexContent>-<restrictionbase="soapenc:Array"><attributeref="soapenc:arrayType"wsdl:arrayType="xsd:string[]"/></restriction></complexContent></complexType>-<complexTypename="ArrayOf_tns1_ShipArriveTime">-<complexContent>-<restrictionbase="soapenc:Array"><attributeref="soapenc:arrayType"wsdl:arrayType="tns1:ShipArriveTime[]"/></restriction></complexContent></complexType></schema>-<schematargetNamespace="urn:AnalyzeShipArriveTime"xmlns="http://www.w3.org/2001/XMLSchema"><importnamespace="http://169.169.19.128:8070/axis/services/ShipArrive"/><importnamespace="http://schemas.xmlsoap.org/soap/encoding/"/>-<complexTypename="ShipArriveTime">-<sequence><elementname="callsign"nillable="true"type="xsd:string"/><elementname="devicenum"nillable="true"type="xsd:string"/><elementname="did"type="xsd:int"/><elementname="dlat"nillable="true"type="xsd:string"/><elementname="dlon"nillable="true"type="xsd:string"/><elementname="eshipname"nillable="true"type="xsd:string"/><elementname="mmsi"nillable="true"type="xsd:string"/><elementname="regionid"nillable="true"type="xsd:string"/><elementname="shiplength"nillable="true"type="xsd:string"/><elementname="shipname"nillable="true"type="xsd:string"/><elementname="utc"nillable="true"type="xsd:string"/></sequence></complexType></schema></wsdl:types>-<wsdl:messagename="getArriveTimeResponse"><wsdl:partname="getArriveTimeReturn"type="impl:ArrayOf_tns1_ShipArriveTime"/></wsdl:message>-<wsdl:messagename="getArriveTimeRequest"><wsdl:partname="devicenums"type="impl:ArrayOf_xsd_string"/></wsdl:message>-<wsdl:portTypename="ShipArriveAction">-<wsdl:operationname="getArriveTime"parameterOrder="devicenums"><wsdl:inputmessage="impl:getArriveTimeRequest"name="getArriveTimeRequest"/><wsdl:outputmessage="impl:getArriveTimeResponse"name="getArriveTimeResponse"/></wsdl:operation></wsdl:portType>-<wsdl:bindingname="ShipArriveSoapBinding"type="impl:ShipArriveAction"><wsdlsoap:bindingstyle="rpc"transport="http://schemas.xmlsoap.org/soap/http"/>-<wsdl:operationname="getArriveTime"><wsdlsoap:operationsoapAction=""/>-<wsdl:inputname="getArriveTimeRequest"><wsdlsoap:bodyencodingStyle="http://schemas.xmlsoap.org/soap/encoding/"namespace="http://action.soa.com"use="encoded"/></wsdl:input>-<wsdl:outputname="getArriveTimeResponse"><wsdlsoap:bodyencodingStyle="http://schemas.xmlsoap.org/soap/encoding/"namespace="http://169.169.19.128:8070/axis/services/ShipArrive"use="encoded"/></wsdl:output></wsdl:operation></wsdl:binding>-<wsdl:servicename="ShipArriveActionService">-<wsdl:portbinding="impl:ShipArriveSoapBinding"name="ShipArrive"><wsdlsoap:addresslocation="http://169.169.19.128:8070/axis/services/ShipArrive"/></wsdl:port></wsdl:service></wsdl:definitions>代码如下/**创建日期2006-10-19**更改所生成文件模板为*窗口>首选项>Java>代码生成>代码和注释*/packagea_test;importjavax.xml.namespace.QName;importjavax.xml.rpc.ParameterMode;importjavax.xml.rpc.encoding.XMLType;importorg.apache.axis.encoding.ser.BeanDeserializerFactory;importorg.apache.axis.encoding.ser.BeanSerializerFactory;/***调用AIS提供给CBOS的AIS时间的WebService接口**@authorAdministrator**更改所生成类型注释的模板为窗口>首选项>Java>代码生成>代码和注释*/publicclassAISTimeService{publicstaticvoidmain(String[]args){ShipArriveTime[]a=getAISMessage_New(newString[]{"2329"});System.out.println(a.length);}publicstaticShipArriveTime[]getAISMessage_New(String[]devicenums){ShipArriveTime[]result=null;try{Stringendpoint="http://169.169.19.128:8070/axis/services/ShipArrive";org.apache.axis.client.Serviceservice=neworg.apache.axis.client.Service();//建立请求服务框架实例。/**org.apache.axis.client.Service实现JAX-RPCsjavax.xml.rpc.Services接口*该接口充当产生下面提到的org.apache.axis.client.Call实例的角色。*/org.apache.axis.client.Callcall;call=(org.apache.axis.client.Call)service.createCall();call.setTargetEndpointAddress(newjava.net.URL(endpoint));call.setOperationName(newjavax.xml.namespace.QName("http://169.169.19.128:8070/axis/services/ShipArrive","getArriveTime"));//设置需要调用的函数名称/**org.apache.axis.client.Call实现了JAX-RPCsjavax.xml.rpc.Call接口。*/QNamebpNmae=newQName("http://169.169.19.128:8070/axis/services/ShipArrive","ShipArriveTime");call.registerTypeMapping(ShipArriveTime.class,bpNmae,newBeanSerializerFactory(ShipArriveTime.class,bpNmae),newBeanDeserializerFactory(ShipArriveTime.class,bpNmae));call.setUseSOAPAction(true);call.setSOAPActionURI("http://169.169.19.128:8070/axis/services/ShipArrive");call.addParameter("getArriveTimeRequest",XMLType.XSD_STRING,ParameterMode.IN);call.setReturnType(newQName("http://169.169.19.128:8070/axis/services/ShipArrive"),ShipArriveTime[].class);result=(ShipArriveTime[])call.invoke(newObject[]{devicenums});}catch(Exceptione){//TODO自动生成catch块e.printStackTrace();}//从框架中生成一个维护调用的实例。returnresult;}}报错2010-4-2116:20:31org.apache.axis.client.CallSEVERE:Exception:2010-4-2116:20:31org.apache.axis.client.CallSEVERE:MSG_EXCEPTION_LOGGEDAxisFaultfaultCode:{http://xml.apache.org/axis/}Server.userExceptionfaultString:org.xml.sax.SAXException:Nodeserializerdefinedforarraytype{urn:AnalyzeShipArriveTime}ShipArriveTimefaultActor:nullfaultDetail:stackTrace:org.xml.sax.SAXException:Nodeserializerdefinedforarraytype{urn:AnalyzeShipArriveTime}ShipArriveTimeatorg.apache.axis.encoding.ser.ArrayDeserializer.onStartElement(ArrayDeserializer.java:257)atorg.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:394)atorg.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:906)atorg.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:200)atorg.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:684)atorg.apache.axis.message.RPCElement.deserialize(RPCElement.java:241)atorg.apache.axis.message.RPCElement.getParams(RPCElement.java:265)atorg.apache.axis.client.Call.invoke(Call.java:1871)atorg.apache.axis.client.Call.invoke(Call.java:1777)atorg.apache.axis.client.Call.invoke(Call.java:1315)ata_test.AISTimeService.getAISMessage_New(AISTimeService.java:74)ata_test.AISTimeService.main(AISTimeService.java:26)org.xml.sax.SAXException:Nodeserializerdefinedforarraytype{urn:AnalyzeShipArriveTime}ShipArriveTimeatorg.apache.axis.AxisFault.makeFault(AxisFault.java:120)atorg.apache.axis.client.Call.invoke(Call.java:1874)atorg.apache.axis.client.Call.invoke(Call.java:1777)atorg.apache.axis.client.Call.invoke(Call.java:1315)ata_test.AISTimeService.getAISMessage_New(AISTimeService.java:74)ata_test.AISTimeService.main(AISTimeService.java:26)Causedby:org.xml.sax.SAXException:Nodeserializerdefinedforarraytype{urn:AnalyzeShipArriveTime}ShipArriveTimeatorg.apache.axis.encoding.ser.ArrayDeserializer.onStartElement(ArrayDeserializer.java:257)atorg.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:394)atorg.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:906)atorg.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:200)atorg.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:684)atorg.apache.axis.message.RPCElement.deserialize(RPCElement.java:241)atorg.apache.axis.message.RPCElement.getParams(RPCElement.java:265)atorg.apache.axis.client.Call.invoke(Call.java:1871)...4moreExceptioninthread"main"java.lang.NullPointerExceptionata_test.AISTimeService.main(AISTimeService.java:28)这句话应该有问题,传入的是String类型,不知道怎么改call.addParameter("getArriveTimeRequest",XMLType.XSD_STRING,ParameterMode.IN);