-1

i'm a new using soap services, so i have a problem when i consume a soap service using soapclient in php. this is the request at soap:

<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/"     xmlns:sia="https://misite.com/">
<x:Header/>
<x:Body>
<sia:cuis>
<SolicitudCuis>
<codigoAmbiente>2</codigoAmbiente>
<codigoModalidad>1</codigoModalidad><codigoPuntoVenta>0</codigoPuntoVenta>
<codigoSistema>79612597C2915E</codigoSistema>   
<codigoSucursal>0</codigoSucursal>          
 <nit>6409401</nit>
 </SolicitudCuis>    
 </sia:cuis>
</x:Body>
</x:Envelope>

ok, and this is my code php to consult an a function of the soapservice:

<?php
$token_to_access="apikey: TokenApi eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqb2VfZW1wcmVzYSIsImNvZGlnb1Npc3RlbWEiOiI3MUU4NzY1QTk2MTI1OTdiOiJTRkUifQ.xh5SF_yeo0II_wabdK_dTRTe9LSdBmfMUursWwiNx9UUdTpAhF6nkqoxzSTxTV1NlqFqauAG7LLgCdWw5ug8ew";
$wsdl="``https://pilotomysite/v2/genCodes?wsdl``";
$context = array(
    'http' => array(
    'header' => $token_to_access //user token catured in your sesuite account details
));

$client = new SoapClient(
    $wsdl,
    array(
        "trace" => 1, // enable trace
        "exceptions" => 1, // enable exceptions
        "stream_context" => stream_context_create($context)
    ));
$parameters=['codigoAmbiente'=>'2','codigoModalidad'=>1,'codigoPuntoVenta'=>0,'codigoSistema'=>'79612597C291','codigoSucursal'=>0,'nit'=>'6409401'];
//$response=$client->__soapCall('cuis',$parameters);
$client->solicitudCuis(2,1,0,'79612597C2915E',0,6409401);
//var_dump($client->__getTypes());`
?>

additional, this is the result of __getTypes()

[25]=>
    string(45) "struct cuis {
    solicitudCuis SolicitudCuis;
}"

[26]=>
    string(145) "struct solicitudCuis {
    int codigoAmbiente;
    int codigoModalidad;
    int codigoPuntoVenta;
    string codigoSistema;
    int codigoSucursal;
    long nit;
}"

i dont know how to must send the parameters to fill the request... or maybe i'm writing bad my array or i dont know xd

when i do php myclientsoap.php at terminal, i have this error:

jose@jose-Lenovo-V14-ADA:~/projects/soapclient$ php soapclient.php PHP Fatal error: Uncaught SoapFault exception: [Client] Function ("solicitudCuis") is not a valid method for this service in /home/jose/projects/soapclient/soapclient.php:22 Stack trace: #0 /home/jose/projects/soapclient/soapclient.php(22): SoapClient->__call() #1 {main} thrown in /home/jose/projects/soapclient/soapclient.php on line 22

M. Eriksson
  • 13,450
  • 4
  • 29
  • 40

1 Answers1

0

Your problem is when you call the soap method.

$respuestaSoap = $WebService->__soapCall('solicitudCuis',array($parameters));

Your client can´t find the method that you are calling.

Edit: you should have the soap extension enabled, see here

Voxxii
  • 369
  • 2
  • 9
  • hi, well... if i use how to call of function (cuis or solicitudCuis), i have the same error, and yes, my soap its ok, if i call the funcion verificarComunicacion and i pass it a arrary empty, i have a good response (this method doesnt need parameters) – GMiguel S. Apr 05 '22 at 16:43
  • 1
    I solved it, just take other perspective and remake the array: $data= array ( 'SolicitudCuis' => array ( 'codigoAmbiente' => '2', 'codigoModalidad' => '1', 'codigoPuntoVenta' => '0', 'codigoSistema' => '71EA2915E', 'codigoSucursal' => '0', 'nit' => '64012', ), ); var_dump($client->cuis($data)); Thanks my friend. – GMiguel S. Apr 05 '22 at 22:03