Quantcast
Channel: Web services
Viewing all articles
Browse latest Browse all 2361

php's Soap Client doesn't work but Boomerang tester does

$
0
0
by Doug Stevens.  

Ok, this is a weird one - and only seems to be impacting one method.  I'm using a PHP7.4 CLI script to add users from our SIS to moodle courses using enrol_manual_enrol_users.  Putting the following 

array(1991) {

 [0]=>
array(3) {
["userid"]=>
int(39615)
["courseid"]=>
int(500)
["roleid"]=>
int(5)
}
[1]=>
array(3) {
["userid"]=>
int(23782)
["courseid"]=>
int(500)
["roleid"]=>
int(5)
}
[2]=>
array(3) {
["userid"]=>
int(10057)
["courseid"]=>
int(500)
["roleid"]=>....

into $registerarray and running  

$clientm->enrol_manual_enrol_users($registerarray);

Where $clientm is an instance of soapClient, happily returns a 200 but shows on the moodle side as "The web service function 'unknown' has been called." and of course nobody enrolled.

Now, here is where things get weird. With tracing on I called 

var_dump($clientm->__getLastRequest());

and then copy/pasted the xml output into the Boomerang api workspace

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope
xmlns:env="http://www.w3.org/2003/05/soap-envelope"
xmlns:ns1="https://********/webservice/soap/server.php?wstoken=**************************"
xmlns:ns2="http://xml.apache.org/xml-soap"
xmlns:enc="http://www.w3.org/2003/05/soap-encoding"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<env:Body>
<ns1:enrol_manual_enrol_users env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<enrolments enc:itemType="ns2:Map" enc:arraySize="1991" xsi:type="enc:Array">
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">userid</key>
<value xsi:type="xsd:int">39615</value>
</item>
<item>
<key xsi:type="xsd:string">courseid</key>
<value xsi:type="xsd:int">500</value>
</item>
<item>
<key xsi:type="xsd:string">roleid</key>
<value xsi:type="xsd:int">5</value>
</item>
</item>
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">userid</key>
<value xsi:type="xsd:int">23782</value>
</item>
<item>
<key xsi:type="xsd:string">courseid</key>
<value xsi:type="xsd:int">500</value>
</item>
<item>
<key xsi:type="xsd:string">roleid</key>
<value xsi:type="xsd:int">5</value>
...



 and it worked perfectly, returning a 202 and students enrolled. I thought it might be headers, but other methods in the same script worked.
I'd love any ideas anyone may have!

Thanks in advance
Doug


Viewing all articles
Browse latest Browse all 2361

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>