1

Spyne を使用して Python で記述された SOAP サーバーがあります。また、suds を使用して Python で SOAP クライアントを作成しました。それは完璧に機能します。これがサーバーのコードです

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>

これを解決する方法はありますか。これは、通信を確立するために使用しようとしている小さなプログラムです。この部分が機能する場合、プログラムを拡張します。

4

1 に答える 1

1

私は答えを見つけました。なぜそれが機能するのかを理解しているとは言いませんが、機能しました。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());
}
于 2016-06-01T19:08:37.647 に答える