Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong value object type for ComplexType #43

Closed
vpistis opened this issue Nov 28, 2014 · 4 comments
Closed

Wrong value object type for ComplexType #43

vpistis opened this issue Nov 28, 2014 · 4 comments

Comments

@vpistis
Copy link

vpistis commented Nov 28, 2014

Hi,
I installed this beautiful lib, I used wsdl2py to generate the class python, no errors, all seem ok.
I tested my link to django dispatcher with "?wsdl" option in the path with SoapUI, the project in SoapUI is created correctly, but when I run the test with values this is the error:

Internal Server Error: /SmarTicket/soapfish
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 113, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/Library/Python/2.7/site-packages/django/views/decorators/csrf.py", line 77, in wrapped_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/soapfish-0.6dev-py2.7.egg/soapfish/django_.py", line 31, in django_dispatch
    soap_response = soap_dispatcher.dispatch(soap_request)
  File "/usr/local/lib/python2.7/site-packages/soapfish-0.6dev-py2.7.egg/soapfish/soap_dispatch.py", line 151, in dispatch
    return self.handle_soap_request(request)
  File "/usr/local/lib/python2.7/site-packages/soapfish-0.6dev-py2.7.egg/soapfish/soap_dispatch.py", line 195, in handle_soap_request
    response.http_content = SOAP.Envelope.response(tagname, response.soap_body, header=response.soap_header)
  File "/usr/local/lib/python2.7/site-packages/soapfish-0.6dev-py2.7.egg/soapfish/soap11.py", line 91, in response
    envelope.Body.message = xsd.NamedType(name=tagname, value=return_object)
  File "/usr/local/lib/python2.7/site-packages/soapfish-0.6dev-py2.7.egg/soapfish/xsd.py", line 1193, in __init__
    self.value = value
  File "/usr/local/lib/python2.7/site-packages/soapfish-0.6dev-py2.7.egg/soapfish/xsd.py", line 848, in __setattr__
    super(ComplexType, self).__setattr__(attr, field.accept(value))
  File "/usr/local/lib/python2.7/site-packages/soapfish-0.6dev-py2.7.egg/soapfish/xsd.py", line 542, in accept
    return self._type.accept(value)
  File "/usr/local/lib/python2.7/site-packages/soapfish-0.6dev-py2.7.egg/soapfish/xsd.py", line 866, in accept
    raise ValueError('Wrong value object type %r for %s.' % (value, self.__class__.__name__))
ValueError: Wrong value object type <class 'appTicket.test_soapfish_wsdl_server.NotifyResponse'> for ComplexType.

In this link there is the wsdl file and the original python generated code from wsd2py:
https://drive.google.com/folderview?id=0B0uiGluEWZlOT0x3cWp2c20wdGc&usp=sharing

Please help me, if possible!

thanx
Vale

@vpistis
Copy link
Author

vpistis commented Nov 28, 2014

Ok,
I found some workaround, maybe :)
I used the python code generated yesterday using wsdl2py from soapbox github, by adding my missing complex types:

Schema_a8452 = xsd.Schema( 
    imports = [],
    targetNamespace = 'urn:PayBemoovListener',
    elementFormDefault = 'qualified',
    simpleTypes = [],
    attributeGroups = [],
    groups = [],
    complexTypes = [BuyReqResponse],
    elements = {'NotifyRequest': xsd.Element( NotifyRequest() ), 'NotifyResponse': xsd.Element( NotifyResponse() )},
 )

and I changed in:

Schema_a8452 = xsd.Schema( 
    imports = [],
    targetNamespace = 'urn:PayBemoovListener',
    elementFormDefault = 'qualified',
    simpleTypes = [],
    attributeGroups = [],
    groups = [],
    complexTypes = [BuyReqResponse, NotifyRequest, NotifyResponse],
    elements = {'NotifyRequest': xsd.Element( NotifyRequest() ), 'NotifyResponse': xsd.Element( NotifyResponse() )},
 )

and, obviously, changing the reference from soapbox to soapfish

I tested it with SoapUI using this request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:PayBemoovListener">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:NotifyRequest>
         <urn:idMerchant>1</urn:idMerchant>
         <urn:idTransactionMerchant>1</urn:idTransactionMerchant>
         <!--Optional:-->
         <urn:idUser>1</urn:idUser>
         <urn:amount>1</urn:amount>
         <urn:productCode>1</urn:productCode>
         <!--Optional:-->
         <urn:itemCode00>1</urn:itemCode00>
         <!--Optional:-->
         <urn:itemCode01>?</urn:itemCode01>
         <!--Optional:-->
         <urn:itemCode02>?</urn:itemCode02>
         <!--Optional:-->
         <urn:itemCode03>?</urn:itemCode03>
         <!--Optional:-->
         <urn:itemCode04>?</urn:itemCode04>
         <urn:requestType>1</urn:requestType>
         <urn:BuyReqResponse>
            <urn:movincomAuthId>1</urn:movincomAuthId>
            <urn:movincomCompId>1</urn:movincomCompId>
            <urn:responseCode>1</urn:responseCode>
            <!--Optional:-->
            <urn:responseDesc>1</urn:responseDesc>
            <!--Optional:-->
            <urn:category>1</urn:category>
            <!--Optional:-->
            <urn:outMessage>1</urn:outMessage>
         </urn:BuyReqResponse>
         <urn:executionCode>1</urn:executionCode>
         <urn:executionDesc>1</urn:executionDesc>
         <urn:mac>1</urn:mac>
      </urn:NotifyRequest>
   </soapenv:Body>
</soapenv:Envelope>

and this is the response:

<ns0:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/">
   <ns0:Body>
      <ns0:NotifyResponse xmlns:ns0="urn:PayBemoovListener">
         <ns0:responseCode>0</ns0:responseCode>
      </ns0:NotifyResponse>
   </ns0:Body>
</ns0:Envelope>

It seem the listener responds correctly :)
This is the python generated from soapbox wsdl2py: https://drive.google.com/open?id=0B0uiGluEWZlOc05MOWZVR2s2bkk&authuser=0

What's the difference from soapbox? At this point, IMHO, seems to be only the wsdl2py script?
soapbox wsdl2py works correctly, but soapfish wsdl2py not!
It's right?

Thanx a lot!
Vale

@FelixSchwarz
Copy link
Member

First of all I find it a bit hard to understand what the problem is here exactly. Can you please post the reference WSDL you used to generate the source? I need somehow a way to reproduce your issue easily.

Ideally you would send a unit test (or a single Python file which clearly demonstrates the problem) but I realize that this might be quite complicated. So the next best thing is having the original WSDL and also the code you are currently using (for example in a temporary git repo).

@vpistis
Copy link
Author

vpistis commented Nov 28, 2014

Oooops.... I found my error :P
I forgot to implement the operation method, it returns an object instead of an instance of object...

sorry, sorry, sorry...

@FelixSchwarz
Copy link
Member

This might be a problem from the code generation. As it is very hard to generate a valid response I guess we could implement something like return SOAPError(..., 'not implemented) to avoid similar problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants