A third party has given me his webservice document for testing. I try to connect to the soap webservice by passing values to the header and body.
The method I want to consume is ConsultarAfiliado.
the soap structure is :
POST /WSAutorizaciones/WSAutorizacionLaboratorio.asmx HTTP/1.1
Host: 191.97.91.43
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://arssenasa.gob.do/ConsultarAfiliado"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<AuthenticationHeader xmlns="https://arssenasa.gob.do/">
<Cedula>string</Cedula>
<Password>string</Password>
<Proveedo>int</Proveedo>
</AuthenticationHeader>
</soap:Header>
<soap:Body>
<ConsultarAfiliado xmlns="https://arssenasa.gob.do/">
<TipoDocumento>int</TipoDocumento>
<NumDocumento>string</NumDocumento>
</ConsultarAfiliado>
</soap:Body>
</soap:Envelope>
I tried these codes :
$wsdl =http://191.97.91.43/WSAutorizaciones/WSAutorizacionLaboratorio.asmx?WSDL";
$client = new SoapClient($wsdl, array('trace' => 1)); // The trace param will show you errors stack
$auth =array('Cedula' => '001-0945751-5', 'Password' => 'dmfvmxm2', 'Proveedo' => '12077');
$header = new SoapHeader('NAMESPACE','AuthenticationHeader',$auth,false);
var_dump($client->__setSoapHeaders($header));
// web service input params
$request_param = array('TipoDocumento' => '2', 'NumDocumento' => '021827151');
$responce_param = null;
try {
$responce_param = $client->ConsultarAfiliado($request_param);
print_r($responce_param->ConsultarAfiliadoResponse);
} catch (Exception $e) {
echo "<h2>Exception Error!</h2>";
echo $e->getMessage();
}
I got this error:
Exception Error! Server was unable to process request. ---> Object reference not set to an instance of an object.
May someone please help me fix that out.
Here is the WSDL: http://191.97.91.43/WSAutorizaciones/WSAutorizacionLaboratorio.asmx?WSDL