Home » Php » PHP / Laravel 5 SOAP / WSDL Issues

PHP / Laravel 5 SOAP / WSDL Issues

Posted by: admin October 26, 2017 Leave a comment

Questions:

I’m working on a project using a SOAP interface to another server and am having some serious issues getting this to work. SOAP is not something I am very familiar with and I have been having a really tough time finding help for this anywhere. Even the people who developed the WSDL file have no ability to help me…

I have a WSDL file – https://sdkdev.wagefiler.com/WageFilerWS/wagefiler.asmx?WSDL

For starters, I need to be able to create an account. The code below works but returns an error of “-999” which is undefined according to the developers of the WSDL and the other server side. They told me to make sure I’m passing an instance of an AccountRequest Object… but nothing I do seems to help.

This is my SoapController.php file. My route points to “demo”. It literally returns an error -999.

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use Artisaninweb\SoapWrapper\SoapWrapper;
use Sentinel;
use App\backendInformation;
use SoapClient;
use SoapHeader;
use SoapParam;
use SoapVar;

class SoapController extends Controller
{

public function demo()
{

    $WSDL = 'https://sdkdev.wagefiler.com/WageFilerWS/wagefiler.asmx?WSDL';
    $user = Sentinel::getUser();
    $backendInfo = backendInformation::where('user_id', $user['id'])->first();
    $b = new backendInformation();
    $b->user_id  = $user['id'];
    $b->username = $user['email'];
    $b->password = crypt($b['username'], '$5$rounds=5000$anexamplestringforsalt$');
    $b->customername = $user['first_name'] . ' ' . $user['last_name'];
    $b->useremail = $user['email'];
    $b->autoemail = $user['email'];



    $options = [
        'trace' => true,
        'cache_wsdl' => WSDL_CACHE_NONE
    ];

    $credentials = [
        'ClientID' => 'XXXX'
    ];


    $data = array(
        'sequence' => array(
            'UserID' => $user->nelco_user_id,
            'Password' => $user->nelco_password,
            'Email' => $b->useremail,
            'ClientId' => config('global.nelco_client_id'),
            'FName' => $user->first_name,
            'LName' => $user->last_name,
            'EIN' => $user->ein,
            'Addr1' => $user->addr1,
            'City' => $user->city,
            'State' => $user->state,
            'Zip' => $user->zip,
            'Phone' => $user->phone,
        ),
    );

    $client = new SoapClient($WSDL, $options); // null for non-wsdl mode

    $param = new SoapParam(new SoapVar($data, SOAP_ENC_OBJECT), 'AccountRequest');

    $client->__soapCall('AccountSetup',array($param));

    echo "<pre>";
    var_dump($client);
    echo "</pre>";

}
}

The return value looks like this –

object(SoapClient)#267 (12) {
  ["trace"]=>
  int(1)
  ["_stream_context"]=>
  resource(8) of type (stream-context)
  ["_soap_version"]=>
  int(1)
  ["sdl"]=>
  resource(10) of type (SOAP SDL)
  ["__last_request"]=>
  string(972) "
    [email protected]$5$rounds=5000$anexamplestringf$ADNI5REUuQNRHFXv3tId        [email protected]McBobbersonEI    N123123123Addr1123 Bobs PlaceCityBobvilleStateokZip73115Phone123-123-1234
"
  ["httpsocket"]=>
  resource(11) of type (stream)
  ["_use_proxy"]=>
  int(0)
  ["httpurl"]=>
  resource(12) of type (SOAP URL)
  ["__last_request_headers"]=>
  string(259) "POST /WageFilerWS/wagefiler.asmx HTTP/1.1
Host: sdkdev.wagefiler.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/7.1.8-1ubuntu1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://localhost/WageFiler/WageFiler/AccountSetup"
Content-Length: 972

"
  ["__last_response_headers"]=>
  string(330) "HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 25 Oct 2017 20:37:54 GMT
Content-Length: 382
Set-Cookie: BIGipServerpool_sdkdev.wagefiler.com_443=3389265580.47873.0000;     path=/; Httponly; Secure
"
  ["_cookies"]=>
  array(1) {
    ["BIGipServerpool_sdkdev.wagefiler.com_443"]=>
    array(3) {
      [0]=>
      string(21) "3389265580.47873.0000"
      [1]=>
      string(1) "/"
      [2]=>
      string(20) "sdkdev.wagefiler.com"
    }
  }
  ["__last_response"]=>
  string(382) "-999"
}
Answers: