首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >获取soapfault错误

获取soapfault错误
EN

Stack Overflow用户
提问于 2011-11-19 16:54:54
回答 1查看 2.4K关注 0票数 1

我正在用Webservice连接我的Android代码来检索数据。我总是得到这样的结果:

代码语言:javascript
复制
 SoapFault - faultcode: 'a:InternalServiceFault' faultstring: 'Error in deserializing body of request message for operation
 'insertAuditData'. OperationFormatter encountered an invalid Message
 body. Expected to find node type 'Element' with name 'insertAuditData'
 and namespace 'http://tempuri.org/'. Found node type 'Element' with
 name 'insertAuditData' and namespace 'http://tempuri.org'' faultactor:
 'null' detail: org.kxml2.kdom.Node@44f6a4e8

我的代码是

代码语言:javascript
复制
private static final String SOAP_ACTION3 = "http://tempuri.org/IService/GetSpecificAuditData";
private static final String SOAP_ACTION2 = "http://tempuri.org/IService/insertAuditData" ;
private static final String SOAP_ACTION = "http://tempuri.org/IService/GetAllAuditData";
private static final String METHOD_NAME = "GetAllAuditData";
private static final String METHOD_NAME2 = "insertAuditData";
private static final String METHOD_NAME3 = "GetSpecificAuditData";
private static final String NAMESPACE = "http://tempuri.org//";
private static final String URL = "http://70.33.215.18/PortalService.svc?wsdl";
private boolean isResultVector = false;

public Audit CallGetALL()
  {
    final String sGetSingle = METHOD_NAME;
    // Create the outgoing message
    final SoapObject requestObject = new SoapObject(NAMESPACE, sGetSingle);
    // Create soap envelop .use version 1.1 of soap
    final SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    // add the outgoing object as the request
    envelope.setOutputSoapObject(requestObject);
    envelope.addMapping(NAMESPACE,Audit.Audit_CLASS.getSimpleName(),Audit.Audit_CLASS);
    // call and Parse Result.
    final Object response = this.call(SOAP_ACTION, envelope);
    Audit result = null;
    if (response != null)
        {
            result = new Audit((SoapObject) response);
        }

        return result;
    }
 protected Object call(String soapAction,SoapSerializationEnvelope envelope)
        {
            Object result = null;
            final HttpTransportSE transportSE = new HttpTransportSE(URL);
            transportSE.debug = false;
            // call and Parse Result.
            try
            {
                transportSE.call(soapAction, envelope);
                if (!isResultVector)
                {
                    result = envelope.getResponse();
                } else
                {
                    result = envelope.bodyIn;
                }
            } catch (final IOException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (final XmlPullParserException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (final Exception e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return result;
        }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-11-21 22:56:36

最突出的一点是,您没有在requestObject上设置任何属性。

用于GetSpecificAuditData的序列化SOAP XML可能如下所示...<k:GetSpecificAuditData xmlns:k="http://tempuri.org//"></k:GetSpecificAuditData>

web服务可能希望GetSpecificAuditData具有一些与其相关联的数据。也许是个记录ID?这一切都只是我的猜测,因为我不知道web服务规范是什么样子的。

看看SoapObject的addProperty方法。

此外,请仔细检查您的名称空间。末尾的斜杠可能也会导致服务出现问题。

如果你感兴趣,我写了一个关于ksoap2-android的教程,可以在...

http://www.shanekirk.com/2011/11/speaking-soap-with-android/

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8192955

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档