ksoap2:java.lang.IllegalArgumentException异常:大小< = 0,同时使htt​​p.call [英] ksoap2 : java.lang.IllegalArgumentException: size <= 0 while making a http.call

查看:459
本文介绍了ksoap2:java.lang.IllegalArgumentException异常:大小< = 0,同时使htt​​p.call的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用我的Ksoap2 4.03的Andr​​oid设备连接到基于dot.net web服务。

I want to connect to a dot.net based Webservice with my Android 4.03 Device using Ksoap2.

我的问题是,当我打电话SOAP请求我得到这个异​​常:

My problem is when i call the soap request i get this exception:

11-16 08:35:08.649: W/System.err(6392): java.lang.IllegalArgumentException: size <= 0
11-16 08:35:08.649: W/System.err(6392): at java.io.BufferedInputStream.<init>(BufferedInputStream.java:94)
11-16 08:35:08.649: W/System.err(6392): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:226)
11-16 08:35:08.649: W/System.err(6392):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:114)
11-16 08:35:08.649: W/System.err(6392):     at at.jesenko.eDoc.MainActivity$1.run(MainActivity.java:48)

使用code IM

The Code im using

    final String url = "http://server:9007/DWService?wsdl";
    final String NAMESPACE = "http://tempuri.org/";
    final String METHOD_NAME ="Login";
    final String SOAP_ACTION="http://tempuri.org/Login";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Thread loginThread = new Thread(){

            @Override
            public void run() {

                try {


                    SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
                    Request.addProperty("userName", "demo");
                    Request.addProperty("password", "demo1234");
                    Request.addProperty("organization", "Peters Engineering");

                    SoapSerializationEnvelope Envelope = new SoapSerializationEnvelope(
                            SoapEnvelope.VER12); 
                    Envelope.dotNet=true;
                    Envelope.setOutputSoapObject(Request);


                    HttpTransportSE ht = new HttpTransportSE(url);
                    ht.debug = true;
                    ht.call(SOAP_ACTION, Envelope);

                    SoapObject response = (SoapObject) Envelope.getResponse();
                    final String SessionID = response.getProperty("SessionID").toString();


                runOnUiThread(new Runnable() {

                    public void run() {

                        TextView tv = (TextView) findViewById(R.id.textView1);
                        tv.setText(SessionID);

                    }
                });

                } catch (Exception e) {

                    e.printStackTrace();

                }   

            }


    };
    loginThread.start();
}

下面,我要调用的WSDL文件的一部分:

Here the part of the wsdl file which i want to call:

<wsdl:definitions name="DWService" targetNamespace="http://tempuri.org/">
 <wsdl:types>
  <xsd:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
   <xsd:element name="Login">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element minOccurs="0" name="userName" nillable="true" type="xsd:string"/> 
      <xsd:element minOccurs="0" name="password" nillable="true" type="xsd:string"/>
      <xsd:element minOccurs="0" name="organization" nillable="true" type="xsd:string"/> 
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>

我不有KSOAP和Web服务多expierience,所以我希望有人能够帮助我解决这个问题:)

I don´t have much expierience with Ksoap and Web-Services so i hope someone could help me solving this problem :)

问候。

修改

我trye​​d使用SVC来代替 - >同样的错误:(

i tryed using ?svc instead -> same errors :(

修改

WSDL文件,这里的标题也许我的名字空间是假的。

Here the Header of the WSDL file maybe my Namespace is false

    <?xml version="1.0" encoding="UTF-8"?>
    -<wsdl:definitions xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" 
xmlns:wsa10="http://www.w3.org/2005/08/addressing" 
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:tns="http://tempuri.org/" 
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
targetNamespace="http://tempuri.org/" name="DWService">
-<wsdl:types>-
<xsd:schema targetNamespace="http://tempuri.org/" elementFormDefault="qualified">-
<xsd:element name="Login">-
<xsd:complexType>-
<xsd:sequence>
<xsd:element name="userName" type="xsd:string" nillable="true" minOccurs="0"/>
<xsd:element name="password" type="xsd:string" nillable="true" minOccurs="0"/>
<xsd:element name="organization" type="xsd:string" nillable="true" minOccurs="0"/></xsd:sequence>
</xsd:complexType>
</xsd:element>
-<xsd:element name="LoginResponse">
-<xsd:complexType>-
<xsd:sequence>
<xsd:element name="LoginResult" type="q1:ClientServiceSession" nillable="true" minOccurs="0" 
xmlns:q1="http://schemas.datacontract.org/2004/07/DocuWare.WebServices.GAPIFunctionality.DataContracts"/>
</xsd:sequence></xsd:complexType></xsd:element>

和SOAP部分:

-<wsdl:binding name="BasicHttpBinding_IDWService" type="tns:IDWService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
-<wsdl:operation name="Login"><soap:operation style="document" soapAction="http://tempuri.org/IDWService/Login"/>
-<wsdl:input><soap:body use="literal"/></wsdl:input>
-<wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation>
-<wsdl:operation name="Logoff"><soap:operation style="document" soapAction="http://tempuri.org/IDWService/Logoff"/>
-<wsdl:input><soap:body use="literal"/></wsdl:input>
-<wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation>

-<wsdl:service name="DWService">
-<wsdl:port name="BasicHttpBinding_IDWService" binding="tns:BasicHttpBinding_IDWService"><soap:address location="http://localhost:9007/DWService"/></wsdl:port></wsdl:service>

希望你能帮助我。)

Hope you can help me ;)

推荐答案

使用提琴手来跟踪流量。可能是服务器/服务正在返回的Content-Length:0
这可能是任何东西,在我的情况是从客户端应用程序发送内容类型不匹配和预期在服务器端内容类型。由于异常清楚地表明, ByteArrayInputStream的收到长度LT的内容;从服务= 0

Use Fiddler to track the traffic. Probably the server/service is returning Content-Length: 0 This could be anything, in my case it was Content-type mismatch sent from the client app and expected content-type on the server side. Since the exception clearly indicates that the ByteArrayInputStream received content of length <= 0 from the service.

我希望这会让你更进行调查。

I hope this will make you investigate more.

干杯,

这篇关于ksoap2:java.lang.IllegalArgumentException异常:大小&LT; = 0,同时使htt​​p.call的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆