0
私はAndroid上でWebサービス「http://www.w3schools.com/webservices/tempconvert.asmx」を消費していますのと、その方法「CelsiusToFahrenheit」にアクセスしようとすると、マニフェストファイル内のインターネットアクセス権を追加しましたが、私はプロジェクトを実行したときにエミュレータが誤った結果の代わりに、摂氏から華氏への変換を示しています。どんな助けもありがとう。Androidのエミュレータは、Webサービスの結果を示し、「偽」の結果を与えない代わりに加え
public class FinalKsoap extends Activity {
/** Called when the activity is first created. */
public static final String NAMESPACE = "http://tempuri.org/";
public static final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
public static final String URL =
"http://www.w3schools.com/webservices/tempconvert.asmx";
public static final String METHOD_NAME = "CelsiusToFahrenheit";
TextView tv,tv1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView)findViewById(R.id.text01);
tv1 = (TextView)findViewById(R.id.text02);
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
Request.addProperty("Celsius", "32");
SoapSerializationEnvelope soapEnvelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
AndroidHttpTransport aht = new AndroidHttpTransport(URL);
try
{
aht.call(SOAP_ACTION, soapEnvelope);
SoapPrimitive result = (SoapPrimitive)soapEnvelope.getResponse();
tv.setText("Status : " + result);
}
catch(Exception e)
{
e.printStackTrace();
}
tv1.setText("Hellooooooo");
}
}
ありがとう:あなたは、Webサービスによって返されたデータが必要な場合
は、次のコードを使用する必要があります。私はそれをObject Response = resultsRequestSOAP.getProperty( "Celsius")として追加しました。 \t tv.setText(response.toString())。それでも同じエラー – Ashu
はあなただけ(だけ更新)の代わりに私のサンプルコードを使用する必要があるかもしれませ得ます。 – Robert
は再びあなたにロバートに感謝が、それはまだ続いてあなたの使用ksoapのライブラリーでもよい欠陥である代わりに、実際の結果 – Ashu