大侠帮忙看webservice调用存在什么问题
wsdl 地址 :http://169.169.19.128:8070/axis/services/ShipArrive?wsdl内容如下:
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="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">
- <!--
WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)
-->
- <wsdl:types>
+ <schema targetNamespace="http://169.169.19.128:8070/axis/services/ShipArrive" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="urn:AnalyzeShipArriveTime" />
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType name="ArrayOf_xsd_string">
- <complexContent>
- <restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]" />
</restriction>
</complexContent>
</complexType>
- <complexType name="ArrayOf_tns1_ShipArriveTime">
- <complexContent>
- <restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="tns1:ShipArriveTime[]" />
</restriction>
</complexContent>
</complexType>
</schema>
- <schema targetNamespace="urn:AnalyzeShipArriveTime" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://169.169.19.128:8070/axis/services/ShipArrive" />
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType name="ShipArriveTime">
- <sequence>
<element name="callsign" nillable="true" type="xsd:string" />
<element name="devicenum" nillable="true" type="xsd:string" />
<element name="did" type="xsd:int" />
<element name="dlat" nillable="true" type="xsd:string" />
<element name="dlon" nillable="true" type="xsd:string" />
<element name="eshipname" nillable="true" type="xsd:string" />
<element name="mmsi" nillable="true" type="xsd:string" />
<element name="regionid" nillable="true" type="xsd:string" />
<element name="shiplength" nillable="true" type="xsd:string" />
<element name="shipname" nillable="true" type="xsd:string" />
<element name="utc" nillable="true" type="xsd:string" />
</sequence>
</complexType>
</schema>
</wsdl:types>
- <wsdl:message name="getArriveTimeResponse">
<wsdl:part name="getArriveTimeReturn" type="impl:ArrayOf_tns1_ShipArriveTime" />
</wsdl:message>
- <wsdl:message name="getArriveTimeRequest">
<wsdl:part name="devicenums" type="impl:ArrayOf_xsd_string" />
</wsdl:message>
- <wsdl:portType name="ShipArriveAction">
- <wsdl:operation name="getArriveTime" parameterOrder="devicenums">
<wsdl:input message="impl:getArriveTimeRequest" name="getArriveTimeRequest" />
<wsdl:output message="impl:getArriveTimeResponse" name="getArriveTimeResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="ShipArriveSoapBinding" type="impl:ShipArriveAction">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="getArriveTime">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="getArriveTimeRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://action.soa.com" use="encoded" />
</wsdl:input>
- <wsdl:output name="getArriveTimeResponse">
<wsdlsoap:body encodingStyle="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:service name="ShipArriveActionService">
- <wsdl:port binding="impl:ShipArriveSoapBinding" name="ShipArrive">
<wsdlsoap:address location="http://169.169.19.128:8070/axis/services/ShipArrive" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
代码如下
/*
* 创建日期 2006-10-19
*
* 更改所生成文件模板为
* 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
package a_test;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.encoding.XMLType;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
/**
* 调用AIS提供给CBOS的AIS时间的WebService接口
*
* @author Administrator
*
* 更改所生成类型注释的模板为 窗口 > 首选项 > Java > 代码生成 > 代码和注释
*/
public class AISTimeService {
public static void main(String[] args) {
ShipArriveTime[] a = getAISMessage_New(new String[] { "2329" });
System.out.println(a.length);
}
public static ShipArriveTime[] getAISMessage_New(String[] devicenums) {
ShipArriveTime[] result = null;
try {
String endpoint = "http://169.169.19.128:8070/axis/services/ShipArrive";
org.apache.axis.client.Service service = new org.apache.axis.client.Service();// 建立请求服务框架实例。
/*
* org.apache.axis.client.Service实现JAX-RPCs javax.xml.rpc.Services接口
* 该接口充当产生下面提到的org.apache.axis.client.Call实例 的角色。
*/
org.apache.axis.client.Call call;
call = (org.apache.axis.client.Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new javax.xml.namespace.QName(
"http://169.169.19.128:8070/axis/services/ShipArrive",
"getArriveTime"));// 设置需要调用的函数名称
/*
* org.apache.axis.client.Call实现了JAX-RPCs javax.xml.rpc.Call接口。
*/
QName bpNmae = new QName(
"http://169.169.19.128:8070/axis/services/ShipArrive",
"ShipArriveTime");
call.registerTypeMapping(ShipArriveTime.class, bpNmae,
new BeanSerializerFactory(ShipArriveTime.class, bpNmae),
new BeanDeserializerFactory(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(new QName(
"http://169.169.19.128:8070/axis/services/ShipArrive"),
ShipArriveTime[].class);
result = (ShipArriveTime[]) call
.invoke(new Object[] { devicenums });
} catch (Exception e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}// 从框架中生成一个维护调用的实例。
return result;
}
}
报错
2010-4-21 16:20:31 org.apache.axis.client.Call
SEVERE: Exception:
2010-4-21 16:20:31 org.apache.axis.client.Call
SEVERE: MSG_EXCEPTION_LOGGED
AxisFault
faultCode: {http://xml.apache.org/axis/}Server.userException
faultString: org.xml.sax.SAXException: No deserializer defined for array type {urn:AnalyzeShipArriveTime}ShipArriveTime
faultActor: null
faultDetail:
stackTrace: org.xml.sax.SAXException: No deserializer defined for array type {urn:AnalyzeShipArriveTime}ShipArriveTime
at org.apache.axis.encoding.ser.ArrayDeserializer.onStartElement(ArrayDeserializer.java:257)
at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:394)
at org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:906)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:200)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:684)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:241)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:265)
at org.apache.axis.client.Call.invoke(Call.java:1871)
at org.apache.axis.client.Call.invoke(Call.java:1777)
at org.apache.axis.client.Call.invoke(Call.java:1315)
at a_test.AISTimeService.getAISMessage_New(AISTimeService.java:74)
at a_test.AISTimeService.main(AISTimeService.java:26)
org.xml.sax.SAXException: No deserializer defined for array type {urn:AnalyzeShipArriveTime}ShipArriveTime
at org.apache.axis.AxisFault.makeFault(AxisFault.java:120)
at org.apache.axis.client.Call.invoke(Call.java:1874)
at org.apache.axis.client.Call.invoke(Call.java:1777)
at org.apache.axis.client.Call.invoke(Call.java:1315)
at a_test.AISTimeService.getAISMessage_New(AISTimeService.java:74)
at a_test.AISTimeService.main(AISTimeService.java:26)
Caused by: org.xml.sax.SAXException: No deserializer defined for array type {urn:AnalyzeShipArriveTime}ShipArriveTime
at org.apache.axis.encoding.ser.ArrayDeserializer.onStartElement(ArrayDeserializer.java:257)
at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:394)
at org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:906)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:200)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:684)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:241)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:265)
at org.apache.axis.client.Call.invoke(Call.java:1871)
... 4 more
Exception in thread "main" java.lang.NullPointerException
at a_test.AISTimeService.main(AISTimeService.java:28)
这句话应该有问题,传入的是String类型,不知道怎么改
call.addParameter("getArriveTimeRequest", XMLType.XSD_STRING,
ParameterMode.IN);
补充:企业软件 , 中间件