Jump to content

Help with SOAP client...


tillman.stevens

Recommended Posts

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:

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.