user1005319
user1005319

Reputation: 231

php soapclient Array to string conversion

I have an array a couple of levels deep in my SOAP request like below. When I run my SoapRequest I get Notice (8): Array to string conversion and my XML response does not convert the Array in RTrans to XML and I have no idea why. How I am creating the SOAP request and the XML version of it can be found below.

The Request:

$r['request'] = array(
'request' => array(
    'user' => 'test',
    'password' => 'test',
    'RTrans' => array(
        'Transactions' => array(
            'Criteria' => array(
                'Name' => 'Thomas'
            )
        )
    )
)
);

try{
    $response = $this->apiClient->DoQuery($r);
}
catch(Exception $e){
    debug($e);
}

The XML Version

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://webServices/">
<SOAP-ENV:Body>
    <ns1:DoNormalEnquiry>
        <request>
            <username>test</usernmae>
            <password>test</password>
            <RTrans>Array</RTrans>
        </request>
    </ns1:DoNormalEnquiry>
</SOAP-ENV:Body>

Upvotes: 2

Views: 2806

Answers (1)

user3351733
user3351733

Reputation: 46

I think RTrans is defined as a String. Please have a look at the wsdl file. Maybe thats the reason you got "Array" in the xml.

To send an array to your soapservice you could convert it to json. json_encode( array('Transactions' => array('Criteria' => array('Name' => 'Thomas')));

or define a complex datatype.

Maybe SoapVar will help you.

Upvotes: 1

Related Questions