dongshanya2008 2019-04-26 14:20
浏览 432
已采纳

PHP SoapClient返回状态200没有任何响应

I have some issues when trying to perform a soap request to a salesforce api from a php code deployed on an apache 2.4 server (Centos 7).

My soap request works fine on localhost running with the php built-in server (php -S 0.0.0.0:8080). Its also works fine when I launch the built-in php server on my remote Centos host (php -S 0.0.0.0:8080 -c path-to-my-ini/php.ini). But doesn't works on apache. The problem is that I don't get any error response, it just returns null with status 200 so I have no way to debug deeply.

Here is my Soap client config:

public function getClient(){
        ini_set('soap.wsdl_cache_enabled',0);
        ini_set('soap.wsdl_cache_ttl',0); 

        $wsdl = PUBLIC_PATH.'/wsdl-metadata.xml'; // le fichier wsdl
        // creation de l'objet SOAP avec proxy et trace à TRUE       
        $service = new SoapClient($wsdl, array( 'proxy_host' => "xxx.proxy.xxx.fr", 
                                                'proxy_port' => 3130,
                                                'trace' => 1) );
        return $service;
    }

And here is my controller function which performs the soap request:

 public function editMock( Request $request, Response $response, $arg){
        $token = base64_decode($request->getQueryParams()['token']);
        $explodeToken = explode ('!', $token);
        $sandboxUrl = $this->getSandboxUrl($arg['sandbox']);
        $serviceName = $_POST['service'];
        $valueUseMock = $_POST['isMock'];

        $soapService = new SoapService($token);
        $client = $soapService->getClient();
        $soapService->updateServiceMock($serviceName, $valueUseMock);
        $xmlReq = $soapService->getXml();

        //url
        $location = "https://".$sandboxUrl."/services/Soap/m/44.0/" . $explodeToken[0];

        // appel soap avec la requete créée 
        return $client->__doRequest($xmlReq, $location, null, 44, 0);
    }

Note that I already activate soap in my php_ini

; SOAP - Extension permettant les echanges clients/serveurs SOAP.
extension = soap.so

Am I doing something wrong?

  • 写回答

1条回答 默认 最新

  • douchang8219 2019-05-13 08:04
    关注

    We finally figure it out. The rease why it works with php built-in server and doesn't work on apache was that we disable tls and ssl in our composer.json

    "config": {
            "process-timeout": 0,
            "sort-packages": true,
            "secure-http" : true,
            "disable-tls" : false
        },
    

    And since the php built-in server use composer.json, it bypass the tls/ssl verifications. So we just install the salesforce certificate on our apache server and set soap to use it and It works now.

    Thanks all for your replies!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题