Workaround for PHP SOAP request failure when wsdl defines service port binding as https and port 80?

后端 未结 2 1853
旧时难觅i
旧时难觅i 2021-01-24 08:20

I am consuming a SOAP web service using php5\'s soap extension. The service\' wsdl was generated using Axis java2wsdl, and whatever options are used during generation result in

2条回答
  •  别那么骄傲
    2021-01-24 08:57

    If you can't find a more elegant solution, you can always download the file, do the string replacements, then use that as the WSDL.

    $cached_wsdl_file = './cached_wsdl.xml';
    if (filemtime($cached_wsdl_file) > time() - 3600) {
        $wsdl = file_get_contents('http://server/service?wsdl');
        $wsdl = str_replace('server:80', 'server', $wsdl);
        file_put_contents($cached_wsdl_file, $wsdl);
    }
    $client = new SoapClient($cached_wsdl_file);

提交回复
热议问题