我使用jaxws
中的myeclipse5.1.1GA
创建了网络服务,我可以在eclipse indigo64 bit
中调用此网络服务方法。
问题是,当我可以在web服务中设置webmethod的参数时
使用soap对象的setparameter()
方法,但它没有在webservice的webmethod中设置。
如何设置参数:
public class MyAsyncTask extends AsyncTask<String, Void, Object> {
private String METHOD_NAME="";
private String NAMESPACE="http://ws.easyway3e.com/";
private String SOAP_ACTION="";
private static final String URL="http://10.0.2.2:8080/WebService/DBConn?wsdl";
@Override
protected Object doInBackground(String... params) {
System.out.println("Call-1 -----"+params[0]+","+params[1]+",
"+params[2]+","+params[3]);
METHOD_NAME="openConnection";
SoapObject request=new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty(DRIVERNAME);
request.addProperty("d_Name",params[0]);
request.addProperty("c_String",params[1]);
request.addProperty("u_Name",params[2]);
request.addProperty("pass",params[3]);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope
(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
System.out.println(envelope.bodyOut.toString());
HttpTransportSE androidHttpTranportSE=new HttpTransportSE(URL);
androidHttpTranportSE.setXmlVersionTag("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>");
try {
SOAP_ACTION = NAMESPACE + METHOD_NAME;
androidHttpTranportSE.call(SOAP_ACTION, envelope);
SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
System.out.println(" Connection is =>"+resultsRequestSOAP.toString());
} catch (IOException e) { e.printStackTrace(); }
Object result = null;
try { result = envelope.getResponse(); }
return result;
}
答案 0 :(得分:0)
你已经回答了自己的问题。你已经提出了
request.addProperty("d_Name",params[0]);
这是向SOAP webservice添加参数的正确方法。
您还可以参考以下链接清除您在android中的webservice概念。
web service in android/eclipse
http://www.ibm.com/developerworks/webservices/library/ws-android/index.html