I am very new to Android and ksoap2 development. I have been searching on the forums for an answer to my error and still have not found a fix. Hopefully someone will be able to figure how to fix the error.
I am calling a Webservice with 10 parameters in my sample android app using the Ksoap2-Android-assembly-2.4 jar library.
The error from the responsedump call:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Server was unable to read request. ---> There is an error in XML document (1, 435). ---> Input string was not in a correct format.</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
The request from the requestdump call:
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<InsertAnalyzerQueue xmlns="http://63.237.52.216/service.asmx/" id="o0" c:root="1">
<uploadcustomerkey i:type="d:int">11111</uploadcustomerkey>
<uploadcustomertype i:type="d:string">C</uploadcustomertype>
<description i:type="d:string">ANDROIDTEST</description>
<uploadedfile i:type="d:string">Myfile</uploadedfile>
<companionfile i:type="d:string">C</companionfile>
<emailaddress i:type="d:string">tom@transferexpress</emailaddress>
<generatedfilename i:type="d:string">MyFileName</generatedfilename>
<companyname i:type="d:string">MyCompany</companyname>
<dealerid i:type="d:string">TEST</dealerid>
<phonenbr i:type="d:string">4409181900</phonenbr>
</InsertAnalyzerQueue>
</v:Body></v:Envelope>
My actual code:
package com.example.soapconnect2;
import java.io.IOException;
import org.ksoap2.transport.AndroidHttpTransport;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
public class SoapConnect2 extends Activity {
/** Called when the activity is first created. */
private static final String SOAP_ACTION = "http://63.237.52.216/service.asmx/InsertAnalyzerQueue"; //Need to include WebService method
private static final String METHOD_NAME = "InsertAnalyzerQueue"; //WebService
private static final String NAMESPACE = "http://63.237.52.216/service.asmx/"; //Only use IP address plus the asmx file name
private static final String URL = "http://63.237.52.216/service.asmx"; //Only use IP address plus the asmx file name
//HttpGet httpPost = new HttpGet("http://63.237.52.215/serce.asmx/IsValidReferenceID?referenceID='092010-0123A1of1'");
//private static final String URL = "http://63.237.52.216/service.asmx/InsertAnalyzerQueue?uploadcustomerkey=1111&uploadcustomertype=T&description=TESTTESTTEST&uploadedfile=My_file.jpg&companionfile=&[email protected]&generatedfilename=MyFileName.jpg&companyname=MyCompany&dealerid=TEST&phonenbr=5555555555";
String[] results;
String resultdata;
Toast mtoast;
PropertyInfo mPropertyInfo;
String mRequestDump = null;
String mResponseDump = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
mPropertyInfo = new PropertyInfo();
//mPropertyInfo.elementType.setValue(request.addProperty("uploadcustomerkey", "11111"));
//mPropertyInfo.setElementType(elementType)= PropertyInfo.INTEGER_CLASS;
//Adds parameters <parameter name>, <value>
request.addProperty("uploadcustomerkey", 11111);
request.addProperty("uploadcustomertype", "C");
request.addProperty("description", "ANDROIDTEST");
request.addProperty("uploadedfile", "Myfile");
request.addProperty("companionfile", "C");
request.addProperty("emailaddress", "tom@transferexpress");
request.addProperty("generatedfilename", "MyFileName");
request.addProperty("companyname", "MyCompany");
request.addProperty("dealerid", "TEST");
request.addProperty("phonenbr", "4409181900");
SoapSerializationEnvelope mEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
mEnvelope.dotNet=true;
mEnvelope.setOutputSoapObject(request);
mEnvelope.encodingStyle = SoapSerializationEnvelope.XSI;
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
androidHttpTransport.debug = true;
try {
androidHttpTransport.call(SOAP_ACTION, mEnvelope);
}
catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mRequestDump = androidHttpTransport.requestDump;
mResponseDump = androidHttpTransport.responseDump;
//SoapObject result = (SoapObject)envelope.bodyIn;
//resultdata = result.getProperty(0).toString();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mtoast = Toast.makeText(getBaseContext(), resultdata, Toast.LENGTH_LONG);
mtoast.show();
}
}
The actual Webservice WSDL:
http://63.237.52.216/service.asmx?wsdl
<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://63.237.52.216/service.asmx/" xmlns:s1="http://microsoft.com/wsdl/types/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://63.237.52.216/service.asmx/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <s:schema elementFormDefault="qualified" targetNamespace="http://63.237.52.216/service.asmx/">
<s:import namespace="http://microsoft.com/wsdl/types/" />
- <s:element name="IsValidReferenceID">
- <s:complexType>
+ <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="referenceID" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="IsValidReferenceIDResponse">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="IsValidReferenceIDResult" type="s:boolean" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="GetDealersUploadedItems">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="dealerID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="phoneNumber" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="GetDealersUploadedItemsResponse">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetDealersUploadedItemsResult" type="tns:ArrayOfUploadItem" />
</s:sequence>
</s:complexType>
</s:element>
- <s:complexType name="ArrayOfUploadItem">
- <s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="UploadItem" nillable="true" type="tns:UploadItem" />
</s:sequence>
</s:complexType>
- <s:complexType name="UploadItem">
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="UploadRefID" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="UploadedDate" type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="UploadedFileName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="UpdatedFlag" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Description" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="StatusName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EmailAddress" type="s:string" />
</s:sequence>
</s:complexType>
- <s:element name="UpdateOrderStatus">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="referenceIDs" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="orderStatus" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="newCustomerID" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="UpdateOrderStatusResponse">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="UpdateOrderStatusResult" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="InsertAnalyzerQueue">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="uploadcustomerkey" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="uploadcustomertype" type="s1:char" />
<s:element minOccurs="0" maxOccurs="1" name="description" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="uploadedfile" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="companionfile" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="emailaddress" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="generatedfilename" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="companyname" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="dealerid" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="phonenbr" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="InsertAnalyzerQueueResponse">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="InsertAnalyzerQueueResult" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="MyTestService">
<s:complexType />
</s:element>
- <s:element name="MyTestServiceResponse">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="MyTestServiceResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="boolean" type="s:boolean" />
<s:element name="ArrayOfUploadItem" nillable="true" type="tns:ArrayOfUploadItem" />
<
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…