我想將一些數據發送到asmx soap web服務,一直在嘗試但是設法發送。我得到的錯誤是:使用KSOAP從android應用程序調用asmx Web服務
08-13 20:51:12.571:W/System.err(8885):SoapFault - faultcode:'soap:服務器'faultstring:'服務器無法處理請求。 --->值不能爲空。 08-13 20:51:12.571:W/System.err(8885):SoapFault - faultcode:'soap:服務器'faultstring:'服務器無法處理請求。 --->值不能爲空。 08-13 20:51:12.571:W/System.err(8885):SoapFault - faultcode:'soap:服務器'faultstring:'服務器無法處理請求。 --->值不能爲空。
這裏是網絡servcie網址: http://87.248.129.182:8090/PostPhotoInfo.asmx
,代碼:
private final String NAMESPACE = "http://tempuri.org/";
private final String URL = "http://87.248.129.182:8090/PostPhotoInfo.asmx";
private final String SOAP_ACTION = "http://tempuri.org/PostPhotoInfo";
private final String METHOD_NAME = "PostPhotoInfo";
public void call_asmx() {
//Create request
// photoArray
SoapObject request = new SoapObject(URL, METHOD_NAME);
//SoapObject request2 = new SoapObject(NAMESPACE, "photoArray");
SoapObject IMG = new SoapObject(URL, "PhotoInfo");
PropertyInfo _date = new PropertyInfo();
_date.setName("Date");
_date.setValue("2016-08-12 15:45:00");
_date.setType(String.class);
PropertyInfo _Latitude = new PropertyInfo();
_Latitude.setName("Latitude");
_Latitude.setValue("12.5245123");
_Latitude.setType(double.class);
PropertyInfo _longtitude = new PropertyInfo();
_longtitude.setName("Longitude");
_longtitude.setValue("32.45345");
_longtitude.setType(double.class);
PropertyInfo _CardID = new PropertyInfo();
_CardID.setName("CardID");
_CardID.setValue(14);
_CardID.setType(int.class);
PropertyInfo _ParkingNo = new PropertyInfo();
_ParkingNo.setName("ParkingNo");
_ParkingNo.setValue(12);
_ParkingNo.setType(int.class);
PropertyInfo _Image = new PropertyInfo();
_Image.setName("Image");
_Image.setValue("<< IMAGE DATA >>>");
_Image.setType(Base64.class);
IMG.addProperty(_date);
IMG.addProperty(_Latitude);
IMG.addProperty(_longtitude);
IMG.addProperty(_CardID);
IMG.addProperty(_ParkingNo);
IMG.addProperty(_Image);
request.addSoapObject(IMG);
//Create envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
//Set output SOAP object
envelope.setOutputSoapObject(request);
//Create HTTP call object
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
//Invole web service
androidHttpTransport.call(SOAP_ACTION, envelope);
//Get the response
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
//Assign it to fahren static variable
fahren = response.toString();
} catch (Exception e) {
e.printStackTrace();
//Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
任何暗示是非常讚賞。