English 中文(简体)
Webservice SOAP in Anders
原标题:Webservice SOAP in Android

I m开始在安乐斯使用网络服务,我沿用这个理论:

package com.android.webservices;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class AddNumbersWSActivity extends Activity {
/** Called when the activity is first created. */

private String METHOD_NAME = "addTwoNumbers"; // our webservice method name
private String NAMESPACE = "http://sencide.com"; // Here package name in webservice with reverse order.
private String SOAP_ACTION = "http://sencide.com/addTwoNumbers"; // NAMESPACE + method name
private static final String URL = "http://192.168.1.214:8080/axis2/services/FirstWebService?wsdl"; // you must use ipaddress here, don’t use Hostname or localhost

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

    Button addButton = (Button) findViewById(R.id.button1);

    addButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            try
            {
                SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
                EditText num1 = (EditText) findViewById(R.id.editText1);
                EditText num2 = (EditText) findViewById(R.id.editText2);
                request.addProperty("firstNumber", Integer.valueOf(num1.getText().toString()));
                request.addProperty("secondNumber", Integer.valueOf(num2.getText().toString()));
                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
//                  envelope.dotNet = true;
                    envelope.setOutputSoapObject(request);
                    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
                    androidHttpTransport.call(SOAP_ACTION,envelope);
                    Object result = envelope.getResponse();
                    System.out.println("Result : " + result.toString());
                    ((TextView) findViewById (R.id.textView4)).setText(result.toString());
                } catch (Exception E) {
                    E.printStackTrace();
                }
            }
        });

    }
}

但现在我对安的世界首脑会议的消费有一些问题:

  1. As I can see here, the kSOAP2 library is deprecated... Should I continue to use this library or I need another tool? If yes, which one?
  2. Is it possible to know the NAMESPACE, METHOD_NAME, SOAP_ACTION using only the WSDL of the service?
  3. Can I generate some code automatically using WSDL (like WSDL2Java tool that is used for Java applications)?
  4. At the addProperty(String name, Object value) method, can I used arbitrary name or it should follow a rule?

提前感谢!

最佳回答

奥帕奇轴为 Java,不在安乐平台工作。 Ksoap2图书馆是该图书馆的候补图书馆,大部分是使用工具,在安康使用网络服务。 贵问题:

1 - Today [15.5.2012] i can see the last commit only 4 days ago in here

2 - Yes it is possible. The namespace describes like as follow:

<wsdl:definitions targetNamespace="http://tempuri.org/">

方法名称如下:

<s:element name="YourMethodName">

具体来说,《国家行动计划》的行动包括:

3 - As I know, there is no well written project for now.

4 - 应当遵循一项规则,该规则必须贴切于妇女地位部的属性和案件敏感性。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签