我在android中调用soap Web服务,但是响应仅仅是anyType {}。但回应数据并未到来。它只是给出如此多的响应以及如何获得响应数据。在android中调用soap webservice
private static String SOAP_ACTION = "http://tempuri.org/IService1/FindEmployee";
private static String NAMESPACE = "http://tempuri.org/";
private static String METHOD_NAME = "FindEmployee";
private static String URL = "http://192.168.1.9/Employee/Service1.svc?wsdl";
private TextView tv;
StringBuilder sb;
private XmlSerializer writer;
private TextView lblResult1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lblResult1 = (TextView) findViewById(R.id.textView1);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addAttribute("Empid", "R001");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
lblResult1.setText(resultsRequestSOAP.toString());
} catch (Exception e)
{
System.out.println("Error"+e);
}
}
使用addProperty代替addAtribute in line request.addAttribute(“Empid”,“R001”); – himanshu
尝试更改request.addProperty(“Empid”,“R001”);而不是request.addAttribute(“Empid”,“R001”); – Richa
你正在使用它的webservice它基于Java的还是.net baesd –