[Soap-Python] Spyne: ability to change default results name from FooResult to WhateverXyz ?

Patricio Stegmann kpoman at gmail.com
Thu Apr 23 05:45:00 CEST 2015


Burak,
I was able to monkey-patch the lib allowing it to carry and treat a 
_out_result_name kwarg and substitute when building response / result 
name, and it kinda works. Unfortunately I couldn't fix totally my issue.
The problem is the client that is consuming my spyne webservice is based 
on Java JAX WS lib. It is right now able to call the method and receive 
the response, but however finds null on all the returned values on that 
ComplexModel return thing.
I have a response that works on the java app (generated by itself when 
in emulator mode), and one generated by the real spyne app that doesnt 
and provide null values to the client.
This one works:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">

<S:Body>

<RecuperaInfoSoftwareResponse xmlns="tns" 
xmlns:ns2="http://www.tse.jus.br/secad/produtos/biometria/tiposComuns" 
xmlns:ns3="http://standards.iso.org/iso-iec/19794/-1/" 
xmlns:ns4="http://standards.iso.org/iso-iec/19794/-4/">

<ns2:fabricante>SECAD/STI/TSE</ns2:fabricante>

<ns2:dataLiberacao>2015-04-22T19:51:59.295-03:00</ns2:dataLiberacao>

<ns2:versao>0.0.1</ns2:versao>

<ns2:outrasInfo>Implementação DEMO do "lado servidor"</ns2:outrasInfo>

</RecuperaInfoSoftwareResponse>

</S:Body>

</S:Envelope>

and this want doesnt:

<senv:Envelope xmlns:tns="tns" 
xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/">

<senv:Body>

<*tns:*RecuperaInfoSoftwareResponse>

<tns:outrasInfo>{'product_id': 'WATSON MINI', 'software_version': 
'3.1.4', 'software_vendor': 'BioLogica Sistemas SA', 'device_state': 
'0', 'software_release_date': '02/04/2015', 'serial_number': 
'1236-00083', 'device': '\n        ', 'infoSoftwareXml': '\n    ', 
'firmware_version': '1.0.2'}</tns:outrasInfo>

<tns:fabricante>Biologica Sistemas</tns:fabricante>

<tns:versao>3.1.4</tns:versao>

<tns:dataLiberacao>02/04/2015</tns:dataLiberacao>

</tns:RecuperaInfoSoftwareResponse>

</senv:Body>

</senv:Envelope>

They really seem quite similar with only namespace compatible 
differences. Do you have any clue what could be wrong or any experience 
dealing with JAX WS clients ?

Thank you !


On 4/21/2015 12:31 PM, Burak Arslan wrote:
>
>
> On 04/21/15 06:52, Patricio Stegmann Gmail wrote:
>> The bare parameter is forcing me to have, for the decorated function, 
>> only one parameter of input, 
>
> SOAP defines a way to map an XML document to a method call. Actually, 
> that's like this for every serialization standard / RPC standard pair. 
> For example JsonRPC is a standard to map an incoming json document to 
> a method call. XmlRpc is another way of mapping xml documents to 
> method calls, etc..
>
> So in normal (non-bare) mode, you define your method and Spyne 
> generates needed input and output objects for you. In bare mode, it's 
> your job to define these objects. That's why you can only have a 
> single input and single output object.
>
> So if your method needs to take two arguments, you have to do what 
> Spyne does behind the scenes and define a complex model that has two 
> attributes and use that object as type of the single argument to your 
> method.
>
> The "one object == one method call" is the fundamental design 
> principle behind Spyne[1].
>
> If that's clear, let's get back to your case. You need:
>
>     class InitializeRequest(ComplexModel):
>          __type_name__ = 'Initialize'
>          __namespace__ = 'tns' # whatever you passed to your app as
>     tns argument
>
>         _type_info = [
>             ('id', Unicode),
>             ('name', Unicode),
>         ]
>
> and
>
>     class SomeService(ServiceBase):
>         @rpc(InitializeRequest, _body_style='bare')
>         def wicked(ctx, request):
>             print "id:", request.id
>             print "name:", request.name
>
> If you need to have the namespace of your incoming object different 
> from your app's tns,  you need latest code from 
> github.com/arskom/spyne. I just found out 2.11 doesn't support that.
>
> I hope this helps.
>
> Best,
> Burak
>
> [1]: That doesn't mean one document can't contain more than one 
> object, but that's not implemented because I don't see the point.
>



---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/soap/attachments/20150423/96e4ee79/attachment.html>


More information about the Soap mailing list