在ksoap2中调用webservice

时间:2012-11-10 14:42:59

标签: android web-services ksoap2

我的网络服务有问题。我曾经在我的项目中调用不同的ws并且工作正常。

private static final String URL2 = "http://46.248.168.51/webservice/soap/endpoint/apikey/cb7f1f308e82ca2be8541d5ba829dc1e/?wsdl";
        private static final String METHOD_NAME2 = "getObjectList";
        private static final String SOAP_ACTION2 = "http://46.248.168.51/webservice/soap/endpoint/apikey/cb7f1f308e82ca2be8541d5ba829dc1e/getObjectList";
        private static final String NAMESPACE2 = "http://46.248.168.51/webservice/soap/endpoint/apikey/cb7f1f308e82ca2be8541d5ba829dc1e/";

    protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            setContentView(R.layout.pp);

            SoapObject request = new SoapObject(NAMESPACE2, METHOD_NAME2);

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);

            envelope.setOutputSoapObject(request);

            AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL2);

            httpTransport.debug = true;

            try {
                httpTransport.call(SOAP_ACTION2, envelope);

                SoapObject result = (SoapObject) envelope.getResponse();

            } catch (Exception e) {
                Log.d("e.getMessage()", e.getMessage());
                e.getMessage();
                e.printStackTrace();
            }

httpTransport.call返回错误

11-10 15:31:43.421:D / e.getMessage()(2550):预期:START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope(职位:START_TAG @ 2: 486 in java.io.InputStreamReader@4124e8d0)

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

由于您的代码可以与其他几种Web服务一起使用。我认为您只更改了URL,SOAP Action和Method。所以请检查天气,响应中包含popper SOAP消息。检查通信之间是否可以使用TCPMon。