1

I am calling soap Web service in android but response is coming only anyType{}. But response data is not coming. it is only giving that much response how to get response data also.

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);
              }

             }
4

2 回答 2

0

写这个 lblResult1.setText(resultsRequestSOAP.getProperty(0).toString());

代替lblResult1.setText(resultsRequestSOAP.toString());

可能会帮助你。

如果它不起作用,则意味着您的 Web 服务没有返回任何响应,即您的 Web 服务没有从数据库中获取数据。

如果您需要有关此方面的更多帮助,请写信给我。

于 2012-06-12T11:56:12.783 回答
0
SoapObject request = new SoapObject(NAMESPACE, methodName);
            request.addProperty("Empid", "R001");

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.setOutputSoapObject(request);
            AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
            androidHttpTransport
            .setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            envelope.dotNet = true;
            androidHttpTransport.debug = true;
            androidHttpTransport.call(newSoapAction, envelope); 
            InputStream in = new ByteArrayInputStream(androidHttpTransport.responseDump.getBytes());    
    System.out.println("WS >>  Response: "+androidHttpTransport.responseDump); // you will get response overhere    
于 2012-06-11T04:43:58.727 回答