Question

I am trying to get a PHP SoapClient working with GAE but can't seem to make it happen.

  • I have billing enabled for the project.
  • The project works fine locally and on many other servers.
  • On GAE I get the error "Could not connect to host" code: "HTTP"

Expected result: "Your input parameters are Test1 and Test2"

app.yaml

application: store-kiosk
version: 2
runtime: php
api_version: 1

handlers:
- url: /favicon.ico
  static_files: favicon.ico
  upload: favicon.ico
- url: /.*
  script: index.php

php.ini

extension=php_openssl.dll
extension_dir = "C:\php\ext"
google_app_engine.enable_functions = "libxml_disable_entity_loader"

index.php

<?php
  libxml_disable_entity_loader(false);
  $client = new SoapClient('http://www.SoapClient.com/xml/SoapResponder.wsdl',array("trace"=>1));
  try {
    $client->__soapCall('Method1',array('Test1','Test2'));
    echo $client->__getLastResponse();
  } catch (Exception $e) {
    echo "<pre>Exception: ".print_r($e, true)."</pre>\n";
  }
?>
Was it helpful?

Solution

The logs for your application make it pretty obvious what's going on - you haven't enabled billing for the app.

The Socket API will be enabled for this application once billing has been enabled in the admin console.

For the record, both of these work fine for me.

libxml_disable_entity_loader(false);
$client = new SoapClient(
    'http://www.soapclient.com/xml/SoapResponder.wsdl',
    ['connection_timeout' => 30]);

print_r($client->Method1('foo', 'bar'));

and

libxml_disable_entity_loader(false);
$client = new SoapClient(
    'http://www.soapclient.com/xml/SoapResponder.wsdl',
    ['connection_timeout' => 30]);

$r = $client->__soapCall('Method1',['foo','bar']);
if (is_soap_fault($r)) {
  trigger_error("SOAP Fault: (faultcode: {$r->faultcode}, faultstring: {$r->faultstring})", E_USER_ERROR);
} else {
  print_r($r);
}

Both print

Your input parameters are foo and bar
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top