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 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加