PHP Laravel:SoapClient 问题致命错误:在 null 上调用成员函数 __soapCall()



我正在使用 SOAP 接口到另一台服务器处理一个项目,并且在使其工作时遇到了一些严重的问题。SOAP不是我非常熟悉的东西,我一直很难在任何地方找到帮助。即使是开发 WSDL 文件的人也没有能力帮助我......

我有一个 WSDL 文件 - https://sdkdev.wagefiler.com/WageFilerWS/wagefiler.asmx?WSDL

首先,我需要能够创建一个帐户。下面的代码可以工作,但返回一个错误"-999",根据WSDL和其他服务器端的开发人员,该错误是未定义的。他们告诉我要确保我传递的是帐户请求对象的实例...但我所做的似乎无济于事。

这是我的 SoapController.php 文件。我的路线指向"演示"。它从字面上返回错误 -999。

<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use AppHttpRequests;
use ArtisaninwebSoapWrapperSoapWrapper;
use Sentinel;
use AppbackendInformation;
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>";
}
}

返回值如下所示 -

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) "
    UserIDbob@bob.comPassword$5$rounds=5000$anexamplestringf$ADNI5REUuQNRHFXv3tId        EhLg65jb4Jc0csmuI4ENQu6Emailbob@bob.comClientId8266FNameBobLNameMcBobbersonEI    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"
}

看起来 WSDL 的 SOAP 文档是错误的。他们需要一堆我们在测试期间没有发送的字段。当您仔细检查 WSDL 文件时,它会显示它们,但文档说它们是特别可选的。

最新更新