Androidアプリで使用したい以下のJavaコードを使用してSOAPサービスにアクセスしようとしていますが、を取得していXmlPullParserException
ます。
org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <{http://www.w3.org/2003/05/soap-envelope}SOAP-ENV:Envelope>@1:114 in java.io.InputStreamReader@4a65e0)
XmlPullParserExceptionに関連するすべてのタグをチェックしました。コードを修正するのを手伝ってください。
import java.io.IOException;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
public class SoapClientClass {
private static String SOAP_ACTION = "/Process Definition";
private static String METHOD_NAME = "EmployeeDetailsOperation";
private static String NAMESPACE = "http://InputMessageNamespace";
private static String URL ="http://10.213.45.05:5026/EmployeeService";
public static void main(String[] args)
{
webserviceCall();
}
private static void webserviceCall() {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
// Pass parameters as Key value pair to URL
request.addProperty("EmployeeId", "121");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (IOException e) {
System.out.println("IOException");
e.printStackTrace();
} catch (XmlPullParserException e) {
System.out.println("XmlPullParserException");
e.printStackTrace();
}
SoapPrimitive result = null;
try {
result = (SoapPrimitive)envelope.getResponse();
} catch (SoapFault e) {
System.out.println("SoapFault");
e.printStackTrace();
}
//to get the data
String resultData = result.toString();
System.out.println("Result as String: \n"+resultData);
}
}