SOAP request with href attribute

Asked by Ales Klimsa

Hi Jakob,
please take a look at this SOAP request: http://pastebin.com/cZvdDFXQ

Please notice using href attribute in Contact object:
<item xsi:type="ns1:Contact" id="ref1">

and

<contacts SOAP-ENC:arrayType="ns1:Contact[1]" xsi:type="ns1:ArrayOfContact">
<item href="#ref1"/>
</contacts>

And when I want access this attribute:
customer->contacts[0]->contactType->ID (this object is represented by <item href="#ref1"/>), I got this error: AttributeError: 'dict' object has no attribute 'ID'

In this contactType attribute isn't stored my object contactType (
<contactType xsi:type="ns1:ContactType">
<ID xsi:type="xsd:long">3</ID>
<Name xsi:type="xsd:string">email</Name>
</contactType>),
but there is: {'doc': 'Contact type object', 'type': <class 'src.dto.ContactType.ContactType'>, 'nullable': True}

Could you help me please?

Thanks

Ales

Question information

Language:
English Edit question
Status:
Solved
For:
ladon Edit question
Assignee:
jsgaarde Edit question
Last query:
Last reply:
Revision history for this message
jsgaarde (jakob-simon-gaarde) said :
#1

hi Ales,

Sorry for the rather long response time :-)

hmm, that seems odd. Can you send a service stub that I can try this with?

Best Regards
Jakob Simon-Gaarde

Revision history for this message
Ales Klimsa (ales-klimsa) said :
#2

Hi Jakob, don't suffer for the late reply, I had weeked too ;)
But i'm not sure what you mean the service stub :(

Thanks for clarify

Ales

Revision history for this message
jsgaarde (jakob-simon-gaarde) said :
#3

Hi Ales.

Small Ladon service that can produce the error :-)

/ Jakob

Revision history for this message
Ales Klimsa (ales-klimsa) said :
#4

http://ws.dev.savvy.cz/service/TestLadon

But, the way how to assembly the request on client side is important. Here is a call example in PHP: http://pastebin.com/MCv9Fc7P

The problem occurs when I use for each instance of Contact ($con1, $con2) same instance of ContactType ($ct)

When I log this on the server side in test method: logging.debug(customer.contacts[1].contactType.ID)

This is the result: DEBUG:root:{'doc': 'ID of contact type', 'type': <class 'int'>, 'nullable': True}

Revision history for this message
jsgaarde (jakob-simon-gaarde) said :
#5

Hi Ales.

Ok I tried using suds, I can't make it work either, can you maybe send the service module source, so I can use it for testing?

Best Regards
Jakob Simon-Gaarde

Revision history for this message
jsgaarde (jakob-simon-gaarde) said :
#6

Oh - wait, I saw that the error I was recieving from the service you have setup, was due to you referencing index 1 in the list of customers. I added one more customer and it worked.

I used suds to produce the request.

Here is the client code:
http://pastebin.com/3Pw87pwa

Here is the request:
http://pastebin.com/Gv1nC5wS

And the output:
Result: test

So, isn't it just your php-soap library, that is producing bad requests?

Best Regards
Jakob Simon-Gaarde

Revision history for this message
Ales Klimsa (ales-klimsa) said :
#7

I believe that the problem is caused using ID and HREF attributes in SOAP request. You can see it in my example: http://pastebin.com/cZvdDFXQ

First contact

<item xsi:type="ns1:Contact" id="ref1">
....
and

<contacts SOAP-ENC:arrayType="ns1:Contact[1]" xsi:type="ns1:ArrayOfContact">
<item href="#ref1"/>
</contacts>

And the object which is represented by this code (<item href="#ref1"/>) aren't stored values of Contact with id = "ref1", but there is: {'doc': 'Contact type object', 'type': <class 'src.dto.ContactType.ContactType'>, 'nullable': True}

If you insepct your SOAP request, there is no ID/HREF attributes used.

Maybe ladon isn't able to parse this attributes

Revision history for this message
jsgaarde (jakob-simon-gaarde) said :
#8

Hi Ales.

I'm a little confused... Why does your SOAP client put href into the <item> element, and what is it you expect Ladon to do?

/ Jakob

Revision history for this message
Ales Klimsa (ales-klimsa) said :
#9

Hi Jakob,
element <item href="#ref1"/> is reference to the previous contact element <item xsi:type="ns1:Contact" id="ref1">...</item> with id="ref1". Because both contact object are identicaly (have same values in all attributes). I don't know why "my" SOAP client is using this shorthand.
My expecting from ladon is that ladon replace element <item href="#ref1"/> by the element <item xsi:type="ns1:Contact" id="ref1">...</item>.

I'm not sure, if using id/href attributes is valid according to SOAP specification. But we are using standard SOAP extension for PHP: http://www.php.net/manual/en/book.soap.php, which is widely used, so I thought it wouldn't be bad, if ladon supports this id/href shorthands.

What you mean?

Ales

Revision history for this message
jsgaarde (jakob-simon-gaarde) said :
#10

Hi Ales.

Just had a look at the SOAP 1.1 specification. It turns out that using href in item elements actually is legal. So I will look at implmenting this soon.

/ Jakob Simon-Gaarde

Revision history for this message
jsgaarde (jakob-simon-gaarde) said :
#11

Hi Ales.

Converted to a bug: #941409

Best Regards
Jakob Simon-Gaarde