【发布时间】:2016-01-07 21:17:52
【问题描述】:
我正在使用代理进行网络服务调用。 使用代理的 SoapClient 调用工作正常,但使用相同 SoapClient 对象调用 webservice 函数失败。当我问服务器人员时,他们说他们可以看到第一个 GET 调用,但看不到 POST 调用。
代码如下:
$context = stream_context_create(
array(
'ssl' => array( 'SNI_enabled' => false, 'SNI_server_name' => $domain
),
'http' => array(
'proxy' => 'proxyurl:8080'
)
)
);
$soapOptions = array(
'trace' => true,
'stream_context' => $context
);
try {
$client = new SoapClient(WSDL_URL, $soapOptions);
} catch (SoapFault $fault) {
echo "SOAP Fault: (faultcode: {".$fault->faultcode."}, faultstring: {".$fault->faultstring."})", E_USER_ERROR;
} catch (Exception $e) {
echo "SOAP Exception: (faultcode: {".$fault->faultcode."}, faultstring: {".$fault->faultstring."})", E_USER_ERROR;
}
echo "Calling Grant Role";
echo "<hr>";
$userName = "username";
$roleIdFromUser = "userrole";
try {
$result = $client->GrantAffiliateUserRole(array('affiliateId' => AFFILIATEID, 'password' => AFFILIATEPASSWORD, 'username' => $userName, 'roleId' => $roleIdFromUser));
echo "Success";
} catch (SoapFault $fault) {
echo "SOAP Proxy Fault: (faultcode: {".$fault->faultcode."}, faultstring: {".$fault->faultstring."})", E_USER_ERROR;
echo "Failed Grant Fault";
} catch (Exception $e) {
echo "SOAP Exception: (faultcode: {".$fault->faultcode."}, faultstring: {".$fault->faultstring."})", E_USER_ERROR;
echo "Failed Grant Exception";
}
输出是:
object(SoapClient)#1 (4) { ["trace"]=> int(1) ["_stream_context"]=> resource(2) of type (stream-context) ["_soap_version"]=> int(1) ["sdl"]=> resource(4) of type (Unknown) }
Calling Grant Role
SOAP Proxy Fault: (faultcode: {HTTP}, faultstring: {Could not connect to host})256
Failed Grant Fault
再次,webservice 操作调用无法识别用于使 SoapClient 调用 WSDL 的代理。有什么帮助吗?
【问题讨论】: