Android ksoap2:java.lang.IllegalArgumentException:size<;=进行http.call时0
我想用我的安卓4.03设备使用Ksoap2连接到基于点.net的Web服务 我的问题是,当我调用soap请求时,会出现以下异常:Android ksoap2:java.lang.IllegalArgumentException:size<;=进行http.call时0,android,wsdl,ksoap2,soap1.2,Android,Wsdl,Ksoap2,Soap1.2,我想用我的安卓4.03设备使用Ksoap2连接到基于点.net的Web服务 我的问题是,当我调用soap请求时,会出现以下异常: 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>(BufferedInpu
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)
下面是我要调用的wsdl文件的一部分:
<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服务没有太多经验,所以我希望有人能帮助我解决这个问题:)
你好
编辑
我尝试使用?svc->相同的错误:(
编辑
这里WSDL文件的头可能是我的命名空间为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>
-
--
-
-
-
-
--
肥皂部分:
-<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>
-
-
-
-
-
-
-
-
-
希望您能帮助我;)这一行之后您检查过调试了吗
SoapObject response = (SoapObject) Envelope.getResponse();
如果您已通过webservice?返回属性?。可能没有返回数据
使用
并检查长度,以了解是否正在接收数据
我认为argumentException可以生成,因为您正在尝试
要访问该属性而不在此处进行检查,请执行以下操作:
final String SessionID = response.getProperty("SessionID").toString();
测试属性计数并告诉我们
编辑:
请测试这个:
将SoapEnvelope从版本12更改为版本11
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
将webService URL从wdsl更改为此类型(svc):
使用
Fiddler
跟踪交通。服务器/服务可能正在返回内容长度:0
这可以是任何内容,在我的例子中,它是从客户端应用程序发送的内容类型
不匹配和服务器端的预期内容类型。因为异常清楚地表明,ByteArrayInputStream
接收的长度为的内容如下所示:
BasicHttpbinding:
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.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(Request);
HttpTransportSE ht = new HttpTransportSE(URL);
try {
ht.call(SOAP_ACTION, envelope);
final SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
Element e = new Element();
e.setName("To");
e.setNamespace("http://www.w3.org/2005/08/addressing");
e.addChild(Node.TEXT,
"your URL HERE");
Element e1 = new Element();
e1.setName("Action");
e1.setNamespace("http://www.w3.org/2005/08/addressing");
e1.addChild(Node.TEXT,
"http://tempuri.org/IService1/HelloTest");
request.addProperty("Celsius", "32");
// use VER12 instead of VER11
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.dotNet=true;
// add HederOut to envelope
envelope.headerOut = new Element[] { e, e1 };
envelope.setOutputSoapObject(request);
我对你的代码做了一些更改
1)
SoapSerializationEnvelope=新的SoapSerializationEnvelope(
第12版)
变成
SoapSerializationEnvelope=new
SoapSerializationEnvelope(SoapEnvelope.VER11)
2)
我已从您的代码中删除此部分
ht.debug=true
3)
SoapObject响应=(SoapObject)信封.getResponse()
变成
SoapPrimitive响应=(SoapPrimitive)信封.getResponse()
确保您在清单中添加了互联网权限
<uses-permission android:name="android.permission.INTERNET"/>
.我的选择:
1.使用最新的3.1.0 ksoap2 jar:
2.将v12改为v11您能分享完整日志吗?请给出正确的日志urlwsdl@Kirit请检查这里的问题程序在ht崩溃。呼叫。。。是的,我没有得到回复。好的,谢谢你添加一些信息。这是一个ASMX网络服务吗?我不知道,但我会尽快得到这些信息。11原因系列化错误已经尝试过了。。。我将尝试使用svc,并将在我从WSDL文件添加新信息时立即回复我认为我的Soap信封对象存在一些错误。请检查WSDL文件并告诉我是否使用了错误的名称空间。如果您希望访问完整的WSDL文件,请在lukasjesenko@gmail.com然后我会把网址发给你。谢谢你的回复请在这里检查我的问题@Tarsem是的,在那之前请阅读
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.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(Request);
HttpTransportSE ht = new HttpTransportSE(URL);
try {
ht.call(SOAP_ACTION, envelope);
final SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
<uses-permission android:name="android.permission.INTERNET"/>
Element e = new Element();
e.setName("To");
e.setNamespace("http://www.w3.org/2005/08/addressing");
e.addChild(Node.TEXT,
"your URL HERE");
Element e1 = new Element();
e1.setName("Action");
e1.setNamespace("http://www.w3.org/2005/08/addressing");
e1.addChild(Node.TEXT,
"http://tempuri.org/IService1/HelloTest");
request.addProperty("Celsius", "32");
// use VER12 instead of VER11
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.dotNet=true;
// add HederOut to envelope
envelope.headerOut = new Element[] { e, e1 };
envelope.setOutputSoapObject(request);