2

从 Android 客户端请求和检索复杂类型时出现以下错误:

服务器无法处理请求。---> 对象引用未设置为对象的实例。faultactor:'null' 详细信息:org.kxml2.kdom.Node

wsdl:

<s:complexType name="AlFi_Rsp">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="RspResult" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="RspReason" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="RspExplain" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="RspInstruc" type="s:string"/>
</s:sequence>
</s:complexType>

<s:element name="wsVale">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="UserId" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Service" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="FiTerminal" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>

<s:element name="wsValeResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="wsValeResult" type="tns:AlFi_Rsp"/>
</s:sequence>
</s:complexType>
</s:element>

客户端:

    PropertyInfo pi1 = new PropertyInfo();PropertyInfo pi2 = new PropertyInfo();
    PropertyInfo pi3 = new PropertyInfo();


    pi1.setName(KEY_USERID);
    pi2.setName(KEY_SERVICE);
    pi3.setName(KEY_FITERMINAL);

    pi1.setValue(VAR_USERID);
    pi2.setValue(VAR_SERVICE);
    pi3.setValue(VAR_FITERMINAL);

    pi1.setType(PropertyInfo.STRING_CLASS);
    pi2.setType(PropertyInfo.STRING_CLASS);
    pi3.setType(PropertyInfo.STRING_CLASS);

    request.addProperty(pi1);
    request.addProperty(pi2);
    request.addProperty(pi3);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11); // put all required data into a soap
                                    // envelope
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request); // prepare request
    envelope.implicitTypes = true;
    envelope.addMapping(XNAMESPACE, "AlFi_Rsp", OutValeResponse.class);

    HttpTransportSE httpTransport = new HttpTransportSE(XURL);
    httpTransport.debug = true;
    httpTransport.call(XSOAP_ACTION, envelope); // send request

信封.bodyIn 检索上述错误。

请求转储:

<?xml version="1.0" encoding="UTF-8"?>
<v:Envelope xmlns:v="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/">
   <v:Header />
   <v:Body>
      <wsVale xmlns="https://.../AlCheq/">
         <UserId i:type="d:string">0</UserId>
         <Service i:type="d:string">0</Service>
         <FiTerminal i:type="d:string">0</FiTerminal>
      </wsVale>
   </v:Body>
</v:Envelope>

响应转储:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Server</faultcode>
         <faultstring>Server was unable to process request. ---> Object reference not set to an instance of an object.' faultactor: 'null' detail: org.kxml2.kdom.Node</faultstring>
         <detail />
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

InVale 和 OutValeResponse 类都实现了 KvmSerializable 方法。

我正在使用最后一个 ksoap2-android-assembly-3.0.0-RC.4-jar-with-dependencies 和 Android 2.2。有什么建议吗?,我已经搜索了好几天,但没有达到重点。

谢谢你的帮助

4

1 回答 1

1

问题解决了。

很奇怪,但最终这是 NAMESPACE 和 SOAP 操作的构造中的一个问题。我改变了这个

String METHOD_NAME = "method";
String NAMESPACE = "https://url/.../AlCheq/";
String SOAP_ACTION = NAMESPACE + METHOD_NAME;

为了这

String METHOD_NAME = "method";
String SOAP_ACTION = "https://url/.../AlCheq/method";

这意味着,它与 NAMESPACE 中的“/”有关

于 2012-12-15T08:26:38.263 回答