我正在尝试使用SOAP API,以下是WSDL:http://clientes.tcc.com.co/servicios/informacionremesas.asmx?wsdl,具体来说,该方法称为:ConsultarInformacionRemesasEstadosUEN
问题是,当我使用名为SoapUI的程序发出请求时,得到200响应,但是当我从Laravel项目中获得响应时,出现错误。我在做什么错了?
protected $pass ;
protected $url;
public function __construct($pass='APIKEY',$url="http://clientes.tcc.com.co/servicios/informacionremesas.asmx?wsdl")
{
$this->pass=$pass;
$this->url=$url;
}
public function test()
{
try{
$param=array('Clave'=>$this->pass,'numeroremesa'=>433654926,'unidadnegocio'=>1,'Respuesta'=>0);
$client = new SoapClient($this->url,array('trace'=>TRUE));
$response =$client->ConsultarInformacionRemesasEstadosUEN($param);
dd($client->__getLastRequest());
exit;
// $array= json_decode(json_encode($response),true);
}
catch(Exeption $fault){
return response()->json(['entro'=>'entro en la exepcion',"error"=>$fault->getMessage()],400);
}
}
我收到以下500错误
"message": "System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.\n at ServiciosWeb.InformacionRemesas.ConsultarInformacionRemesasEstadosUEN(String Clave, List`1 remesas, List`1& remesasrespuesta, Int32& Respuesta, String& Mensaje) in C:\\TCC\\Proyectos\\Legacy\\WSNET\\2-Desarrollo\\3-Servicios\\ServiciosWeb\\ServiciosWeb\\InformacionRemesas.asmx.vb:line 443\n --- End of inner exception stack trace ---",
"exception": "SoapFault",
"file": "C:\\xampp\\htdocs\\GirosYa\\app\\Http\\Controllers\\Api\\ExternalApis\\TccController.php",
"line": 35,
"trace": [
{
"file": "C:\\xampp\\htdocs\\GirosYa\\app\\Http\\Controllers\\Api\\ExternalApis\\TccController.php",
"line": 35,
"function": "__call",
"class": "SoapClient",
"type": "->"
},
它可以在SoapUI上正常工作,所以我不确定该软件是否在添加标头或类似的标头,非常感谢您的帮助。
答案 0 :(得分:0)
基于该WSDL和错误消息,看来您的'numeroremesa'=>433654926,'unidadnegocio'=>1
需要包装在一个数组中,该数组的主键为“ remesas”。这意味着您的$param
应该如下:
$param=array('Clave'=>$this->pass,'remesas' => array('numeroremesa'=>433654926,'unidadnegocio'=>1),'Respuesta'=>0)
WSDL中表明这一点的部分是:
<s:element minOccurs="0" maxOccurs="1" name="remesas" type="tns:ArrayOfRemesaUEN"/>
...
<s:element minOccurs="0" maxOccurs="unbounded" name="RemesaUEN" nillable="true" type="tns:RemesaUEN"/>
...
<s:complexType name="RemesaUEN">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="numeroremesa" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="unidadnegocio" type="s:string"/>
</s:sequence>
</s:complexType>
错误消息中表明这一点的部分是:
在ServiciosWeb.InformacionRemesas.ConsultarInformacionRemesasEstadosUEN(String Clave,清单
1 remesas, List
1&remesasrespuesta,Int32&Respuesta, String&Mensaje)
请注意为该函数显示的参数列表