Pass parameters from the Web Service header?

0

I'm trying to make a web service call on AngularJS, however I'm getting the following error message in the browser console (I tested it in chrome and Firefox):

  

XMLHttpRequest can not load

     

No Access-Control-Allow-Origin header is present on the requested   resource. Origin ' link ' is therefore not allowed   access.

As far as I understand, soap complained that I did not send the request headers. Actually the service requires headers as below, however I do not know how to pass them in the parameter of the post call, I just sent the body parameters of the request.

Header Parameters: User and Store:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

   <soapenv:Header>
      <v1:header>
         <usuario>?</usuario>
         <loja>?</loja>
      </v1:header>
   </soapenv:Header>
   <soapenv:Body>
      <v1:inImprimirFatura>
         <tipo-fatura>?</tipo-fatura>
         <numero-cpf>?</numero-cpf>
      </v1:inImprimirFatura>
   </soapenv:Body>
</soapenv:Envelope>

Service that makes the post call:

function GerarSegundaViaFaturaTotvsPDF()
{
	var metodo = 'imprimirFatura';
	var url = '
	var param = {};      	 
	param.tipoFatura = "ATUAL";
	param.CPF =
	return $soap.post(url, metodo, {req: param});	      	 
}

How do I step the header parameters in a simple way without changing the structure of my code?

    
asked by anonymous 06.02.2017 / 19:40

1 answer

0

Usually this type of error is related to the CORS (Cross-Origin Resource Sharing).

In this post link you can check out better and have two more references explaining the concept. One of them clucked up. Below is the quote from the post that I believe has something to do with your problem:

  

If I understand you're doing an XMLHttpRequest to a different domain than your page is on. So the browser is blocking it as it usually allows to request in the same origin for security reasons. You need to do something different when you want to cross-domain request. A tutorial on how to achieve that is Using CORS.

    
06.02.2017 / 20:01