我在从响应中获取Date
( ) 对象时遇到问题。这是响应 XML:java.util.Date
ksoap2
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header></s:Header>
<s:Body>
<UpdateLocationResponse xmlns="http://tempuri.org/">
<UpdateLocationResult>2012-05-07T13:34:34.7693883-04:00</UpdateLocationResult>
</UpdateLocationResponse>
</s:Body>
</s:Envelope>
这是我用来初始化信封和请求的代码(出于安全原因,使用* *代替真实姓名):
static final String NAMESPACE = "http://tempuri.org/";
static final String URL = "http://****************.svc";
envelope.addMapping(NAMESPACE, "UpdateLocationResult", Date.class,
new MarshalDate());
MarshalDate mdate = new MarshalDate();
mdate.register(envelope);
envelope.implicitTypes = true;
HttpTransportSE trans = new HttpTransportSE(URL);
trans.debug = true;
trans.call(SOAP_ACTION, envelope);
Object r = envelope.getResponse(); // r is always SoapPrimitive!!!
// I want it to be a java.util.Date
我尝试了命名空间、属性名称和编组器的所有组合,但无济于事。我总是得到SoapPrimitive
回报envelope.getResponse()
我究竟做错了什么?