Authentication error in WSDL

Asked

Viewed 345 times

0

using the phptester to test the following code:

<?phptry {
$opts = array(
    'http' => array(
        'user_agent' => 'PHPSoapClient'
    )
);
$context = stream_context_create($opts);

$wsdlUrl = 'http://ws.portaledu.com.br:8051/wsConsultaSQL/MEX?wsdl';
$soapClientOptions = array(
    "login"      => "XxXxXxXx", 
    "password"  => "XxXxXxXxX",
    "stream_context" => $context,
    "cache_wsdl" => WSDL_CACHE_NONE
);

$client = new SoapClient($wsdlUrl, $soapClientOptions);

echo $status =(string) simplexml_load_string($client->RealizarConsultaSQL(['codSentenca'=>'06','codColigada'=>$CODCOLIGADA,'codSistema'=>'S','parameters'=>'CODCOLIGADA='.$CODCOLIGADA.';IDPS='.$IDPS.';CPF='.$CPF.';DTNASCIMENTO='.$DTNASCIMENTO])->RealizarConsultaSQLResult)->Resultado->DESCRICAO;

}
catch(Exception $e) {
    echo $e->getMessage();
}

get back:

WARNING Soapclient::Soapclient(http://ws.portaledu.com.br:8051/wsConsultaSQL/MEX? wsdl): failed to open stream: Connection refused on line number 17

Why not authenticate, will need to release some more port beyond 8051 to make SOAP requests?

1 answer

1

When the content is in a Ws endpoint, via php the most coherent is to do via CURL...

<?php
    $runfile = 'http://ws.portaledu.com.br:8051/wsConsultaSQL/MEX?wsdl';

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $runfile);

    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

    $content = curl_exec ($ch);

    curl_close ($ch); 

    echo $content;
  • the tip was very good, but let me complete the question so that we mark this answer once and for all as a solution,.

  • that your echo seems a bit strange... I’ll copy it and try to understand

  • It is a bit confusing even, however, the goal is: send a request SOAP for this wsdl I have already mentioned above, and call the function RealizarConsultaSQL() and show on the screen your return!

  • I suggest solving one problem at a time... give an echo on the return first and when you are returning what you expect to leave just for the function, then it is more organized the reasoning. About display the largest, depending on how the return comes you can transform into array and just choose the largest of the list.

  • I understand, but it helps me understand here, because this code did not return me error, let alone xml (did not return anything), as I will do the request for the RealizarConsultaSQL()

  • in fact the xml ta returning until qdo I lap right into the browser, then by the CURL tmb will be! from there you just need to process the return of it.

  • Try to understand this process and how it generates your code to consume the service: https://code.google.com/archive/p/php-wsdl-creator/

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.