gpt4 book ai didi

android - 获取 soapfault 错误

转载 作者:行者123 更新时间:2023-11-29 16:18:55 25 4
gpt4 key购买 nike

我正在将我的 Android 代码与 Webservice 连接以检索数据。我总是得到:

 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

我的代码是

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;
}

最佳答案

值得注意的一件事是您没有在 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/

关于android - 获取 soapfault 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8192955/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com