I’m trying to integrate a SOAP-based API into my WordPress website, but I’m facing issues with loading the WSDL file. I’ve followed the documentation and several tutorials, but I keep encountering the same error. Here’s the situation:
Problem: I’m trying to use the SOAP extension in PHP to connect to a SOAP-based API. However, when I attempt to fetch the WSDL file using the SoapClient class, I’m consistently getting the error message:
Error fetching listings: SOAP-ERROR: Parsing WSDL: Couldn’t load from ‘https://api.immowelt.de/immoweltag/api/v1/search?wsdl’ : failed to load external entity “https://api.immowelt.de/immoweltag/api/v1/search?wsdl” What I’ve Tried:
Checked the WSDL URL: I’ve verified that the URL is correct and accessible. When I open the URL in a browser, I can see the WSDL XML. Enabled SOAP Extension: I’ve made sure that the SOAP extension is enabled in my PHP configuration. I’ve also confirmed that I’m editing the correct php.ini file for my local server. Firewall and Network: I’ve checked for any network or firewall restrictions that might be preventing outbound connections. My hosting provider (Hetzner) is used, and I’m not sure if there are any specific settings I need to configure. SSL/TLS Configuration: I’ve looked into my server’s SSL/TLS settings and ensured they are correctly configured.
Here is the code that I have tried:
function fetch_and_display_immowelt_listings() {
$api_key = ‘apikey’;
// WSDL URL for Immowelt SOAP API
$wsdl_url = ‘https://api.immowelt.de/immoweltag/api/v1/search?wsdl’;
try {
// Create a SOAP client
$soap_client = new SoapClient($wsdl_url, array(‘trace’ => 1));
// Construct SOAP request parameters
$params = array(
‘apiKey’ => $api_key,
‘CurrentPage’ => 1,
‘PageSize’ => 10,
// Add other request parameters here
);
// Make the SOAP API call
$response = $soap_client->GetList($params); // Replace with the actual method name
// Process the response and display listings
return ‘Immowelt listings: ‘ . print_r($response, true);
} catch (SoapFault $e) {
return ‘Error fetching listings: ‘ . $e->getMessage();
}
}
add_shortcode(‘immowelt_listings’, ‘fetch_and_display_immowelt_listings’);
I’m not sure why I’m encountering this issue consistently. Is there anything specific I’m missing or overlooking that could be causing this problem? Are there any Hetzner-specific settings I need to configure for using SOAP? Any guidance or suggestions on how to troubleshoot and resolve this issue would be greatly appreciated.