SoapSerializationEnvelope org.xmlpull.v1.XmlPullParserException:expected:START_TAG

时间:2014-07-16 10:27:03

标签: android ksoap2

我得到了预期:START_TAG {http ....}

我无法找出错过的地方,

我正在使用.Net webservice

Belew是我的代码&错误 -

private static String NAMESPACE = "http://product.a.b.com/";
// Add a special character other than ':'
private static String METHOD_NAME = "prod|getProductDetailByCommercialRef";
private static String SOAP_ACTION = NAMESPACE + METHOD_NAME;

//下面的行是工作文件

private static String URL = "http://test.a.b.com/bsl-fo-service/ProductService?wsdl";

public String getSoapRequest(String refID)
{
    try
    {
        System.out.println("CommercialRef = "+refID);
        SoapObject request = new SoapObject("", METHOD_NAME);
        request.addSoapObject(getScopeBean());
        request.addSoapObject(getLocaleBean());
        request.addProperty("commercialRef", refID);
        request.addProperty("rangeId", "");

        // Instantiating ExtendedSOAPEnvelope
        SoapSerializationEnvelope envelope = new ExtendedSOAPEnvelope(SoapEnvelope.VER11, NAMESPACE);

        envelope.dotNet = true;
        envelope.implicitTypes = true;
        envelope.setAddAdornments(false);
        envelope.setOutputSoapObject(request);

        CustomHttpTransportSE ht = new CustomHttpTransportSE(URL);
        ht.debug = true;

        ht.call(SOAP_ACTION, envelope);
        System.out.println("Request ID   ::::: "+refID);


        **System.out.println("Request Dump ::::: " + ht.requestDump);
        System.out.println("Response Dump ::::: " + ht.responseDump);**

        return ht.responseDump;
        // final SoapPrimitive response = (SoapPrimitive) envelope
        // .getResponse();

        // envelope.getResponse();
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;

}

使用KsopaVer-12

获取错误 -

07-16 14:33:04.870: W/System.err(19902): org.xmlpull.v1.XmlPullParserException:     expected: START_TAG {http://www.w3.org/2003/05/soap-envelope}Envelope (position:START_TAG <    {http://schemas.xmlsoap.org/soap/envelope/}soap:Envelope>@1:71 in      java.io.InputStreamReader@4328b7b0) 
07-16 14:33:04.870: W/System.err(19902):    at org.kxml2.io.KXmlParser.require (KXmlParser.java:2056)
07-16 14:33:04.870: W/System.err(19902):    at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:128)
07-16 14:33:04.870: W/System.err(19902):    at org.ksoap2.transport.Transport.parseResponse(Transport.java:118)
07-16 14:33:04.870: W/System.err(19902):    at  com.schneider.soaphelper.CustomHttpTransportSE.call(CustomHttpTransportSE.java:204)
07-16 14:33:04.870: W/System.err(19902):    at com.schneider.soaphelper.CustomHttpTransportSE.call(CustomHttpTransportSE.java:63)
07-16 14:33:04.870: W/System.err(19902):    at com.schneider.soaphelper.CustomHttpTransportSE.call(CustomHttpTransportSE.java:58)
07-16 14:33:04.870: W/System.err(19902):    at com.schneider.soaphelper.OPSSoapHelper.getSoapRequest(OPSSoapHelper.java:43)
07-16 14:33:04.870: W/System.err(19902):    at com.schneider.dialog.OPSCustomDialog$1SendOPSReqAsyncTask.doInBackground(OPSCustomDialog.java:93)
07-16 14:33:04.870: W/System.err(19902):    at com.schneider.dialog.OPSCustomDialog$1SendOPSReqAsyncTask.doInBackground(OPSCustomDialog.java:1)
07-16 14:33:04.870: W/System.err(19902):    at android.os.AsyncTask$2.call(AsyncTask.java:288)
07-16 14:33:04.870: W/System.err(19902):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
07-16 14:33:04.870: W/System.err(19902):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
07-16 14:33:04.870: W/System.err(19902):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
07-16 14:33:04.870: W/System.err(19902):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
07-16 14:33:04.870: W/System.err(19902):    at java.lang.Thread.run(Thread.java:841)

向服务器代码发送请求如下 -

private void sendOpsRequest()
{

    class SendOPSReqAsyncTask extends AsyncTask<String, Void, String>
    {
        @Override
        protected void onPreExecute()
        {
            progressBar.setVisibility(View.VISIBLE);
        }

        @Override
        protected String doInBackground(String... params)
        {
            OPSSoapHelper helper = new OPSSoapHelper();
            System.out.println("Request ID Before sending request - refID  ::::: "+refID);
            //refID = refID.replace("http:", "http://");
            String response = helper.getSoapRequest(refID);
            return response;
        }

        protected void onPostExecute(String soapResponse)
        {
            progressBar.setVisibility(View.GONE);

            if (soapResponse != null)
            {
                InputStream inputStream = new ByteArrayInputStream(soapResponse.getBytes());

                OPSXmlParser opsXmlPullParser = new OPSXmlParser();
                try
                {
                    opsBean = opsXmlPullParser.parse(inputStream);

                    if (opsBean != null)
                    {
                        System.out.println("Size>>>>>>>>>>> " + opsBean.size());

                        String imagePath = Constants.catchStoragePath(mainContext) + "/" + refID + Constants.IMAGE_FORMAT;
                        // TODO
                        // Bitmap productBitmap = ((BaseActivty) mainContext).convertBitmap(imagePath);

                        // productImage.setImageBitmap(productBitmap);

                        listsFragment.mImageFetcherLarge.loadImage(imagePath, productImage);


                        // get the listview
                        expListView = (ExpandableListView) findViewById(R.id.opsList);

                        listAdapter = new OPSExpandableListAdapter(mainContext, opsBean);
                        expListView.setAdapter(listAdapter);
                        expListView.setGroupIndicator(null);
                        layout.setVisibility(View.VISIBLE);
                        for (int i = 0; i < listAdapter.getGroupCount(); i++)
                        {
                            expListView.expandGroup(i);
                        } 
                    }
                }
                catch (XmlPullParserException e)
                {
                    Log.e("XmlPullParserException- OPS Parsing", e.getMessage());
                }
                catch (IOException e)
                {
                    Log.e("IOException in closing stream - OPS Parsing", e.getMessage());
                }
                finally
                {
                    try
                    {
                        inputStream.close();
                    }
                    catch (IOException e)
                    {
                        Log.e("IOException in closing stream - OPS Parsing", e.getMessage());
                    }
                }
            }
            else
            {
                CustomDialogBox dialog = new CustomDialogBox(mainContext);
                dialog.setMessage(mainContext.getString(R.string.no_ops_response_received));
                // dialog.show();
            }
        }
    }

    SendOPSReqAsyncTask sendPostReqAsyncTask = new SendOPSReqAsyncTask();
    if (WebserviceUtil.isNetworkAvailable(mainContext))
    {
        sendPostReqAsyncTask.execute();
    }
    else
    {
        if (customDialogBox == null)
        {
            customDialogBox = new CustomDialogBox(mainContext);
        }
        customDialogBox.setMessage(mainContext.getString(R.string.network_unavailable));

    }

}

1 个答案:

答案 0 :(得分:0)

07-16 14:33:04.870:W / System.err(19902):org.xmlpull.v1.XmlPullParserException:expected:START_TAG {http://www.w3.org/2003/05/soap-envelope}信封(位置:START_TAG&lt; {{{3肥皂:信封&gt; java.io.InputStreamReader@4328b7b0中的@ 1:71)

意味着XML解析器不会返回SOAP,但会有不同的东西(可能是任何东西,例如html错误页面)。 在您的情况下,我尝试使用另一个soap客户端重现该问题。为此,请记录/转储来自您提到的应用程序的请求,并使用其他工具(soapUI或curl from commandline)发送请求并检查会发生什么。