gpt4 book ai didi

android - 将 kSoap 连接到 Spyne 时出错 The attribute '{http://schemas.xmlsoap.org/soap/encoding/}root' is not allowed

转载 作者:行者123 更新时间:2023-11-30 01:17:53 36 4
gpt4 key购买 nike

我有一个使用 spyne 用 python 编写的 soap 服务器。我还使用 suds 在 python 中创建了一个肥皂客户端。它工作完美。这是服务器的代码

class Personnel(ServiceBase):

@rpc(_returns=String)
def personnel(self):
"""Docstrings for service methods appear as documentation in the wsdl.
<b>What fun!</b>

@param name the name to say hello to
@param times the number of times to say hello
@return the completed array
"""
employees_list = employees()
employees_list.populate_from_db("elleo", "odoo", "0801", "127.0.0.1")

tstString = "Dirk"

return tstString

application = Application([Personnel], 'elleo.personnel',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11())

wsgi_application = WsgiApplication(application)

当使用 kSOAP 连接我的 android 程序时,出现错误。这是代码:

    String SOAP_ACTION = "http://192.168.1.100:8000/personnel";
String METHOD_NAME = "personnel";
String NAMESPACE = "elleo.personnel";
String URL = "http://192.168.1.100:8000/?wsdl";


try {
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);

SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
HttpTransportSE transport = new HttpTransportSE(URL);

transport.call(SOAP_ACTION, soapEnvelope);
resultString = (SoapPrimitive) soapEnvelope.getResponse();

Log.i(TAG, "Result Celsius: " + resultString);
} catch (Exception ex) {
Log.e(TAG, "Error: " + ex.getMessage());
}

我收到以下错误消息:

  <faultstring>:1:0:ERROR:SCHEMASV:SCHEMAV_CVC_COMPLEX_TYPE_3_2_1: Element '{elleo.personnel}personnel', attribute '{http://schemas.xmlsoap.org/soap/encoding/}root': The attribute '{http://schemas.xmlsoap.org/soap/encoding/}root' is not allowed.</faultstring>

知道如何解决这个问题。这只是我尝试用来建立通信的一个小程序。如果这部分有效,我将扩展程序。

最佳答案

我找到了答案。我不声称理解它为什么起作用,但它确实起作用了。参见 How can you remove namespace declarations in ksoap?了解更多详情。

这是我添加到我的 java 程序中的代码:

try {
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);

SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
soapEnvelope.setAddAdornments(false);
HttpTransportSE transport = new HttpTransportSE(URL);

transport.call(SOAP_ACTION, soapEnvelope);
resultString = (SoapPrimitive) soapEnvelope.getResponse();

Log.i(TAG, "Result Celsius: " + resultString);
} catch (Exception ex) {
Log.e(TAG, "Error: " + ex.getMessage());
}

关于android - 将 kSoap 连接到 Spyne 时出错 The attribute '{http://schemas.xmlsoap.org/soap/encoding/}root' is not allowed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37576838/

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