从php-soapclient在soap服务上发帖的问题



我是一个新使用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致命错误:未捕获的SoapFault异常:[Client]函数("solicitudCuis"(不是/home/jose/projects/ssoapclient/soapclient.php中此服务的有效方法:22堆栈跟踪:#0/home/jose/projects/soapcclient/soapcclient.php(22(:soapclient-&gt__call((#1{main}在第22行的/home/jose/projects/soapclient/soapclient.php中抛出

问题在于调用soap方法时。

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

您的客户端找不到您正在调用的方法。

编辑:您应该启用soap扩展,请参阅此处的

最新更新