在 php soapclient 的 soap 服务中执行 post 的问题
problem to do a post at soap service from php soapclient
我是 soap 服务的新手,所以当我在 php 中使用 soapclient 使用 soap 服务时遇到问题。这是 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>
好的,这是我的代码 php 查询 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());`
?>
另外,这是__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;
}"
我不知道如何必须发送参数来填充请求...或者我写错了我的数组或者我不知道 xd
当我在终端执行 php myclientsoap.php 时,出现此错误:
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
你的问题是在你调用soap方法的时候。
$respuestaSoap = $WebService->__soapCall('solicitudCuis',array($parameters));
您的客户端找不到您正在调用的方法。
编辑:您应该启用 soap 扩展,请参阅 here
我是 soap 服务的新手,所以当我在 php 中使用 soapclient 使用 soap 服务时遇到问题。这是 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>
好的,这是我的代码 php 查询 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());`
?>
另外,这是__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;
}"
我不知道如何必须发送参数来填充请求...或者我写错了我的数组或者我不知道 xd
当我在终端执行 php myclientsoap.php 时,出现此错误:
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
你的问题是在你调用soap方法的时候。
$respuestaSoap = $WebService->__soapCall('solicitudCuis',array($parameters));
您的客户端找不到您正在调用的方法。
编辑:您应该启用 soap 扩展,请参阅 here