Declaration error (this)

Hello everyone,

I’m close to close to complete my first page by using Ionic.
I would need to consume a local web service by sending and receiving a soap envelope.
I built the soap envelope to send and I have some troubles with some declarations, this is the part of the code in which I have some troubles :

let query = {
	method: 'POST',
	url: "http://win-9u040a2kpbv:83/adelerh/server/soap.l1000?wsdl=Sage1000Authentication",
	data: soapRequest(),
	datatype: "text/xml; charset=utf-8",
	headers: {"Content-Type": "application/xml"}
   .success(function (query) {
	   //$Scope.PostDataResponse = query["data"];
   .error(function (query) {
	   //$scope.ResponseDetails = "Data: " + query["data"]+
	//	   "<hr />status: " + query["status"];

My errors are related to the $http and the $Scope objects, they both aren’t declared.
About the $http object, I declared it thanks to the constructor and this way:

constructor(public navCtrl: NavController, public $http: Http)

But it says that “this” is undefined.
The full code of my page can be found on here.


You are putting your function Autentication_get_sessionId() outside the class export class HomePage, so keyword this not prefer to HomePage
Your HomePage class end at line 59
Put your Autentication_get_sessionId() inside that class, so you can use the this.$http…

Or you can pass the http method (known as this.$http) to your Autentication_get_sessionId() like below.

At line 44: Autentication_get_sessionId(this.$http);
//(send this.http from Hompage to function outside that class)
At line 81: function Autentication_get_sessionId(thatHttp) {
At line 111:
//(get this.http as thatHttp and use it as this.http in function outside that class)

I moved the function into the class, that works.
By reading this message, I had to change the structure of the, I replaced success by subscribe and I deleted error, I put this into my code :

let m_url=url_autentication2;
let m_data=soapRequest();
let response_soap='';,m_data)
	   .subscribe(m_data=>{response_soap = readBody(m_data);});

There is no execution error but nothing is returned, I will see that with a workmate as I think the prob comes from the web service itself

My design rule is that pages do not interact directly with Http. Only service providers do that. Pages get Observables of business objects from the provider. That way it becomes much easier to mock out providers for testing and potentially change how the data is retrieved at some point in the future (such as caching, &c).

last week, we were in contact with the Sage editor who explained in detail how to consume our services via Postman and there were 2 mistakes :

  1. the web service was too heavy to be consumed on a mobile device, the fumber of functions shouldn’t exceed 15 (our web service has about 50 functions actually)
  2. 2 header parameters have to be sent : Accept and Content-Type
    I took a screenshot of the good execution via Postman.
    I will see the rest as I now have the correct info