Using the PHP SoapClient, I make a call to the WSDL at https://webservices-test.ede.de:9443/ibis/ws/WS_EXT_ELC?wsdl and I get the following xml response (as indicated by $soapclient->__last_response
)
<?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>
Nevertheless, the call to $soapclient->simulateOrder()
returns null
.
How do I get the PHP SoapClient to return an object instead of null?
Note: The xml I use for the soap call is generated manually by an override to SoapClient::__doRequest()
. The code for the soap call looks like:
$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();
No exceptions are thrown, but $result
is null
3 Answers
Answers 1
The problem is the SSL setup, the error that is thrown when I try to call your code on my server is as follows:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://webservices-test.ede.de:9443/ibis/ws/WS_EXT_ELC?wsdl' : failed to load external entity "https://webservices-test.ede.de:9443/ibis/ws/WS_EXT_ELC?wsdl" in /home/repojarilo/public_html/sc.php:22 Stack trace: #0 /home/repojarilo/public_html/sc.php(22): SoapClient->SoapClient('https://webserv...', Array) #1 {main} thrown in ... on line 22
I am assuming you are trying to get the code to work with a self signed certificate as indicated in your SSL array inside of the request, however it looks like the SoapClient is not paying attention to it and throwing an error anyway.
So my solution would be to either buy an SSL (very cheap now days, try sites such as namecheap etc...) or use something like https://letsencrypt.org/ to obtain an SSL that will allow your soap client to work correctly.
Lastly I noticed a typo, in your code one line before last you have ));
which should read )));
.
Koda
Answers 2
The Problem is that SOAP needs a valid SSL-Certificate.
For an testing-server it's sometimes not worth the effort, so maybe this link help you to use a little workarround, to got your SOAP-Request working without need to create a fully-validated SSL-Certificat:
http://automationrhapsody.com/send-soap-request-over-https-without-valid-certificates/
Answers 3
Problem is not your certificate as client, but server certificate itself (try to load https://webservices-test.ede.de:9443/ibis/ws/WS_EXT_ELC?wsdl in a browser), that is invalid. You can ignore it perfectly, as server certificate it's mainly to avoid phishing, and I understand that url it's really the one you're attempting to reach. In command line curl, this is realized with the -k option. In php, SoapClient exactly, you can use this (exactly your problem, check third answer, and see what says about PHP7)
NOTE: You are loading wsdl, the definition file of the service, at each construction of SoapClient. If you store $soapclient as a static variable, you can use it's methods all the time without the need of recreate the client object (and so, avoiding to reload and reinterpret the wsdl file, that can delay perfectly from 1 to 5 seconds) all the time.
0 comments:
Post a Comment