服务器检索complextype Server的ksoap2错误无法处理请求。 --->你调用的对象是空的

时间:2012-12-06 20:11:26

标签: android ksoap2 android-ksoap2

从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

envelope.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。有什么建议吗?我已经搜索了好几天,但没有达到目的。

感谢您的帮助

1 个答案:

答案 0 :(得分: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中的“/”有关。