I'm trying to pull data from a SOAP API on a Wordpress site. I'm using the PHP SoapClient library.
I've scoured the internet over the past week trying every possible solution to this problem I can find, including trying other libraries, with no luck. I haven't even gotten to the point where I can pull data, I'm just trying to login to this service, which I can confirm the login and other functions work through thirdparty applications.
I've also tried refactoring my code into it's own class and calling things that way, but the same issues occur.
I keep getting the same error back no matter what I try:
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 NjoynDataGateway.Login(String pr_UserName, String pr_Password, Boolean pr_AbortExistingSession) --- End of inner exception stack trace
This is the code I'm using:
$url = 'https://qa1.njoyn.com/CL4/net/WebService/NjoynDataExport.asmx?wsdl';
$username = 'username';
$password = 'password';
$abort_session = true;
$namespace = "http://njoyn.com/";
$soap_client = new SoapClient($url);
// Body of the Soap Header.
$headerbody = [
'pr_UserName' => $username,
'pr_Password' => $password,
];
// Create Soap Header.
$header = new SOAPHeader($namespace, 'AuthHeader', $headerbody);
$soap_client->__setSoapHeaders($header);
$result = $soap_client->__SoapCall('Login', [
'pr_UserName' => $username,
'pr_Password' => $password,
'pr_AbortExistingSession' => $abort_session,
]);
var_dump($result);
Expected results would be something that isn't an error to start with. According to their documentation, the login method should return true.