How do I access SOAP headers in a Spyne srpc method? -
forgive me if being thick spyne documentation on headers seems bit thin , link sample code broken. think found sample code here seems access headers in listener callback function. need access in srpc method if possible.
what (this not work):
class myrequest(complexmodel): messages = array(unicode) class myheader(complexmodel): trackingid = bytearray class mysoapservice(servicebase): @srpc(myrequest, _in_header=myheader) def postmessages(req, hdr): logging.info(u'received: {0:s}'.format(hdr.trackingid))
if helps, trying replace service written in .net defines message headers in message contract this:
[messagecontract] public class myrequest { [messageheader] public guid trackingid { get; set; } [messagebodymember] public string[] messages { get; set; } }
you can't read header data within srpc function. @srpc existing functions don't want touch. should use @rpc unless know need @srpc
decorate function using @rpc. passes rpc context (conventionally named ctx) first argument function. then, ctx.in_header you'll find header data. can set ctx.out_header alter outgoing response headers.
also, pull requests docs pure gold me :)
Comments
Post a Comment