2017-09-04 218 views
8

使用PHP SoapClient的,我做的WSDL调用在https://webservices-test.ede.de:9443/ibis/ws/WS_EXT_ELC?wsdl和我得到以下XML响应(通过$soapclient->__last_response所示)PHP SoapClient的返回null,甚至认为有一个响应

<?xml version='1.0' encoding='UTF-8'?><soap:Envelope xmlns:ede="http://ede.de/webservices" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><Response action="ELC" requestId="1" version="1.0"><created>2017-09-04T16:04:46.556+02:00</created><StatusInformation>OK</StatusInformation><StatusCode>0</StatusCode><Payload><SalesOrderSimulateConfirmation><Items><Item><ID>10</ID><ProductID>0003062700050</ProductID><Price>2.970</Price><PositionPrice>2.970</PositionPrice><PriceUnit>1</PriceUnit><QuantityUnit>ST</QuantityUnit><QuantityAvailable>1</QuantityAvailable><QuantityProfile>1</QuantityProfile><Currency>EUR</Currency><Services /><Schedules>Geplante Liefertermine: 1 ST in KW 36.2017;</Schedules><Remark /><DangerMaterial /></Item></Items></SalesOrderSimulateConfirmation></Payload></Response></soap:Body></soap:Envelope> 

尽管如此,来电$soapclient->simulateOrder()回报null

如何让PHP SoapClient的返回一个对象,而不是空的?

注:我使用的肥皂调用XML手动生成由一个覆盖到SoapClient::__doRequest()。为SOAP调用的代码如下所示:

$soapClient = new SoapClient('https://webservices-test.ede.de:9443/ibis/ws/WS_EXT_ELC?wsdl', array(
    'cache_wsdl' => WSDL_CACHE_NONE, 
    'trace'  => true, 
    'exceptions' => true, 
    'soap_version' => SOAP_1_2, 
    'features'  => SOAP_SINGLE_ELEMENT_ARRAYS, 
    'login' => '------', // cannot post here for security purposes 
    'password' => '-----', // cannot post here for security purposes 
    'stream_context' => (
     stream_context_create(array(
      'ssl' => array(
       'verify_peer' => false, 
       'verify_peer_name' => false, 
       'allow_self_signed' => true 
      ) 
     )) 
)); 
$result = $soapClient->simulateOrder(); 

没有异常抛出,但$resultnull

+0

你能告诉我们你的函数simulateOrder()吗? –

回答

3

的问题是SSL设置,当我尝试打电话给您的代码所引发的错误我服务器如下:

致命错误:未捕获的SOAPFault异常:[WSDL] SOAP的错误:解析WSDL:无法从 'https://webservices-test.ede.de:9443/ibis/ws/WS_EXT_ELC?wsdl' 中加载:未能加载外部实体 “https://webservices-test.ede.de:9443/ibis/ws/WS_EXT_ELC?wsdl” 在/ home/repojarilo /的public_html /sc.php:22堆栈跟踪:#0 /home/repojarilo/public_html/sc.php(22):所以, apClient-> SoapClient('https://webserv ...',Array)#1 {main}抛出...在第22行

我假设您试图让代码与自签名证书一起工作在请求中的SSL数组中,但它看起来像SoapClient没有注意到它并抛出错误。

所以我的解决方案是要么购买SSL(非常便宜的日子,尝试诸如namecheap等网站...)或使用类似https://letsencrypt.org/的东西来获得一个SSL,这将允许您的肥皂客户端正常工作。

最后,我注意到一个错字,在你的代码前一行你有));应该是)));

Koda

1

问题不是您的证书作为客户端,而是服务器证书本身(尝试在浏览器中加载https://webservices-test.ede.de:9443/ibis/ws/WS_EXT_ELC?wsdl),这是无效的。你可以完全忽略它,作为服务器证书,它主要是为了避免网络钓鱼,并且我明白,它是你真正想要达到的网址。在命令行curl中,这是通过-k选项实现的。在PHP中,SoapClient完全可以使用this(完全是你的问题,检查第三个答案,并查看关于PHP7的说明)。

注意:您正在每次构建SoapClient时加载服务的定义文件wsdl。如果将$ soapclient作为静态变量存储,则可以始终使用它的方法,而无需重新创建客户端对象(因此,避免重新加载并重新解释wsdl文件,该文件可能会在1到5秒内完全延迟),所有时间。

相关问题