Skip to content

How To Call With This SOAP envelope #79

@sonnyariady

Description

@sonnyariady

I have a problem to call SOAP with these following envelope header and body, on the tutor, it doesn't include SoapEnvelope Header.
I will create this api call in the class .Service.TS
For example, these statements are called in the constructor

var requrl = environment.baseWSAddress + 'WS_serviceku.asmx?wsdl';
this.soap.createClient(requrl).then(client => {

  client.addSoapHeader({
    'api:UserCredential': {
     
      Username: environment.App_UserName,
      Password: environment.App_Password,
      App_Name: environment.App_Name
      
    }
  });

the XML SOAP envelope are like these:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="http://aplikasinganu.com/">
soapenv:Header
api:UserCredential

api:Usernameuseranu</api:Username>

api:PasswordPasswordnganu</api:Password>

api:App_Nameappnganu</api:App_Name>
</api:UserCredential>
</soapenv:Header>
soapenv:Body
api:Login

api:loginVM

api:Usernamesujono</api:Username>

api:PasswordPassword123</api:Password>
</api:loginVM>
</api:Login>
</soapenv:Body>
</soapenv:Envelope>

I create mthod call in service class like this. For Example, this is "Login" method on WS_serviceku.asmx

DoLogin3() : Observable
{

const body = {
  'api:Login': {
  Username: this.formData.Username,
  Password: this.formData.Password
  }
};

this.client.addHttpHeader('Content-Type', 'application/soap+xml; charset=utf-8');

console.log("Sebelum panggil method login");

console.log("Dapatkan httpheader: " + this.client.getHttpHeaders());
console.log("Dapatkan getSoapHeaders: " + this.client.getSoapHeaders());

return this.client.call('Login',body, this.httpOptions );

}

Then on component.ts I call this:

this.service.DoLogin3().subscribe(res => {
// console.log("Has passed api call");
// console.log("Is Success: " + res.IsSuccess);
});

The error occured on the picture, on environment.baseWSAddress I use debug address, It did't enter the breakpoint for debugging.
What's wrong and missing on my statement?

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions