我正在尝试从我的Android应用程序访问共享点Web服务。
我使用KSoap访问网络服务,但每次都在下面的线上抛出错误。
“androidHttpTransport.call(SOAP_ACTION,envelope);”
所以我尝试使用以下链接,但它返回“Fault String”。
无论问题来自应用程序端还是服务器端,请帮助我。
提前致谢。
答案 0 :(得分:0)
试试这段代码:
public static String call(Context c, SoapObject request, String NAMESPACE,
String METHOD_NAME, String SOAP_ACTION) throws IOException,
XmlPullParserException {
Log.i(WebCalls, "URL " + CommonVariable.URL);
Log.i(WebCalls, "Method Name " + METHOD_NAME);
Log.i(WebCalls, "request Name " + request);
String SoapResult = null;
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
HttpTransportSE androidHttpTransport = new HttpTransportSE(
CommonVariable.URL);
// this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
// Get the SoapResult from the envelope body.
if (envelope.bodyIn instanceof SoapFault) {
SoapResult = ((SoapFault) envelope.bodyIn).faultstring;
} else {
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
SoapResult = resultsRequestSOAP.getProperty(0).toString();
}
Log.i(WebCalls, "Response " + SoapResult);
return SoapResult;
}