or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

client.mdhttp-transport.mdindex.mdsecurity.mdserver.mdwsdl.md

wsdl.mddocs/

0

# WSDL Processing

1

2

WSDL (Web Services Description Language) parsing, validation, and XML object conversion capabilities for processing web service definitions. The WSDL class provides comprehensive functionality for working with SOAP service definitions.

3

4

## Capabilities

5

6

### WSDL Class

7

8

Core WSDL processing class for parsing service definitions and handling XML transformations.

9

10

```typescript { .api }

11

/**

12

* WSDL class for parsing and processing web service definitions

13

* Handles WSDL parsing, XML object conversion, and service description

14

*/

15

class WSDL {

16

/** Ignored namespaces array */

17

ignoredNamespaces: string[];

18

/** Whether to ignore base namespaces */

19

ignoreBaseNameSpaces: boolean;

20

/** Key used for XML values */

21

valueKey: string;

22

/** Key used for XML content */

23

xmlKey: string;

24

/** XML namespace for envelope */

25

xmlnsInEnvelope: string;

26

/** XML namespace for header */

27

xmlnsInHeader: string;

28

/** WSDL URI */

29

uri: string;

30

/** WSDL definitions element */

31

definitions: any;

32

/** WSDL processing options */

33

options: any;

34

35

/**

36

* Create new WSDL instance

37

* @param definition - WSDL definition content or service object

38

* @param uri - Base URI for the WSDL

39

* @param options - WSDL processing options

40

*/

41

constructor(definition: any, uri: string, options: IOptions);

42

}

43

```

44

45

### WSDL Methods

46

47

Core methods for WSDL processing and XML conversion.

48

49

```typescript { .api }

50

/**

51

* Set callback for when WSDL is ready

52

* @param callback - Callback function called when WSDL processing is complete

53

*/

54

onReady(callback: (err: Error) => void): void;

55

56

/**

57

* Process WSDL includes and imports

58

* @param callback - Callback function for completion

59

*/

60

processIncludes(callback: any): void;

61

62

/**

63

* Get description of all services in the WSDL

64

* @returns Object describing services, ports, and operations

65

*/

66

describeServices(): any;

67

68

/**

69

* Convert WSDL to XML string representation

70

* @returns XML string of the WSDL

71

*/

72

toXML(): string;

73

74

/**

75

* Convert XML to JavaScript object

76

* @param xml - XML content to convert

77

* @param callback - Optional callback for asynchronous processing

78

* @returns Parsed JavaScript object

79

*/

80

xmlToObject(xml: any, callback?: any): any;

81

82

/**

83

* Find schema object by namespace URI and qualified name

84

* @param nsURI - Namespace URI

85

* @param qname - Qualified name to find

86

* @returns Schema object definition

87

*/

88

findSchemaObject(nsURI: string, qname: string): any;

89

90

/**

91

* Create document-style XML from parameters

92

* @param name - Element name

93

* @param params - Parameters object

94

* @param nsPrefix - Namespace prefix

95

* @param nsURI - Namespace URI

96

* @param type - Type information

97

* @returns Generated XML string

98

*/

99

objectToDocumentXML(name: string, params: any, nsPrefix: string, nsURI?: string, type?: string): any;

100

101

/**

102

* Create RPC-style XML from parameters

103

* @param name - Operation name

104

* @param params - Parameters object

105

* @param nsPrefix - Namespace prefix

106

* @param nsURI - Namespace URI

107

* @param isParts - Whether to use parts format

108

* @returns Generated XML string

109

*/

110

objectToRpcXML(name: string, params: any, nsPrefix: string, nsURI: string, isParts?: boolean): string;

111

112

/**

113

* Convert JavaScript object to XML with namespace handling

114

* @param obj - Object to convert

115

* @param name - Element name

116

* @param nsPrefix - Namespace prefix

117

* @param nsURI - Namespace URI

118

* @param isFirst - Whether this is the first element

119

* @param xmlnsAttr - XML namespace attributes

120

* @param schemaObject - Schema object for validation

121

* @param nsContext - Namespace context

122

* @returns Generated XML

123

*/

124

objectToXML(obj: any, name: string, nsPrefix: any, nsURI: string, isFirst?: boolean, xmlnsAttr?: any, schemaObject?: any, nsContext?: any): any;

125

126

/**

127

* Check if namespace should be ignored

128

* @param ns - Namespace to check

129

* @returns True if namespace should be ignored

130

*/

131

isIgnoredNameSpace(ns: string): boolean;

132

133

/**

134

* Filter out ignored namespace from string

135

* @param ns - Namespace string

136

* @returns Filtered namespace string

137

*/

138

filterOutIgnoredNameSpace(ns: string): string;

139

140

/**

141

* Find schema type definition

142

* @param name - Type name

143

* @param nsURI - Namespace URI

144

* @returns Schema type definition

145

*/

146

findSchemaType(name: any, nsURI: any): any;

147

148

/**

149

* Find child schema object

150

* @param parameterTypeObj - Parameter type object

151

* @param childName - Child element name

152

* @param backtrace - Backtrace for debugging

153

* @returns Child schema object

154

*/

155

findChildSchemaObject(parameterTypeObj: any, childName: any, backtrace?: any): any;

156

```

157

158

**Usage Examples:**

159

160

```typescript

161

import { WSDL, open_wsdl } from "soap";

162

163

// Create WSDL from definition

164

const wsdl = new WSDL(wsdlDefinition, 'http://example.com/service', {

165

strict: true,

166

preserveWhitespace: false

167

});

168

169

// Wait for WSDL to be ready

170

wsdl.onReady((err) => {

171

if (err) throw err;

172

173

// Get service descriptions

174

const services = wsdl.describeServices();

175

console.log('Available services:', Object.keys(services));

176

177

// Convert to XML

178

const xmlString = wsdl.toXML();

179

console.log('WSDL XML:', xmlString);

180

});

181

182

// Convert object to document XML

183

const docXml = wsdl.objectToDocumentXML(

184

'GetUserRequest',

185

{ userId: 123 },

186

'tns',

187

'http://example.com/types'

188

);

189

190

// Convert object to RPC XML

191

const rpcXml = wsdl.objectToRpcXML(

192

'GetUser',

193

{ userId: 123 },

194

'tns',

195

'http://example.com/service'

196

);

197

```

198

199

### WSDL Factory Functions

200

201

Functions for opening and processing WSDL from various sources.

202

203

```typescript { .api }

204

/**

205

* Open and parse WSDL from URL or file path

206

* @param uri - WSDL URL or file path

207

* @param callback - Callback receiving (error, wsdl)

208

*/

209

function open_wsdl(uri: any, callback: (error: any, result?: WSDL) => any): any;

210

211

/**

212

* Open and parse WSDL from URL or file path with options

213

* @param uri - WSDL URL or file path

214

* @param options - WSDL processing options

215

* @param callback - Callback receiving (error, wsdl)

216

*/

217

function open_wsdl(uri: any, options: IOptions, callback: (error: any, result?: WSDL) => any): any;

218

```

219

220

**Usage Examples:**

221

222

```typescript

223

import { open_wsdl } from "soap";

224

225

// Open WSDL from URL

226

open_wsdl('http://example.com/service.wsdl', (err, wsdl) => {

227

if (err) throw err;

228

229

console.log('WSDL loaded successfully');

230

const services = wsdl.describeServices();

231

console.log('Services:', services);

232

});

233

234

// Open WSDL with options

235

open_wsdl('http://example.com/service.wsdl', {

236

strict: true,

237

ignoreBaseNameSpaces: false,

238

wsdl_headers: { 'User-Agent': 'SOAP Client' }

239

}, (err, wsdl) => {

240

if (err) throw err;

241

242

// Process WSDL includes

243

wsdl.processIncludes((includeErr) => {

244

if (includeErr) throw includeErr;

245

console.log('WSDL includes processed');

246

});

247

});

248

249

// Open from local file

250

open_wsdl('./local-service.wsdl', (err, wsdl) => {

251

if (err) throw err;

252

253

// Convert object to XML using WSDL schema

254

const xml = wsdl.objectToDocumentXML(

255

'CalculateRequest',

256

{ a: 10, b: 20 },

257

'calc',

258

'http://calculator.example.com/'

259

);

260

261

console.log('Generated XML:', xml);

262

});

263

```

264

265

## Advanced WSDL Features

266

267

### Namespace Handling

268

269

WSDL class provides sophisticated namespace handling capabilities.

270

271

```typescript

272

// Check if namespace should be ignored

273

const shouldIgnore = wsdl.isIgnoredNameSpace('http://schemas.xmlsoap.org/soap/envelope/');

274

275

// Filter namespace prefixes

276

const filtered = wsdl.filterOutIgnoredNameSpace('soap:Body');

277

278

// Find schema objects with namespace resolution

279

const userType = wsdl.findSchemaObject('http://example.com/types', 'User');

280

```

281

282

### Schema Processing

283

284

Work with XSD schema definitions embedded in WSDL.

285

286

```typescript

287

// Find specific schema type

288

const stringType = wsdl.findSchemaType('string', 'http://www.w3.org/2001/XMLSchema');

289

290

// Find child elements in complex types

291

const childElement = wsdl.findChildSchemaObject(userType, 'name');

292

```

293

294

### XML Generation Options

295

296

Control XML generation behavior through WSDL options.

297

298

```typescript

299

const wsdl = new WSDL(definition, uri, {

300

// Use empty tags for null values

301

useEmptyTag: true,

302

// Preserve whitespace in text content

303

preserveWhitespace: true,

304

// Handle namespace arrays properly

305

namespaceArrayElements: false,

306

// Custom attribute key

307

attributesKey: '$attributes',

308

// Custom value key

309

valueKey: '$value'

310

});

311

```

312

313

## Error Handling

314

315

Handle WSDL processing errors appropriately.

316

317

```typescript

318

wsdl.onReady((err) => {

319

if (err) {

320

console.error('WSDL processing failed:', err.message);

321

return;

322

}

323

324

try {

325

const xml = wsdl.objectToDocumentXML('InvalidElement', {}, 'ns', 'uri');

326

} catch (conversionError) {

327

console.error('XML conversion failed:', conversionError.message);

328

}

329

});

330

```