2

我正在从 android 代码访问 wcf 服务
Web 服务是http://www.nbrm.mk/klservice/kurs.asmx 我的问题是 SoapObject 构造函数和 HttpTransportSE 对象的调用方法中的参数是什么?

这是代码

public class ExchangeMoneyMKActivity extends Activity {
private static final String SOAP_ACTION = "http://nbrm.mk/callService";

private static final String METHOD_NAME = "callService";

private static final String NAMESPACE = "http://nbrm.mk/";
private static final String URL = "http://www.nbrm.mk/klservice";
TextView txt;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    txt=(TextView)findViewById(R.id.txtView1);
    callService();
}
private void callService() {
    // TODO Auto-generated method stub
    try{
        SoapObject request=new SoapObject(NAMESPACE,METHOD_NAME);
        SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);

    envelope.dotNet=true;
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    androidHttpTransport.call(SOAP_ACTION, envelope);
    Object result = (Object)envelope.getResponse();
     txt.setText(result.toString());
    }


}
4

1 回答 1

0
 private static final String METHOD_NAME = "GetExchangeRate";

private static final String NAMESPACE = "http://www.nbrm.mk/klservice/";
private static final String SOAP_ACTION=NAMESPACE+METHOD_NAME;
private static final String URL = "http://www.nbrm.mk/klservice/kurs.asmx?kurs";

METHOD_NAME 是我从 Web 服务调用的方法的名称,NAMESPACE 是来自 url 的域 + 根文件夹

于 2012-05-31T08:18:47.003 回答