2017-10-14 15 views
0

私は扱うことができなければならないことを、以下のSOAPリクエストを持っている:spyneでSOAPリモートプロシージャ属性をモデル化する方法は?

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
    <s:Body> 
    <LogoutNotification xmlns="urn:mace:shibboleth:2.0:sp:notify" type="global"> 
     <SessionID> 
     _d5628602323819f716fcee04103ad5ef 
     </SessionID> 
    </LogoutNotification> 
    </s:Body> 
</s:Envelope> 

セッションIDは、単にRPCパラメータです。それは簡単に処理できます。

しかし、spyneのtype属性をどのようにモデル化できますか? typeは「グローバル」または「ローカル」のいずれかです。

私は現在、(単に属性を無視できるようにするには、無効検証)以下を持っています。

class LogoutNotificationService(Service): 
    @rpc(MandatoryUnicode, _returns=OKType, 
     _in_variable_names={'sessionid': 'SessionID'}, 
     _out_variable_name='OK', 
     ) 
    def LogoutNotification(ctx, sessionid): 
     pass # handle the request 

完全を期すために、ここでは使用されたモデルです。

class OKType(ComplexModel): 
    pass 


class MandatoryUnicode(Unicode): 
    class Attributes(Unicode.Attributes): 
     nullable = False 
     min_occurs = 1 

スキーマがありますonline。しかし、この属性を含む公式のWSDLはありません。

答えて

0

この鍵はbareボディスタイルを使用しています。次に、完全な入力メッセージと出力メッセージをモデル化することができます。

私の作業コードは次のようになります。

class OKType(ComplexModel): 
    pass 


class MandatoryUnicode(Unicode): 
    class Attributes(Unicode.Attributes): 
     nullable = False 
     min_occurs = 1 


class LogoutRequest(ComplexModel): 
    __namespace__ = 'urn:mace:shibboleth:2.0:sp:notify' 
    SessionID = MandatoryUnicode 
    type = XmlAttribute(Enum("global", "local", type_name="LogoutNotificationType")) 


class LogoutResponse(ComplexModel): 
    __namespace__ = 'urn:mace:shibboleth:2.0:sp:notify' 
    OK = OKType 


class LogoutNotificationService(Service): 
    @rpc(LogoutRequest, _returns=LogoutResponse, _body_style='bare') 
    def LogoutNotification(ctx, req): 
     # do stuff, raise Fault on error 
     # sessionid is available as req.SessionID 
     return LogoutResponse 

(実際には関係のない問題)についてnot wrapping response良い例が含まれており、この問題を解決する方法を教えてくれました。

関連する問題