2

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>

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

From what I know it expects an XML string so should I have it in this format? RTrans = '<Transactions><Criteria><Name>Thomas</Name></Criteria></Transactions>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.