【问题标题】:php soap proxy failing in web service action callphp soap代理在Web服务操作调用中失败
【发布时间】: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 的代理。有什么帮助吗?

【问题讨论】:

    标签: php soap proxy


    【解决方案1】:

    我已经解决了这个问题。由于 Web 服务 URL 是 HTTPS,因此只需将 SSL 作为流上下文并将其与 Proxy 数组一起传递给 WSDL 调用,如下所示。

    $context = stream_context_create(
    array(
        'ssl' => array('SNI_enabled' => false)
        )
    );
    
    $soapOptions = array('proxy_host' => PROXY_HOST, 'proxy_port' => PROXY_PORT, 'stream_context' => $context);
    
    $client = new SoapClient(WSDL_URL, $soapOptions);
    

    【讨论】:

      猜你喜欢
      • 2012-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-05
      • 1970-01-01
      • 1970-01-01
      • 2010-10-10
      相关资源
      最近更新 更多