$client = new SoapClient("http://soap.m4u.com.au/?wsdl", array("trace" => 1));
$params = array(
"authentication" => array(
"userId" => "user",
"password" => "pass"
),
"requestBody" => array(
"messages" => array(
"message" => array(
"recipients" => array( "recipient" => array("1" => "9799996899") ),
"content" => "Message Content"
)
)
)
);
$response = $client->__soapCall("sendMessages", array($params));
But I am getting following error
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] The request is either not well-formed or is not valid against the relevant schema.
I need the request format like below.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://xml.m4u.com.au/2009">
<soapenv:Header/>
<soapenv:Body>
<ns:sendMessages>
<ns:authentication>
<ns:userId>Username</ns:userId>
<ns:password>Password</ns:password>
</ns:authentication>
<ns:requestBody>
<ns:messages>
<ns:message format="SMS" sequenceNumber="1">
<ns:recipients>
<ns:recipient uid="1">61400000001</ns:recipient>
<ns:recipient uid="2">61400000002</ns:recipient>
</ns:recipients>
<ns:content>Message Content</ns:content>
</ns:message>
</ns:messages>
</ns:requestBody>
</ns:sendMessages>
</soapenv:Body>
</soapenv:Envelope>
How I can achieve this, please help.
You've got a tricky one there.
I haven't got the time to solve it fully, but it looks like the format of the WSDL means that SoapClient MUST provide an object structure.
I can't think off the top of my head how to represent the multiple node entries without using arrays (which see to then get decomposed before being sent)
I know it's not a complete solution, but I think this is moving along the right lines (as a proof of concept)
Note the use of
__getLastRequest
against theSoapClient
to retrieve exactly what you are sending to the server. It's very useful...I think your best bet is to get in touch with the service supplier to find if anyone else has connected via PHP.
Sorry I can't be of more help - I hope this is useful!