从android调用Soap Service

时间:2013-03-03 20:42:52

标签: android ksoap2

当我发送请求时,我从未见过这种错误:

  

anyType的{SendResultCode = Unsuccessfull;错误=值不能为空。   参数名称:地址; }

我没有任何地址参数。

这是来自java的代码

                        String methodName = "SendMail";
                        String namespace = "http://www.xxxxxxxx.ge";
                        String soapAction = "http://www.xxxxxxxx.ge/SendMail";
                        String url = "http:///xx.xxx.xx.xxx/SmsService/SmsSendingService.asmx";

                        SoapObject soapObject = new SoapObject(namespace, methodName);
                        soapObject.addProperty("from","someaddress");
                        soapObject.addProperty("to","someaddress");
                        soapObject.addProperty("cc","someaddress");
                        soapObject.addProperty("bcc","someaddress");
                        soapObject.addProperty("subject","Message From App");
                        soapObject.addProperty("replyTo","someaddress");
                        soapObject.addProperty("messageBody","Some text here");
                        soapObject.addProperty("isFormatHtml",true);
                        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
                        envelope.dotNet = true;
                        envelope.setOutputSoapObject(soapObject); 
                        HttpTransportSE conn = new HttpTransportSE(url);
                        conn.call(soapAction, envelope); //send request
                        SoapObject result=(SoapObject)envelope.getResponse();

更新

我发现了我的问题,这有点棘手,

  

String soapAction =“http://www.xxxxxxxx.ge/SendMail

此网址最后需要'/',如下所示:

  

String soapAction =“http://www.xxxxxxxx.ge/SendMail/

所以现在一切正常。

1 个答案:

答案 0 :(得分:1)

您没有在SoapObject中添加Address参数

  soapObject.addProperty("address","#fdfdsf asdasd asdasds");