I have a web service running at http://localhost:9090/WS with WSDL url of http://localhost:9090/WS?wsdl. Using the following PHP script and following the direction from the University of Toronto (putting the two PHP scripts above in the same folder as my script), I have been able to call my webservice correctly.
<?php require('soap-wsse.php'); class mySoap extends SoapClient { function __doRequest($request, $location, $saction, $version) { $doc = new DOMDocument('1.0'); $doc->loadXML($request); $objWSSE = new WSSESoap($doc); $objWSSE->addUserToken("admin", "admin", false); return parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version); } } $wsdl = 'http://localhost:9090/WS?wsdl'; $sClient = new mySoap($wsdl, array('trace'=>1)); $wrapper->word = new SoapVar("Echo testing", XSD_STRING); $result = $sClient->echo($wrapper); print_r($result->return); ?>
The resulting print out on the web is "Echo Testing". I hope this would help anyone that encountered similar problem.
2 comments:
pak,, saya mahasiswi yg sedanga mengerjakan Tugas Akhir, boleh bertanya mengenai ws-security??karena TA saya berhubungan dengan web service dan ws-security,,
blh minta contact personnya pak??
makasi
Thank you for the code. It's really helpful.
Post a Comment