PHP SOAP客户端连接

f0ofjuux  于 2023-06-04  发布在  PHP
关注(0)|答案(1)|浏览(251)

我想连接一个SOAP客户端(通过PHP 7.4)。
提供的数据为https://plc.post.at/Post.Webservice/ShippingService.svc?wsdl Der HTTPS端点:https://plc.post.at/Post.Webservice/ShippingService.svc/secure
如何连接SOAP客户端?我总是得到SOAP-ERROR:解析WSDL:无法从'https://plc.post.at/Post.Webservice/ShippingService.svc加载?wsdl':无法加载外部实体“https://plc.post.at/Post.Webservice/ShippingService.svc?wsdl“

$soap = new SoapClient('https://plc.post.at/Post.Webservice/ShippingService.svc?wsdl', $options); should connect but does not.
$options = array(
    'follow_location' => 1,
    'cache_wsdl' => 0,
    'allow_redirects' => true,
    'http_errors' => true,
    'decode_content' => true,
    'verify' => false,
    'cookies' => false,
    'idn_conversion' => false,
    // SSL Configuration
    'stream_context' => $context,    
    'trace' => 0,    
    'exceptions' => true,
    'ciphers' => 'RC4-SHA',
    'soap_version' => SOAP_1_2,
    'stream_context' => stream_context_create(array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        )
    )));
ssm49v7z

ssm49v7z1#

我在本地设置了这个,并尝试使用SoapClient连接:

<?php

$client = new SoapClient('https://plc.post.at/Post.Webservice/ShippingService.svc?wsdl', []);

这给了我你在文章中描述的同样的错误:
解析WSDL:无法从“https://...”加载:无法加载外部实体“https://...”
我更改了php.ini配置中的以下行。

  1. ;extension=opensslextension=openssl
  2. ;extension=soapextension=soap
  3. ;extension=php_openssl.dllextension=php_openssl.dll
    1.已重新启动Web服务器
    WSDL位于https连接的后面,这就是您需要启用扩展的原因。
    使用$client->__getFunctions();可以获得:
array(12) {
    [0]=> string(65) "ImportShipmentResponse ImportShipment(ImportShipment $parameters)"
    [1]=> string(119) "ImportShipmentAndGenerateBarcodeResponse ImportShipmentAndGenerateBarcode(ImportShipmentAndGenerateBarcode $parameters)"
    [2]=> string(98) "ImportShipmentReturnImageResponse ImportShipmentReturnImage(ImportShipmentReturnImage $parameters)"
    [3]=> string(80) "ImportShipmentForceResponse ImportShipmentForce(ImportShipmentForce $parameters)"
    [4]=> string(62) "ImportAddressResponse ImportAddress(ImportAddress $parameters)"
    [5]=> string(68) "PerformEndOfDayResponse PerformEndOfDay(PerformEndOfDay $parameters)"
    [6]=> string(86) "PerformEndOfDaySelectResponse PerformEndOfDaySelect(PerformEndOfDaySelect $parameters)"
    [7]=> string(107) "GetAllowedServicesForCountryResponse GetAllowedServicesForCountry(GetAllowedServicesForCountry $parameters)"
    [8]=> string(68) "CancelShipmentsResponse CancelShipments(CancelShipments $parameters)"
    [9]=> string(134) "GetAvailableTimeWindowsForPickupOrderResponse GetAvailableTimeWindowsForPickupOrder(GetAvailableTimeWindowsForPickupOrder $parameters)"
    [10]=> string(98) "ImportPickupOrderBusinessResponse ImportPickupOrderBusiness(ImportPickupOrderBusiness $parameters)"
    [11]=> string(74) "CancelPickupOrderResponse CancelPickupOrder(CancelPickupOrder $parameters)"
}

相关问题