0

http://i.stack.imgur.com/pK9rm.png http://i.stack.imgur.com/27Qj0.png

ksoap2 を使用して Web サービスに接続したいのですが、動作する例がありますが、アプリケーションを統合するにはどうすればよいですか?

public class WebServiceDemoActivity extends Activity {

  private static String SOAP_ACTION = "http://tempuri.org/UrunleriListele";
  private static String NAMESPACE = "http://tempuri.org/";
  private static String METHOD_NAME = "UrunleriListele";
  private static String URL = "http://services.annebebekavm.com/Service1.asmx?WSDL";

  Button btnFar,btnCel,btnClear;
  EditText txtFar,txtCel;

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    btnFar = (Button)findViewById(R.id.btnFar);

    txtFar = (EditText)findViewById(R.id.txtFar);


    btnFar.setOnClickListener(new View.OnClickListener()
    {
              @Override
              public void onClick(View v)
              {

              SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);       


              request.addProperty("Fahrenheit",txtFar.getText().toString());


              SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

              envelope.setOutputSoapObject(request);
              envelope.dotNet = true;

              try {
                    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);


                    androidHttpTransport.call(SOAP_ACTION, envelope);


                    SoapObject result = (SoapObject)envelope.bodyIn;

                    if(result != null)
                    {

                          txtFar.setText(result.getProperty(0).toString());
                    }
                    else
                    {
                          Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show();
                    }
              } catch (Exception e) {
                    e.printStackTrace();
              }
              }
        });

}

}

4

1 に答える 1

0

別のクライアントを使用することを再検討してください

http://code.google.com/p/android-ws-client/

必要なものをすべて作成できます。1つのアプリケーションで、生成クラスを使用してライブラリをプロジェクトにコピーします

これは本当に簡単に見える例です

    Service servis = new Service();
    ServiceSoap soap12 = servis.getServiceSoap12();
    LoginParams inParams = new LoginParams();
    inParams.setLogin("user");
    inParams.setPassword("pass");
    inParams.setStrategy(LoginStrategy.NOHASHPASS); // even enums are supported
    LoginState result = soap.authorize(inParams);

    result.isLogin(); // boolean if is succesfull
于 2013-01-29T20:06:21.127 に答える