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!

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

报告相同问题?

悬赏问题

  • ¥50 gki vendor hook
  • ¥15 centos7中sudo命令无法使用
  • ¥15 灰狼算法和蚁群算法如何结合
  • ¥15 这是一个利用ESP32自带按键和LED控制的录像代码,编译过程出现问题,请解决并且指出错误,指导如何处理 ,协助完成代码并上传代码
  • ¥20 stm32f103,hal库 hal_usart_receive函数接收不到数据。
  • ¥20 求结果和代码,sas利用OPTEX程序和D-efficiency生成正交集
  • ¥50 adb连接不到手机是怎么回事?
  • ¥20 抓取数据时发生错误: get_mooncake_data() missing 1 required positional argument: 'driver'的问题,怎么改出正确的爬虫代码?
  • ¥15 vs2022无法联网
  • ¥15 TCP的客户端和服务器的互联