0

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?

Géraud Willing B-S
  • 273
  • 1
  • 2
  • 17
  • I don't know how it is on Centos, but on Ubuntu, cli, fpm and Apache all have different php.ini-files. Make sure you're editing the correct one. – M. Eriksson Apr 26 '19 at 14:28
  • Maybe the body of the response is suppose to be empty. Did you check the response headers? – blupointmedia Apr 26 '19 at 14:34
  • @Magnus I set up my apache and my cli to use the same php.ini file. Since its works with cli then the problem could not come from ini file. – Géraud Willing B-S Apr 27 '19 at 00:20
  • @blupointmedia no the response is not empty. I got a not empty response when using the php cli instead of apache on my centos Server – Géraud Willing B-S Apr 27 '19 at 00:21
  • I'm not sure how Apache would be able to change the results of an API request made in PHP. The Soap request doesn't go through the web server. It's between PHP and the Soap-server. Have you checked the error log to see if you get any errors? – M. Eriksson Apr 27 '19 at 12:19
  • The problem is that I actually have absolutely no logs on the soap part. So I can find what goes wrong :/ But I reproduce the problem on my local laptop today. Just by installing the same apache as on my linux server and by using the same httpd/php.ini files. So I think that the issue probably cames from my httpd.conf file – Géraud Willing B-S Apr 29 '19 at 11:32
  • @MagnusEriksson The problem is that I actually have absolutely no logs on the soap part. So I can find what goes wrong :/ But I reproduce the problem on my local laptop today. Just by installing the same apache as on my linux server and by using the same httpd/php.ini files. So I think that the issue probably cames from my httpd.conf file – Géraud Willing B-S Apr 29 '19 at 14:43

1 Answers1

0

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!

Géraud Willing B-S
  • 273
  • 1
  • 2
  • 17