Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

API - PHP Array? 
 
Ashley
Member
 
Total Posts:  51
Joined:  2008-07-23
 

Hi,

Some of the functions in the API require you to pass over a php array as an argument. Altough this means that one API function ‘call’ can actually achieve many functions, it gives me a problem.

I am using java to make soap requests and then I send them to the soap server. This works fine if the request has a single argument;

e.g. look at args element

<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">
    <
SOAP-ENV:Body>
        <
m:call xmlns:m="urn:Magento" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
            <
sessionId xsi:type="xsd:string">8332291f1929ac467ee429faf070d954</sessionId>
            <
resourcePath xsi:type="xsd:string">product.info</resourcePath>
            <
args xsi:type="xsd:string">n2610</args>
        </
m:call>
    </
SOAP-ENV:Body>
</
SOAP-ENV:Envelope>

the problem comes when you need to use an array as the argument

e.g.

<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">
    <
SOAP-ENV:Body>
        <
m:call xmlns:m="urn:Magento" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
            <
sessionId xsi:type="xsd:string">8332291f1929ac467ee429faf070d954</sessionId>
            <
resourcePath xsi:type="xsd:string">product.info</resourcePath>
            <
args xsi:type="xsd:string">{[0]=>"n2610"[1]=> "german"}</args>
        </
m:call>
    </
SOAP-ENV:Body>
</
SOAP-ENV:Envelope>

If I were using a PHP client I would simply use array("n2610", “german") however I am not using PHP and have no idea how to get this to work. I suppose what I am asking is how does one convert data into the raw representation of a PHP array?

I have got a request to work in a similair manner but have had no luck with the example above. I am using Java as a SOAP client but am not using JAX-RPC, instead I am manually creating each soap request to give me full control over the application.

Any help would be much appreciated grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ashley
Member
 
Total Posts:  51
Joined:  2008-07-23
 

Finally figured this out for myself. I have changed to use Apache XML-RPC and what I was after was Data Binding.

Vector paramsV = new Vector();
        
paramsV.addElement(session);
        
paramsV.addElement(new String("product.info"));
        
paramsV.addElement(new String[] {"SKU""german"});

        
result =  client.execute("call"paramsV);

This method works but you have to process nil values and enable extensions as this is not part of the XML-RPC specification and the result contains them.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top