【发布时间】:2017-10-25 20:48:57
【问题描述】:
我正在开发一个使用 SOAP 接口连接到另一台服务器的项目,并且在使其正常工作时遇到了一些严重的问题。 SOAP 不是我非常熟悉的东西,而且我在任何地方都很难找到帮助。连开发 WSDL 文件的人都没有能力帮我……
我有一个 WSDL 文件 - https://sdkdev.wagefiler.com/WageFilerWS/wagefiler.asmx?WSDL
首先,我需要能够创建一个帐户。下面的代码可以工作,但返回一个错误“-999”,根据 WSDL 和其他服务器端的开发人员,该错误是未定义的。他们告诉我要确保我正在传递一个 AccountRequest 对象的实例......但我所做的似乎没有任何帮助。
这是我的 SoapController.php 文件。我的路线指向“演示”。它实际上返回一个错误 -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>";
}
}
返回值是这样的——
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"
}
【问题讨论】:
-
如果你调用这样的函数会发生什么 $client->__soapCall('AccountSetup',[$data]);我无法加载 wsdl ..
-
我得到几乎完全相同的输出
-
object(SoapClient)#275 (12) { ["trace"]=> int(1) ["_stream_context"]=> resource(8) of type (stream-context) ["_soap_version "]=> int(1) ["sdl"]=> resource(10) 类型 (SOAP SDL) ["__last_request"]=> string(238) " "
-
它在最后一个请求中没有显示任何内容......响应不会让我输入完整的输出,所以我把它修剪掉了
-
能在soapui中测试过吗>
标签: php laravel web-services soap soap-client