Skip to content

Improve documentation on custom attributes #151

@felipeferri

Description

@felipeferri

Hi!

First of all, congratulations on this extremely useful library.

I would like to ask you to improve your documentation regarding custom attributes.

I spent some hours trying to do something that I didn't know if was really possible to do with SoapEngine and with some liberal interpretation of some messages exchanges I ended up finding out how to do it, but it would be SOOOO much easier if you documented it up front.. :-)

I was using SoapEngine to connect to a Magento server. At some point, throught some very painful debugging, I found out one of the methods needed to have an array where one of the elements had special attributes, like below:

<args xsi:type="SOAP-ENC:Array">
	<string>2173</string>
	<item xsi:type="ns2:Map">
		<item>
			<key>method</key>
			<value>cartao</value>
		</item>
		<item>
			<key>po_number</key>
			<value>1</value>
		</item>
	</item>
	<double>4</double>
</args>

It is easy to set the "args" tag with the xsi:type="SOAP-ENC:Array" attributes by using [SoapEngine:setValue:forKey:attributes], but I was finding it really hard to set the xsi:type="ns2:Map" attribute to the item tag inside args because it is an element on a list.

I eventually found out that I can create a dictionary which represents a tag using the "value" and "attributes" keys and it would work perfectly.

NSDictionary *paymentMethod = @{@"value":@[@{@"key": @"method",
                                 @"value": @"cartao"},
                               @{@"key": @"po_number",
                                 @"value": @"1"},
                               @{@"key": @"cc_exp_month",
                                 @"value": cardInfo.expirationMonth}],
                               @"attributes": @{@"xsi:type": @"ns2:Map"}};

I didn't find anywhere in the documentation that this is possible; I saw one discussion where you suggest creating a custom class and kinda deduced the above solution from your answers. Please add a similar example to this on your "custom attributes" section on your readme.md because it can help others with the same problem as me.

Thank you and congratulations on your great work!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions