tillman.stevens Posted December 29, 2010 Share Posted December 29, 2010 I'm trying to access webservices using PHP's soap. Here's my code: <?php // test connection to agwebservice $agLogURL = "https://www.agemni.com/_snet/AgemniLogin.asmx?WSDL"; $agDN = "myDN"; $agUserName = "myUserName"; $agPass = "myPassword"; $login = new SoapClient($agLogURL); $login->aglogin($agDN, $agUserName, $agPass); // $login.service.agLogin($agDN, $agUserName, $agPass); ?> When I run the script, here's the resulting error: Fatal error: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. at AgemniLogin.agLogin(String dn, String username, String password) --- End of inner exception stack trace --- in C:\XAMPP\xampp\htdocs\agsync\syncwork.php:12 Stack trace: #0 [internal function]: SoapClient->__call('aglogin', Array) #1 C:\XAMPP\xampp\htdocs\agsync\syncwork.php(12): SoapClient->aglogin('myDN', 'myUserName', 'myPassword') #2 {main} thrown in \htdocs\agsync\syncwork.php on line 12 Not sure if you'll need more info on the SOAP services, but the info is here: http://wiki.agemni.com/Getting_Started/APIs/Agemni_CMS_Sync#Method_details Really could use any help anyone can offer: Quote Link to comment https://forums.phpfreaks.com/topic/222920-help-with-soap-client/ Share on other sites More sharing options...
Maq Posted December 29, 2010 Share Posted December 29, 2010 Have you actually resolved this? Quote Link to comment https://forums.phpfreaks.com/topic/222920-help-with-soap-client/#findComment-1152637 Share on other sites More sharing options...
tillman.stevens Posted December 29, 2010 Author Share Posted December 29, 2010 yes I did. I guess I have to refresh myself on using objects with php. it's been a while since I've done any coding and the service was expecting the login parameters to be passed as an object. Here's what the working code looked like, in case someone else has a similar problem: $agLogURL = "https://www.agemni.com/_snet/AgemniLogin.asmx?WSDL"; $myLogin->dn = "myDN"; $myLogin->username = "myUserName"; $myLogin->password = "myPassword"; $login = new SoapClient($agLogURL); $results = $login->aglogin($myLogin); Quote Link to comment https://forums.phpfreaks.com/topic/222920-help-with-soap-client/#findComment-1152642 Share on other sites More sharing options...
Maq Posted December 29, 2010 Share Posted December 29, 2010 Thanks for sharing. Quote Link to comment https://forums.phpfreaks.com/topic/222920-help-with-soap-client/#findComment-1152643 Share on other sites More sharing options...
the182guy Posted December 29, 2010 Share Posted December 29, 2010 It will work with an array for the params (inputs) aswell, doesn't have to be an object. the SoapClient will convert both arrays and objects into the XML Soap envelope. It's good practice to use a try/catch structure when working with webservices because the SoapClient will throw an exception in your code if there is any problem with the SoapServer, which of course may be out of your control. Quote Link to comment https://forums.phpfreaks.com/topic/222920-help-with-soap-client/#findComment-1152646 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.