2012-12-06 13 views
2

從Android客戶端請求和檢索複雜類型時出現以下錯誤:服務器ksoap2錯誤檢索複雜類型服務器無法處理請求。 --->對象引用未設置爲對象的實例

服務器無法處理請求。 --->對象引用未設置爲對象的實例。' 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

問題解決了。

奇怪,但最後它是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"; 

這意味着,這是一些關於「/」命名空間中的

+0

可以請你告訴我你分配什麼XURL =? –

相關問題