Passing values to header and body of SOAP

Hi there,
I’m very happy to join this community for the first time. I some good knowledge of php but I’m really new the PHP SOAP. I have a webservice document that has the SOAP structure to pass values to the function and get the response. This is the structure:

				POST /WSAutorizaciones/WSAutorizacionLaboratorio.asmx HTTP/1.1
			Content-Type: text/xml; charset=utf-8
			Content-Length: length
			SOAPAction: "https://arsvesa.como/ConsultarAfiliado"

			<?xml version="1.0" encoding="utf-8"?>
			<soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap="">
			<AuthenticationHeader xmlns="">
			<ConsultarAfiliado xmlns="">

I try to consume the function *ConsultarAfiliado * like this:
$wsdl = “”;
$client = new SoapClient($wsdl, array(‘trace’ => 1)); // The trace param will show you errors stack

			$auth =array('Cedula' => '02109427015', 'Password' => 'dmfvmxm2', 'Proveedo' => '12077');
			$header = new SoapHeader('NAMESPACE','AuthenticationHeader',$auth,false);

			// web service input params
			$request_param = array('TipoDocumento' => '2', 'NumDocumento' => '021827151');
			$responce_param = null;
			try {
			$responce_param = $client->ConsultarAfiliado($request_param);

			} catch (Exception $e) {
			echo "<h2>Exception Error!</h2>";
			echo $e->getMessage();

I got his error: *I got this error:

Exception Error! Server was unable to process request. —> Object reference not set to an instance of an object.*
As I’m new to using SOAP would anyone help me to solve that out.

Many thanks

hello, I did not withdrawn my post, why you mention that ?

COLT deleted HIS post…

Is the end point even set-up? Whats at this IP: [] if you go there directly in the browser? Anything?

the correct end point is:

yes I got the wsl file in the browser, I even consumed in postman.

Hi @baptiste.prophete I recorded this video about auth with PHP Soap using headers some time ago. I believe it can come in handy for you :wink:

1 Like

Many thanks guy, you save my live. I did it thanks to you…

1 Like

Great! Glad to help.

Share the video around :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service