我从android代码中访问wcf服务 网络服务是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());
}
}
答案 0 :(得分: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是我从网络服务调用的方法的名称,NAMESPACE是来自网址的域+根文件夹