Мыльная ошибка Ksoap2 - java.lang.IllegalArgumentException: размер буфера <= 0 - PullRequest
0 голосов
/ 09 ноября 2018

Я звоню в сервис Soap Webservice. Ниже мой код. Это работает, когда я использую SOAPui, но не в моем запросе Java. Любая помощь приветствуется!

Во-первых, это запрос XML, который работает в мыльном интерфейсе -

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:Get_SubscriptionType_Server>
         <tem:username>aaeric@sellercloud.com</tem:username>
         <tem:authKey>tgJa3s8Bsh!</tem:authKey>
         <tem:typeEnum>SKUstack</tem:typeEnum>
      </tem:Get_SubscriptionType_Server>
   </soapenv:Body>
</soapenv:Envelope>

Во-вторых, это ответ в SOAPUI, который я ожидаю использовать и для Android -

> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">   
> <s:Body>
>       <Get_SubscriptionType_ServerResponse xmlns="http://tempuri.org/">
>          <Get_SubscriptionType_ServerResult xmlns:a="http://schemas.datacontract.org/2004/07/ScmsApi"
> xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
>             <a:WS_Object_Server_Subscription>
>                <a:DeltaServerUrl>http://cwa.delta</a:DeltaServerUrl>
>                <a:IsInternal>false</a:IsInternal>
>                <a:ServerID>LOCAL</a:ServerID>
>                <a:ServerUrl>http://cwa</a:ServerUrl>
>             </a:WS_Object_Server_Subscription>
>             <a:WS_Object_Server_Subscription>
>                <a:DeltaServerUrl>https://tt.delta.sellercloud.com</a:DeltaServerUrl>
>                <a:IsInternal>true</a:IsInternal>
>                <a:ServerID>TT</a:ServerID>
>                <a:ServerUrl>https://tt.cwa.sellercloud.com</a:ServerUrl>
>             </a:WS_Object_Server_Subscription>
>          </Get_SubscriptionType_ServerResult>
>          <message>?</message>
>       </Get_SubscriptionType_ServerResponse>    </s:Body> </s:Envelope>

наконец, это моя асинхронная задача, которая все это называет - открытый класс GetSubServerTypes расширяет AsyncTask {

    String NAMESPACE = "http://api.testscms.sellercloud.com/";
    String NAMESPACE2 ="http://tempuri.org/";
    String METHOD_NAME = "SecretService.svc";
    String METHODNAME2 = "'Get_SubscriptionType_Server";
    String SOAPACTION = "http://tempuri.org/ISecretService/Get_SubscriptionType_Server";
    String ContentType = "text/xml; charset=UTF-8";
    String TAG = "response";
    String URL = "http://api.testscms.sellercloud.com/SecretService.svc";



    @Override
    protected void onPreExecute(){
        Log.i(TAG, "onPreExecute");


    }


    @Override
    protected SoapObject doInBackground(String... strings) {

        SoapObject request = new SoapObject(NAMESPACE2, METHODNAME2);
        request.addProperty("username", "aaeric@sellercloud.com");
        request.addProperty("authKey", "tgJa3s8Bsh!");
        request.addProperty("typeEnum", "SKUstack");

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);
        envelope.dotNet=true;
        envelope.encodingStyle = SoapSerializationEnvelope.XSD;


        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        try
        {
            List<HeaderProperty> headerList = new ArrayList<>();
            headerList.add(new HeaderProperty("Content-Type", ContentType));
            headerList.add(new HeaderProperty("SOAPAction", SOAPACTION));


            androidHttpTransport.call(METHODNAME2, envelope, headerList);
            SoapObject response = (SoapObject)envelope.getResponse();
            int arraySize = response.getPropertyCount();
            Log.i(TAG, String.valueOf(arraySize));

        }
        catch(Exception e)
        {
            e.printStackTrace();
        }


        SoapObject result = null;
        try {
            result = (SoapObject)envelope.getResponse();
            String results = result.toString();
            Log.i(TAG, results);
        } catch (SoapFault soapFault) {
            soapFault.printStackTrace();
        }catch (Exception e){

        }

        return result;
    }


    @Override
    protected void onPostExecute(Object result) {
        super.onPostExecute(result);




    }
}

Вот журнал ошибок -

2018-11-09 09:03:12.785 13792-13792/com.mobile.skustack I/RegisterSlide1: Try/Catch - 
2018-11-09 09:03:12.785 13792-13792/com.mobile.skustack I/RegisterSlide1: CALL MADE HERE
2018-11-09 09:03:12.785 13792-13792/com.mobile.skustack I/RegisterSlide1: getSubServerTypes Called
2018-11-09 09:03:12.786 13792-13792/com.mobile.skustack I/response: onPreExecute
2018-11-09 09:03:12.807 13792-13923/com.mobile.skustack I/HttpTransportSE: requestData.length: 519
2018-11-09 09:03:12.860 13792-13923/com.mobile.skustack W/System.err: java.lang.IllegalArgumentException: Buffer size <= 0
2018-11-09 09:03:12.861 13792-13923/com.mobile.skustack W/System.err:     at java.io.BufferedInputStream.<init>(BufferedInputStream.java:203)
2018-11-09 09:03:12.861 13792-13923/com.mobile.skustack W/System.err:     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:274)
2018-11-09 09:03:12.861 13792-13923/com.mobile.skustack W/System.err:     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:133)
2018-11-09 09:03:12.861 13792-13923/com.mobile.skustack W/System.err:     at com.mobile.skustack.Register.GetSubscriptionTypeServers.SOAP.GetSubServerTypes.doInBackground(GetSubServerTypes.java:65)
2018-11-09 09:03:12.861 13792-13923/com.mobile.skustack W/System.err:     at com.mobile.skustack.Register.GetSubscriptionTypeServers.SOAP.GetSubServerTypes.doInBackground(GetSubServerTypes.java:20)
2018-11-09 09:03:12.861 13792-13923/com.mobile.skustack W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:333)
2018-11-09 09:03:12.861 13792-13923/com.mobile.skustack W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2018-11-09 09:03:12.862 13792-13923/com.mobile.skustack W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
2018-11-09 09:03:12.862 13792-13923/com.mobile.skustack W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2018-11-09 09:03:12.862 13792-13923/com.mobile.skustack W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2018-11-09 09:03:12.862 13792-13923/com.mobile.skustack W/System.err:     at java.lang.Thread.run(Thread.java:764)
...