我承认有点困惑。我需要将下面的SOAP(.net I presume)转换为php调用(它与Checkmarx集成 - https://checkmarx.atlassian.net/wiki/display/KC/Initiating+a+Session):
public void LogAdminIn()
{
CxSDKWebServiceSoapClient cxSDKProxy = new CxSDKWebServiceSoapClient();
CxWSResponseLoginData loginResult = cxSDKProxy.Login(new Credentials() { User = "admin@cx", Pass = "admin" }, 1033);
sessionID = loginResult.SessionId;
}
这是我的尝试:
$client = new SoapClient($ServiceURL);
$param = array(
'User' => $login,
'Pass' => $password,
'lcid' => "1033"
);
$result = $client->Login(new SoapParam ($param, "Credentials"));
var_dump($result);
但我不相信它实际上是对的(它不起作用,所以我认为它不是。)
我假设结构,但对它应该是什么感到困惑。
答案 0 :(得分:0)
你在php.ini文件中启用了肥皂吗?
extension=php_soap.dll
删除;
并添加到您的脚本中:
ini_set('display_errors', 1);
error_reporting(E_ALL);
ini_set('soap.wsdl_cache_enabled', '0');
ini_set('soap.wsdl_cache_ttl', '0');
你需要一些尝试捕获:
try {
$client = new SoapClient("some.wsdl");
$result = $client->SomeFunction(/* ... */);
} catch (SoapFault $fault) {
trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
}
检查一下,也许你会得到一些提示:)
答案 1 :(得分:0)
看起来Login()方法有两个参数:一个Credentials结构和一个整数。你只需稍微改变一下:
$credentials = array('User' => $login, 'Pass' => $password);
$lcid = 1033;
$result = $client->Login($credentials, $lcid);
如果这不起作用,您还可以尝试将$凭证作为对象:
$credentials = new stdClass();
$credentials->User = $login;
$credentials->Pass = $password;
$lcid = 1033;
$result = $client->Login($credentials, $lcid);
在进行调用之后,检查XML的实际调用并确保请求正确是有帮助的:
var_dump($client->__getLastRequest());