Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am newbie in Angular 6 and TypeScript. Can someone show me the right way to use node.js third-party module in Angular 6?

For example i want to create component with ability to consume and make requests to SOAP wsdl methods.

Did installed it by adding to package.json with npm install.

Trying to use node-soap npm module like this:

import { Injectable } from '@angular/core';
import * as soap from 'node-soap';

@Injectable({
  providedIn: 'root'
})
export class MySoapService {
  constructor() { }

  getOrderInfo() {
    const url = 'http://my-example-api.com/WCF/ClientService.svc?singleWsdl';
    let args = {
      login: 'login',
      password: 'password',
      orderNumber: 'F976638'
    };
    soap.createClient(url, function(err, client) {
      client.GetOrderInfo(args, function(err, result) {
        console.log(result);
      });
    });
  };
}

Then inject this service into component and render it, just to test the service...

But got some error during ng serve:

ERROR in ./node_modules/node-soap/client.js
Module not found: Error: Can't resolve 'http' in '/home/cadistortion/WebstormProjects/my-ng-app/node_modules/node-soap'

Thank you!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
194 views
Welcome To Ask or Share your Answers For Others

1 Answer

it's easy, in your url have your API node. You go need more, express.js(or other) for get work. BD - like MongoDB or other or Json.

See this vídeo and other the same user https://www.youtube.com/watch?v=M-G48Gf2Xl0 is complete how create blog using MEAN Stack


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...