public class Result extends Activity {
private final String NAMESPACE = "http://tempuri.org/";
private final String URL = "http://10.101.21.18/MDSService/Service1.svc?wsdl";
private final String SOAP_ACTION = "http://tempuri.org/IService1/GetAssmtDataByLoginIdAndPassword";
private final String METHOD_NAME = "GetAssmtDataByLoginIdAndPassword";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SoapObject soapObject=new SoapObject(NAMESPACE, METHOD_NAME);
Intent in = getIntent();
soapObject.addProperty("loginName","ginnas");
soapObject.addProperty("password","orcas");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(soapObject);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
System.out.println("call success");
SoapObject soapResponse = (SoapObject)envelope.getResponse();//throws the soap fault exception at this line
Log.i("myApp", soapResponse.toString());
} catch (org.xmlpull.v1.XmlPullParserException ex2) {
System.out.println("EXCEPTION: " + ex2.getMessage());
} catch (SoapFault e) {
System.out.println("SOAPFAULT====");
e.printStackTrace();
} catch (IOException e) {
System.out.println("IOEXCEPTION====");
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
此代码给了我以下异常:安卓KSOAP故障异常参数传递
SoapFault - faultcode: 'a:InternalServiceFault' faultstring: 'Query error occured : Procedure or function 'GetResidentAssmtDataByUser' expects parameter '@loginName', which was not supplied.' faultactor: 'null' detail: [email protected]
登录名和密码是否正确。
我迄今所做的:
Internet权限
envelop.dotNet =真/假
SoapPrimitive响应=(SoapPrimitive)envelope.bodyIn;
但是这会给出同样的例外。请解决我的问题。
你确定要传递正确的标签与请求?而且,您对网络服务有什么反应?一个对象或一个原始值? – Swayam