PHP SoapClient returns null even if there is an answer

Using PHP SoapClient, I make a WSDL call 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> 

However, calling $soapclient->simulateOrder() returns null .

How to force PHP SoapClient to return an object instead of null?

Note. The xml that I use to call the soap is manually generated by overriding on SoapClient::__doRequest() . The code for calling the soap is as follows:

 $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(); 

An exception is not thrown, but $result is null

+8
wsdl php soap-client
source share
3 answers

The problem is setting up SSL, the error that occurs when trying to call your code on my server is as follows:

Fatal error: throw exception SoapFault: [WSDL] SOAP-ERROR: WSDL analysis: could not be loaded 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} is thrown at ... on line 22

I assume that you are trying to get the code to work with a self-signed certificate, as indicated in your SSL array inside the request, however, SoapClient seems to be ignoring it and throwing an error anyway.

So, my solution would be to either buy SSL (days are very cheap now, try sites like namecheap, etc.), or use something like https://letsencrypt.org/ to get SSL, which will allow your Soap client work properly.

Finally, I noticed a typo in your code, one line before the last you have )); which should read ))); .

Koda

+3
source share

The problem is that SOAP must have a valid SSL certificate.

For a test server, this is sometimes not worth the effort, so perhaps this link will help you use a small desktop so that your SOAP request works without the need to create a fully verified SSL certificate:

http://automationrhapsody.com/send-soap-request-over-https-without-valid-certificates/

+1
source share

The problem is not in your certificate as on the client, but on the server itself (try downloading https://webservices-test.ede.de:9443/ibis/ws/WS_EXT_ELC?wsdl in the browser), which is wrong, you can ignore it completely, since the server certificate is basically to avoid phishing, and I understand that this is really the one you are trying to achieve. On the curl command line, this is implemented using the -k option. In php, SoapClient for sure, you can use this (it is your problem, check the third answer and see what PHP7 says)

NOTE. You load wsdl, the service definition file, with each SoapClient construct. If you store $ soapclient as a static variable, you can use its methods all the time without having to recreate the client object (and thus avoiding reloading and reinterpreting the wsdl file, which can be delayed perfectly from 1 to 5 seconds) all the time.

+1
source share

All Articles