2012-04-03 11 views
0

私は多くを検索しましたが、何の助けも見つけられませんでした。だから、誰かがこの問題について光を当てることを望んでいます。Android KSoap2サーバ配列からの応答が空です

私はKSoapを使用してアレイを送りたいと、次のように私はこれを行う:

まず私はこのような石鹸オブジェクトを作成:

SoapObject request = new SoapObject(GENERICNAMESPACE, SOAP_METHOD_NAME); 

PropertyInfo attr = new PropertyInfo(); 
     attr.name = "patientLogin"; 
     attr.type = PropertyInfo.STRING_CLASS; 
     attr.namespace = GENERICNAMESPACE; 
     attr.setValue(patientId); 
     request.addProperty(attr); 

     //could be patientPassword 
     attr = new PropertyInfo(); 
     attr.name = "passwd"; 
     attr.type = PropertyInfo.STRING_CLASS; 
     attr.namespace = GENERICNAMESPACE; 
     attr.setValue(patientPassword); 
     request.addProperty(attr); 

     Vector vectorOfIDsRead = new Vector(); 
     vectorOfIDsRead.addElement(idsRead); 

     attr = new PropertyInfo(); 
     attr.name = "IDsRead"; 
     attr.type = PropertyInfo.STRING_CLASS; 
     attr.namespace = GENERICNAMESPACE; 
     attr.setValue(vectorOfIDsRead); 
     request.addProperty(attr); 

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
       SoapEnvelope.VER10); 
     envelope.setOutputSoapObject(request); 
     HttpTransportSE androidHttpTransport = new HttpTransportSE(GENERICURL); 
     androidHttpTransport.debug = true; 
     try { 
      androidHttpTransport.call(GENERICSOAP_ACTION_URL+"feedbackRead", envelope); 

      SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope 
        .getResponse(); 

      //log request 
      Log.e("SendFeedbackRead", "/////////////////////RequestDump////////////////////"); 
      Log.e("SendFeedbackRead", androidHttpTransport.requestDump.toString());  
      Log.e("SendFeedbackRead", "/////////////////////////////////////////"); 

      //log request 
      Log.e("SendFeedbackRead", "///////////////////ResponseDump/////////////////"); 
      Log.e("SendFeedbackRead", androidHttpTransport.responseDump.toString());   
      Log.e("SendFeedbackRead", "/////////////////////////////////////////"); 

      Log.e("FeedbackRead", 
        "FeedbackRead : " + resultsRequestSOAP.toString()); 

      return resultsRequestSOAP.toString(); 
     } catch (Exception e) { 
      Log.e("FeedbackRead", "SENDFEEDBACKREAD : " + e); 
      return e.getMessage(); 
     } 

要求ダンプは、私が遣わすことが明らかになった:

<v:Envelope xmlns:i="http://www.w3.org/1999/XMLSchema-instance" xmlns:d="http://www.w3.org/1999/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"><v:Header /> 
<v:Body> 
<n0:feedbackRead id="o0" c:root="1" xmlns:n0="http://testing.starburst.com/GenericWS"> 
<n0:patientLogin i:type="d:string">patient1</n0:patientLogin> 
<n0:passwd i:type="d:string">pat1</n0:passwd> 
<n0:IDsRead i:type="c:Array" c:arrayType="d:anyType[1]"><item i:type="d:string">1234test</item></n0:IDsRead></n0:feedbackRead> 
</v:Body> 
</v:Envelope> 

しかし、私はリストが空であると回答します。

feedbackRead、empty submitted ID list!

値が1つではありません。

誰かが正しい方向に向いていますか?

ありがとうございました。

答えて

0

私はあなたのエラーはここにあると思う:

Vector vectorOfIDsRead = new Vector(); 
vectorOfIDsRead.addElement(idsRead); 
attr = new PropertyInfo(); 
attr.name = "IDsRead"; 
attr.type = PropertyInfo.STRING_CLASS; 
attr.namespace = GENERICNAMESPACE; 
attr.setValue(vectorOfIDsRead); 
request.addProperty(attr); 

あなたはVectorとしてvectorOfIDsReadを宣言していますがSTRING_CLASSようなタイプを置きます。 それは次のようになります。

attr.setType(vectorOfIDsRead.getClass()); 

そして:

... create the envelope ... 
envelope.addMapping(NAMESPACE, "IDsRead", new Vector().getClass()); 

はそれがお役に立てば幸いです。また、これを見てください:http://code.google.com/p/ksoap2-android/wiki/CodingTipsAndTricks#sending/receiving_array_of_complex_types_or_primitives

EDIT:とにかく、あなたのSOAP_METHOD_NAMEのメソッドの署名を入れることができますか?

+0

入力いただきありがとうございます。私はあなたが私のコードで行った違いを変更しようとしましたが、それは私がチュートリアルに続いて助けになりませんでした。再び、結果はありません。メソッド名はSOAP_METHOD_NAME = "feedbackRead"です。 –

+0

このエラーはなぜ発生しますか?私には、ベクトルが空でないことは明らかです。サーバーがそれを見ない理由は何ですか?レスポンスが変更され、IDリストがサーバーごとに表示されます。04-03 19:22:17.082:E/SendFeedbackRead(18129): feedbackRead、空の送信IDリスト! idリストではないこれらの値は です。私は自分の問題に対する答えがそこにあると思う。 –

+0

メソッドシグネチャとは、「feedbackRead」メソッドのパラメータの数と型を意味します。 (私の英語は申し訳ありません)。私は配列を渡す他の方法を知らない。 –

関連する問題