Parameter "xy" is not optional

Asked by azurit on 2011-09-24

Hi,

i have problems with running simple SOAP function using two clients:
 - standard PHP SOAP client
 - Python ZSI version 1.7

Result is the same in both cases:
UndefinedServiceMethod:
interface name: soap
service name: test
Parameter "first" is not optional

server
-------
from ladon.ladonizer import ladonize

class test(object):

 @ladonize(unicode,unicode,rtype=unicode)
 def test(self, first, second):
  return first

client Python
---------------
from ZSI.client import Binding
from ZSI import TC

bind = Binding(host="127.0.0.1", port=8080, url="/test/soap")
result = bind.RPC(None, "test", ("aaa", "bbb"), TC.Any(), requesttypecode=TC.Any("test"))

client PHP
------------
$sck = new SoapClient(null, array("location" => "http://127.0.0.1:8080/test/soap", "uri" => "http://127.0.0.1:8080/"));
$result = $sck->__soapCall("test", array("aaa", "bb"));

XML from python client
--------------------------
REQUEST:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" >
<SOAP-ENV:Body>
<test>
<element id="ob77fdf20" xsi:type="xsd:string">aaa</element>
<element id="ob77fdf38" xsi:type="xsd:string">bbb</element>
</test>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

RESPONSE:
Date: Sat, 24 Sep 2011 14:10:18 GMT
Server: WSGIServer/0.1 Python/2.7.1+
Content-Type: text/plain; charset=utf-8
Content-Length: 775

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ladon-0.6.3-py2.7.egg/ladon/server/wsgi_application.py", line 355, in __call__
    response_part = dispatcher.dispatch_request(request_data,environ)
  File "/usr/local/lib/python2.7/dist-packages/ladon-0.6.3-py2.7.egg/ladon/server/dispatcher.py", line 157, in dispatch_request
    result = self.call_method(method,req_dict,tc,export_dict)
  File "/usr/local/lib/python2.7/dist-packages/ladon-0.6.3-py2.7.egg/ladon/server/dispatcher.py", line 50, in call_method
    raise UndefinedServiceMethod(self.iface._interface_name(),self.sinst.servicename,'Parameter "%s" is not optional' % arg['name'])
UndefinedServiceMethod:
interface name: soap
service name: test
Parameter "first" is not optional

Python 2.7.1
PHP 5.3.5

Any ideas ?

Thank you !

Question information

Language:
English Edit question
Status:
Solved
For:
ladon Edit question
Assignee:
No assignee Edit question
Solved by:
jsgaarde
Solved:
2011-09-28
Last query:
2011-09-28
Last reply:
2011-09-28
azurit (azurit) said : #1

Ladon version 0.6.3

json client from wiki.python.org/moin/WebServices is working fine

jsgaarde (jakob-simon-gaarde) said : #2

Hi Azurit.

How do you run the service? and what is the name of the python module where you have implemented your service class "test".

Best Regards
Jakob Simon-Gaarde

azurit (azurit) said : #3

Hi,

i'm running it via Ladon test server. I find out that only kayword arguments are working in Ladon (so i need to specify also argument name, even it's not keyword argument). Is this an intended bahavior ?

jsgaarde (jakob-simon-gaarde) said : #4

I have no problem running your example with suds.

jsgaarde (jakob-simon-gaarde) said : #5

Is the name of your service module by any chance test.py?

azurit (azurit) said : #6

File is 'myservice-new.py'. What version of SUDS are you using ? Mine is 0.4 . As i said, the same problem is with PHP unless i make arguments as keyword:
$result = $sck->testf(new SoapParam("aaa", "first"), new SoapParam("bbb", "second"));

azurit (azurit) said : #7

As, sorry, i didn't tried this one with SUDS :) SUDS was in other question. Anyway, Ladon seems to not handle the positional arguments and needs argument names in XML.

Best jsgaarde (jakob-simon-gaarde) said : #8

Hi Azurit.

The Ladon SOAP interface is my implementation of the SOAP 1.1 protocol. I can't find anything (specification wise) that suggests that positional arguments are supported in SOAP 1.1, but I might have missed it. That's why only named arguments are supported. This does not mean that Ladon can't support positional arguments - it can - cause not only does Ladon store information about parameter names, it also stores the position, default value and doc - strings.

You are more than welcome to write a SOAP 1.2 interface for Ladon. All you have to do is write one new module with 4 classes that inherit: ServiceDescriptor, BaseRequestHandler, BaseResponseHandler and BaseInterface.

You can easilly add a new interface to Ladon - for example like this:
1. copy the ladon/interfaces/soap.py module to ie. ladon/interfaces/mysoap.py.
2. edit ladon/interfaces/mysoap.py and in the bottom change the classname SOAPInterface to MYSOAPInterface and make the static method _interface_name() return "mysoap"
3. edit ladon/interfaces/__init__.py add "import ladon.interfaces.mysoap" in the bottom of the file

If you choose to do so, I will review it and add it as a contribution.

/ Jakob

jsgaarde (jakob-simon-gaarde) said : #9

Btw. my version of suds us 0.4 (0.4.1-2) too. Your service-example works with gSOAP too.

azurit (azurit) said : #10

0.4 or 0.4.1 ? i'm using 0.4 cos this is the last _stable_ version (0.4.1 si beta).

jsgaarde (jakob-simon-gaarde) said : #11

What's the status on this one?

azurit (azurit) said : #12

it's 'fixed' if ladon is not supposed to suppoer positional arguments. closing it

azurit (azurit) said : #13

Thanks jsgaarde, that solved my question.