Access-Control-Allow-Origin: * Access-Control-Allow-Methods: POST, GET, OPTIONS Access-Control-Allow-Headers: Content-type, Soapaction
Access-Control-Allow-Origin: *
| 1) | Download the jquery.soap zip and expand it to a new folder |
| 2) | Log in with MetaEdit+ to the demo repository, opening project Digital Watch |
| 3) | Open the API Tool (main launcher, Repository | API Tool) and press Start Server |
| 4) | Press Save WSDL, and save MetaEdit.wsdl in the jquery.soap folder’s web subfolder |
| 5) | Open index.html from the jquery.soap web subfolder |
| 6) | Change the following values in the fields on the index.html page |
|
Field
|
Value
|
|
url
|
http://localhost:6390/MetaEditAPI
|
|
method
|
open
|
|
appendMethodToURL
|
false
|
|
HTTPHeaders
|
{}
|
|
envAttributes
|
{ 'xmlns:ns':
'http://metacase.com/wsdl/' }
|
|
SOAPHeader
|
JSON
|
|
Contents:
|
|
|
data
|
JSON
|
|
Contents:
|
{
receiver:
{
areaID: 9,
objectID:
389
} }
|
|
namespace
|
ns http://metacase.com/wsdl/
|
| 7) | Press the Start jQuery.soap Test!! button at the bottom of the page |
01 $.soap({
02 url: "http://localhost:6390/MetaEditAPI",
03 method: "open",
04 appendMethodToURL: false,
05 timeout: 5000,
06 HTTPHeaders: {},
07 envAttributes: { 'xmlns:ns': 'http://metacase.com/wsdl/' },
08 data: {
09 receiver: {
10 areaID: 9,
11 objectID: 389
12 }
13 },
14 namespaceQualifier: "ns",
15 namespaceURL: "http://metacase.com/wsdl/",
16 enableLogging: true
17 });01 $.soap({
02 url: "http://localhost:6390/MetaEditAPI",
03 appendMethodToURL: false,
04 timeout: 5000,
05 HTTPHeaders: {},
06 envAttributes: { 'xmlns:ns': 'http://metacase.com/wsdl/' },
07 namespaceQualifier: "ns",
08 namespaceURL: "http://metacase.com/wsdl/",
09 enableLogging: true
10 });01 $.soap({
02 method: "open",
03 data: {
04 receiver: {
05 areaID: 9,
06 objectID: 389
07 }
08 }
09 });01 class MEOop {
02 constructor(areaID, objectID) {
03 this.areaID = areaID;
04 this.objectID = objectID;
05 }
06 }
07 class MetaEditAPI {
08 open(graphOop) {
09 let soap = require('soap');
10 let url = __dirname + '/MetaEdit.wsdl';
11 soap.createClient(url, {}, function(err, client) {
12 client.open( { receiver: graphOop }, function(err, apiFnReturn) {
13 // sync call returns a JavaScript object with property 'result'
14 console.log(JSON.stringify(apiFnReturn.result));
15 });
16 });
17 }
18 }
19
20 let me = new MetaEditAPI();
21 me.open(new MEOop(9, 389));var answer = apiFnReturn.result;
if (typeof(answer) === "undefined") {
console.log("Length == 0 in XML, expected JS Array, got nothing");
answer = []; // return an empty Array
} else if (!Array.isArray(answer)) {
console.log("Length == 1 in XML, expected JS Array, got single object");
answer = [answer]; // enclose in Array
} else {
console.log("Length >= 2 in XML, expected JS Array, got Array")
answer = answer; // return as is
}01 class MEOop {
02 constructor(areaID, objectID) {
03 this.areaID = areaID;
04 this.objectID = objectID;
05 }
06 }
07 class MetaEditAPI {
08 async open(graphOop) {
09 let soap = require('soap');
10 let url = __dirname + '/MetaEdit.wsdl';
11 let client = await soap.createClientAsync(url);
12
13 await this.openAsync(client, graphOop);
14 }
15
16 async openAsync(client, graphOop) {
17 let openArgs = { receiver: graphOop };
18 let openReturn = await client.openAsync(openArgs);
19 let answer = openReturn[0].result;
20 // async call returns array, first element has result property
21
22 console.log(JSON.stringify(answer));
23
24 return answer; // return as is
25 }
26 }
27
28 let me = new MetaEditAPI();
29 me.open(new MEOop(9, 389));