10
I’m trying to connect to the webservice but it’s not working. wsdl address is http://91.205.172.97/globalsight/services/AmbassadorWebService?wsdl
PHP code:
<?php
if (!class_exists('SoapClient'))
{
die ("You haven't installed the PHP-Soap module.");
}
$clientSoap = new SoapClient(
"http://91.205.172.97/globalsight/services/AmbassadorWebService?wsdl",
array(
'username' => 'teste123',
'password' => 'teste123.'
)
);
$params = array( 'username' => 'teste123',
'password' => 'teste123.' );
$result = $clientSoap->login( $params );
print_r($result);
?>
The answer:
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /home/brgwe507/public_html/previas/wp-content/plugins/sample-globalsight/sample-globalsight.php:31 Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://localhos...', '', 1, 0)
#1 /home/brgwe507/public_html/previas/wp-content/plugins/sample-globalsight/sample-globalsight.php(31): SoapClient->__call('login', Array)
#2 /home/brgwe507/public_html/previas/wp-content/plugins/sample-globalsight/sample-globalsight.php(31): SoapClient->login('')
#3 /home/brgwe507/public_html/previas/wp-includes/plugin.php(496): sample_globalsight('')
#4 /home/brgwe507/public_html/previas/wp-admin/admin.php(212): do_action('sample_globalsi...', Array)
#5 {main} thrown in /home/brgwe507/public_html/previas/wp-content/plugins/sample-globalsight/sample-globalsight.php on line 31
Thanks for all your help so far. I forgot to put the code that is working with Curl. With this code I can connect to the webservice, but I can’t do anything else because when I try to make another call with the generated token I get the message "stream closed":
function sample_globalsight(){
class soap_client{
public $xmlRequest;
public $header;
function set_header(){
$this->header = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"\"",
"Content-length: ".strlen($this->xmlRequest)
);
}
function send(){
$this->set_header();
$soapCURL = curl_init();
curl_setopt($soapCURL, CURLOPT_URL, "http://91.205.172.97/globalsight/services/AmbassadorWebService?wsdl" );
curl_setopt($soapCURL, CURLOPT_CONNECTTIMEOUT, 100);
curl_setopt($soapCURL, CURLOPT_TIMEOUT, 1000);
curl_setopt($soapCURL, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soapCURL, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soapCURL, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soapCURL, CURLOPT_POST, true );
curl_setopt($soapCURL, CURLOPT_POSTFIELDS, $this->xmlRequest);
curl_setopt($soapCURL, CURLOPT_HTTPHEADER, $this->header);
//Executing Curl Here.
$result = curl_exec($soapCURL);
if($result === false) {
$err = 'Curl error: ' . curl_error($soapCURL);
$result = $err;
//echo "This is text".$err;
}
curl_close($soapCURL);
return $result;
}
}
$data ='<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.globalsight.com/webservices/">
<soapenv:Header/>
<soapenv:Body>
<web:login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<p_username xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">teste123</p_username>
<p_password xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">teste123.</p_password>
</web:login>
</soapenv:Body>
</soapenv:Envelope>';
$obj = new soap_client();
$obj->xmlRequest = $data;
print_r($obj->send());
}
The address really needs authentication ?
– gmsantos
I tried with and without authentication and gave the same error in both cases.
– Ricardo BRGWeb
@Ricardolimagonçalves by what I read in error
SoapClient->__doRequest('<?xml version="...', 'http://localhos...', '', 1, 0)
I think you’re trying to connect to localhost, which is strange. Is there any server redirection going onhttp://91.205.172.97
?– Guilherme Nascimento
@Guilhermenascimento found this strange too. As it is the first time I use this type of api I thought it was normal this. In the xml generated by
http://91.205.172.97/globalsight/services/AmbassadorWebService?wsdl
the second information appears<wsdl:service name="AmbassadorService">
<wsdl:port binding="impl:AmbassadorWebServiceSoapBinding" name="AmbassadorWebService">
<wsdlsoap:address location="http://localhost:8080/globalsight/services/AmbassadorWebService"/>
</wsdl:port>
</wsdl:service>
.– Ricardo BRGWeb
That’s what I was just about to comment on. So this line is weird. I believe that in the documentation of this Webservice you have to define the domain and redirect port (theory). Or it’s a BUG (their configuration flaw). Which service is this, has documentation?
– Guilherme Nascimento
I may be wrong, but I think it’s some kind of proxy and you might want to disable it, see: https://github.com/tingley/globalsight/blob/master/main6/envoy/src/webserviceClients/ambassador-desktop/desktopicon/src/globalsight/www/webservices/AmbassadorServiceLocator.java#L25
– Guilherme Nascimento
It is the API of Globalsight, an open source translation and management system. [http://www.globalsight.com/wiki/index.php/GlobalSight_Web_Services_API]
– Ricardo BRGWeb
I will change the localhost pro IP and recompile to see if it works...
– Ricardo BRGWeb
Let’s go continue this discussion in chat.
– Ricardo BRGWeb
I added Curl code to the question. I’m not sure if it helps...
– Ricardo BRGWeb
@Ricardolimagonçalves You disabled the IP filter?
– stderr
@Qmechanic73 did disable it... to test if it was really disabled, I reactivated it and made the Curl call by a server that was not in the list and was blocked. Then I deactivated it again.
– Ricardo BRGWeb