in the controllers directory, create a file say 'mysoapservice.py'.
include something like:
def soapfunction():
retval = {}
retval['tradeNo'] = 27
retval['volume'] = 10
retval['descr'] = 'this is a test'
#add stuff to the dict here
return retval
then make sure in the views directory you have a folder called
'mysoapservice' that contains a file called 'soapfunction.xxx' where 'xxx'
is replaced with the extension that is on the URL called by the requester.
say the request is for /app/mysoapservice/soapfunction.xml then your view
file would be named 'soapfunction.xml'. see the book for ways to override
this default behavior.
the view file would look like:
<Trade>
<TradeNo>{{=tradeNo}}</TradeNo>
<Volume>{{=volume}}</Volume>
<Description>{{=descr}}</Description>
<etc...>
<Trade>
On Monday, September 10, 2012 5:17:07 PM UTC-7, devrunner wrote:
>
> Hi cfh. thanks. I'm fairly new to web2py and python, can you provide a
> sample code for me to start with. I really appreciate your reply.
>
> On Tuesday, September 11, 2012 7:17:09 AM UTC+8, howesc wrote:
>>
>> you can make a "view" that formats the output however you like....so when
>> your controller method is called it returns a dict that is then rendered by
>> your custom view.
>>
>> does that make sense? does that help you?
>>
>> cfh
>>
>> On Monday, September 10, 2012 12:31:46 AM UTC-7, devrunner wrote:
>>>
>>> I wanted to return an xml similar to this :
>>> <Trade>
>>> <TradeNo></TradeNo>
>>> <Volume></Volume>
>>> <Description></Description>
>>> <etc...>
>>> <Trade>
>>>
>>> using a SOAP WebService. The example i'm seeing is just for primitive
>>> datatypes, I wanted to have a user defined object. Is this possible? Thanks.
>>>
>>>
--