简体   繁体   中英

How can we use .wsdl file from local drive to send soap request?

I am new to soap web services. I have local wsdl file. The company I want to connect to...com?wsdl url has closed for security reasons. I need to reach locally. When I use the soap ui tool and send a request, a successful result is returned. but when I send a request with the help of soap package with nodejs, the result is returned. The methods appear in the client.describe method. but I can't access the methods. Please help me enter image description here

Hello and welcome to StackOverflow.

WSDL (web serice desciption language) is an XML notation for describing a web service. A WSDL definition tells a client how to compose a web service request and describes the interface that is provided by the web service provider.

Typycally a WSDL definition is divided into separate sections that specify the logical interface and the physical details of a web service. The physical details include both endpoint information, such as HTTP port number, and binding information, which specifies how the SOAP payload is represented and which transport is used.

Because the company closed the endpoint for security reasons, I assume that you changed it successfully to a local URI in the .wsdl file.

With node.js, you should be able to query it with or without a specific node package, since soap services can be queried with HTTP POST, a few extra headers and an XML SOAP envelope. Otherwise here is an example that you can adapt with easy SOAP request:

const soapRequest = require('easy-soap-request');
const fs = require('fs');`enter code here`

// example data
const url = 'http://your-local-ip:80/test';
const sampleHeaders = {
  'user-agent': 'sampleTest',
  'Content-Type': 'text/xml;charset=UTF-8',
  'soapAction': 'http://your-local-ip:80/test/yourservice.wsdl#Test',
};
const xml = fs.readFileSync('./someEnvelope.xml', 'utf-8');

// usage of module
(async () => {
  const { response } = await soapRequest({ url: url, headers: sampleHeaders, xml: xml, timeout: 1000 }); // Optional timeout parameter(milliseconds)
  const { headers, body, statusCode } = response;
  console.log(headers);
  console.log(body);
  console.log(statusCode);
})();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM