0

Currently i'm trying to build a little PHP - Soap Connector, which worked pretty good so far. But when i'm deploying my little script to my server, it won't work anymore and i have no clue, why.

I'm connecting in 2 different ways (by curling the SOAP WSDL Scheme, and saving it temporary in the script location, and creating from that a new SOAP Client, and creating a SOAP Client directly by using the SOAP WSDL Scheme URL):

$opts = array(
    'http'=>array(
        'user_agent' => 'PHP Soap Client'
    )
);

$context = stream_context_create($opts);

// SOAP 1.2 client
$params = array (
    'encoding' => 'UTF-8',
    'verifypeer' => false,
    'verifyhost' => false,
    'soap_version' => SOAP_1_2,
    'trace' => 1,
    'exceptions' => 1,
    'connection_timeout' => 30,
);

$curlStuff = curl_init($soapURL);

curl_setopt($curlStuff,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curlStuff,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($curlStuff,CURLOPT_TIMEOUT,30);

$response = curl_exec($curlStuff);
$info = curl_getinfo($curlStuff);

if($response) {
    file_put_contents("./tempSoapScheme.wsdl", $response);
}

$soapClient = new SoapClient(
    './tempSoapScheme.wsdl',
    array(
        'trace' => 1,
        'stream_context' => $context,
        'cache_wsdl' => WSDL_CACHE_NONE
    )
);

$soapClientTwo = new SoapClient(
    $soapURL,
    array(
        'trace' => 1,
        'stream_context' => $context,
        'cache_wsdl' => WSDL_CACHE_NONE
    )
);

$result = $soapClient->myLoginMethod(
    array(
        'username' => 'my@email.example',
        'password' => 'password'
    )
);

As i said earlier - on my local machine it works like a charm, and everything is fine. The param "soapURL", which is not inside the script, is just the https path to my SOAP WSDL Scheme.

I've tried different options inside "$params" array, other curl setopt settings, but i can't make it work.

The response from both SoapClients:

SOAP-ERROR: Parsing WSDL: Couldn't load from '<MyURL>' : failed to load external entity "<MyURL>", which is pretty uncommon, because the CURL could save everything.

Do you have any suggestions for me?

EDIT - forgot the most important thing: - The server, which should execute the script, has very strong firewall restrictions, and the SOAP URL Scheme is on another server (not the same). And i guess, that is the point, why it won't work, but i receive an answer from the Scheme by executing CURL.. So it's just SOAP?

Tyralcori
  • 1,079
  • 13
  • 33
  • It's definitely not CURL and the SOAP-ERROR makes me think that your SOAP server is hit and responds something. Does your firewall make some kind of redirect / filtering of the URL which would cause the SOAP server to be hit with a wrong URL ? – Hussard Apr 27 '16 at 08:21
  • No, it's not CURL - because curl_exec returns the SOAP Scheme, as i wrote. The "execution server" is in the same cluster as the "soap server". but they are not allowed to see each other over the hostname. That's why i'm using the external HTTPS URL, which is working pretty fine (CURL returns stuff) - by initializing SOAP it makes such problems. How is the SoapClient resolving the URL? There has to be a difference between SoapClient setting and CURL. – Tyralcori Apr 27 '16 at 08:28
  • From what I can grasp here http://stackoverflow.com/questions/21861077/soap-error-parsing-wsdl-couldnt-load-from-but-works-on-wamp, the user agent could be some lead. Next things would be to inspect the request headers/content using `curl -v`and/or wireshark. It would tell us what's different between the one that works and the other. – Hussard Apr 27 '16 at 08:55
  • As you may can see, i'm already using an UserAgent. Also you can not set any HTTP Properties for a SoapClient - because it is a little bit different compared with CURL. – Tyralcori Apr 27 '16 at 08:59
  • Yep, I know but inspecting both of the request can get you on the lead about why SOAP client is not resolving the URL correctly (from the scheme). – Hussard Apr 27 '16 at 09:04
  • you can use SAOP_1_1 instead http://stackoverflow.com/questions/8588309/what-is-the-difference-between-soap-1-1-soap-1-2-http-get-http-post-methods – chongsong Jul 26 '16 at 03:46

0 Answers0