CIAO皆、 使用してSOAP WebサービスからのネストされたXMLノードを受信しないでください。私は誰かが私を助けることを願っています! 私は解決策のためのウェブで検索、しかしeveriting私は私のために動作しません発見しました。これはシナリオです: 私は、.NET WSに要求を作るしようとしています。要求は単純であるが、応答は以下のネストされた2レベルのXML構造である:、私はこの質問について愚かになってきていますksoap2
<soap:Body>
<ProgettoResponse xmlns="http://tempuri.org/">
<ProgettoResult xmlns="">
<Success>boolean</Success>
<Message>string</Message>
<Progetto>
<Titolo>string</Titolo>
<Descrizione>string</Descrizione>
</Progetto>
</ProgettoResult>
</ProgettoResponse>
</soap:Body>
を私はWSからの受信応答は常に: anyTypeを{成功= TRUE。メッセージ= OK; PROGETTO = anyTypeを{};}
この状況は、ノードが常に空でlogcat
によって確認されます。私は、同じパラメータで呼び出されたWSが完全な構造を(ウェブアプリケーションと広告アプリのi-phone経由で)送信することをうれしく思います。私はアンドロイド2.1/2.2環境でksoap2-アンドロイド・アセンブリ-2.6.0-ジャーとの依存関係を使用しています
。
これは私がWSを呼び出すために使用するクラスです:
package feronia.culturando.android;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
public class webService
{
public final String SOAP_ACTION = "http://tempuri.org/Progetto";
public final String METHOD_NAME = "Progetto";
public final String NAMESPACE = "http://tempuri.org/";
public final String URL = "http://www.feronia.it/intra/webservice/wsCulturando.asmx";
public webService()
{
}
public String Call(String a,int b)
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo pi=new PropertyInfo();
pi.setName("a");
pi.setValue(a);
pi.setType(String.class);
request.addProperty(pi);
pi=new PropertyInfo();
pi.setName("b");
pi.setValue(b);
pi.setType(Integer.class);
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
envelope.addMapping(NAMESPACE, "ProgettoResult", new ProgettoResult().getClass());
envelope.addMapping(NAMESPACE, "Progetto", new Progetto().getClass());
HttpTransportSE httpTransport = new HttpTransportSE(URL);
SoapObject response=null;
String totalCount = "";
try
{
httpTransport.call(SOAP_ACTION, envelope);
response = (SoapObject)envelope.getResponse();
//totalCount = response.getPropertyAsString("Progetto").toString();
//totalCount = response.toString();
//Progetto prog = response.getProgetto();
totalCount = response.toString();
////////////Progetto prog = (Progetto) response.getProperty(3);
//////////////totalCount = prog.toString();
}
catch (Exception e)
{
e.printStackTrace();
}
//String totalCount = response.getProperty("Success").toString();
//Object totalCount = response.getProperty(Progetto.class);
//Object resultData = (SoapObject)response.getProperty(2);
return "risposta dal WS = " + totalCount;
}
}
、これらはProgettoResultとPROGETTO
package feronia.culturando.android;
import java.util.Hashtable;
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
public class ProgettoResult implements KvmSerializable {
private String pSuccess;
private String pMessage;
private Progetto pProgetto;
public Progetto getProgetto()
{
return pProgetto;
}
public void setProgetto(Progetto Progetto)
{
this.pProgetto = Progetto;
}
public ProgettoResult()
{
this.setSuccess("");
this.setMessage("");
}
public ProgettoResult(String Success, String Message)
{
this.setSuccess(Success);
this.setMessage(Message);
}
public Object getProperty(int arg0)
{
switch(arg0)
{
case 0:
return this.getSuccess();
case 1:
return this.getMessage();
case 2:
return this.getProgetto();
}
return null;
}
public int getPropertyCount()
{
return 3;
}
public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info)
{
switch(index)
{
case 0:
info.name="Success";
info.type=PropertyInfo.STRING_CLASS;
break;
case 1:
info.name="Message";
info.type=PropertyInfo.STRING_CLASS;
break;
case 2:
info.name="Progetto";
info.type=Progetto.class;
break;
default:
break;
}
}
public void setProperty(int index, Object value)
{
switch(index)
{
case 0:
this.setSuccess(value.toString());
break;
case 1:
this.setMessage(value.toString());
break;
case 2:
this.setProgetto((Progetto)value);
break;
default:
break;
}
}
/*********** GET - SET *****************/
public void setSuccess(String Success)
{
this.pSuccess = Success;
}
public String getSuccess()
{
return pSuccess;
}
public void setMessage(String Message)
{
this.pMessage = Message;
}
public String getMessage()
{
return pMessage;
}
}
と
package feronia.culturando.android;
import java.util.Hashtable;
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
public class Progetto implements KvmSerializable{
private String pTitolo;
private String pDescrizione;
public Progetto()
{
this.setTitolo("");
this.setDescrizione("");
}
public Progetto(String t,String d)
{
this.setTitolo(t);
this.setDescrizione(d);
}
public Object getProperty(int index)
{
switch(index)
{
case 0:
return this.getTitolo();
case 1:
return this.getDescrizione();
}
return null;
}
public int getPropertyCount()
{
return 2;
}
public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info)
{
switch(index)
{
case 0:
info.name="Titolo";
info.type=PropertyInfo.STRING_CLASS;
break;
case 1:
info.name="Descrizione";
info.type=PropertyInfo.STRING_CLASS;
break;
default:
break;
}
}
public void setProperty(int index, Object value)
{
switch(index)
{
case 0:
this.setTitolo(value.toString());
break;
case 1:
this.setDescrizione(value.toString());
break;
default:
break;
}
}
/*********** GET - SET *****************/
public void setTitolo(String Titolo)
{
this.pTitolo = Titolo;
}
public String getTitolo()
{
return pTitolo;
}
public void setDescrizione(String Descrizione)
{
this.pDescrizione = Descrizione;
}
public String getDescrizione()
{
return pDescrizione;
}
}
のためのクラスです誰誰があります間違いはどこにあるのですか?あなたができるなら私を助けてください!
============================================== ==================================
はあなたに私にあなたの興味のために非常に多くのヒマンシュとshadescoに感謝します質問!!ここに私の活動クラスのコードがありますが、それは呼び出し関数です。 int bは、データがWebにリクエストされているプロジェクト(progetto = 2)の単純なcheコードですが、この時点では、呼び出しの文字列aは重要ではありません(まだコントロールは実装されていません。サービス。
要求:
<soap:Body>
<Progetto xmlns="http://tempuri.org/">
<Guid>string</Guid>
<Id_Progetto>int</Id_Progetto>
</Progetto>
</soap:Body>
呼び出し元のクラスのコード:私が正しくエミュレータ
package feronia.culturando.android;
import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.widget.TextView;
public class Presentazione extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.presentazione);
webService cs=new webService();
String appo=cs.Call("oi", 2);
TextView pres_prog = (TextView) findViewById(R.id.pres_prog);
pres_prog.setText(Html.fromHtml(appo));
}
}
上の(間違った)応答を見ることができると考えて、私はそれが重要であると考えていませんしかし、この方法の完全な応答は次のとおりです。
<soap:Body>
<ProgettoResponse xmlns="http://tempuri.org/">
<ProgettoResult xmlns="">
<Success>boolean</Success>
<Message>string</Message>
<Progetto>
<Titolo>string</Titolo>
<Descrizione>string</Descrizione>
<Immagini>
<Immagine xsi:nil="true" />
<Immagine xsi:nil="true" />
</Immagini>
</Progetto>
</ProgettoResult>
</ProgettoResponse>
別のブロック が、要求PROGETTO = 2応答のこの部分があると、プロジェクトが関連付けられた画像と
<Immagini />
が発生していないタグを有していない(存在しないです。私はステップバイステップで行くつもりです...totalCount
は何
ProgettoResult pr = null;
try {
httpTransport.call(SOAP_ACTION, envelope);
pr = (ProgettoResult)envelope.getResponse();
} catch (Exception e) {
e.printStackTrace();
}
:
どこアクティビティクラスですか?そのクラスのコードを投稿してください。 – himanshu
@Franco何ですか:String a、int bのですか?それらは要求に関連していますか?もしあなたが送っているものをより良く理解するためにリクエストのSOAP xmlを投稿する – shadesco
@Francoまた、関数 "Call(String a、int b)"をどのように呼び出すのですか? – shadesco