javascriptweb-servicesproxy-classeswsdl.exe

How to consume JavaScript classes generated by WSDL utility?


I generated classes in JavaScript from a WSDL by using Visual Studio's WSDL utility.

wsdl /o:SomeClasses.js /l:js https://SomeCompany.com/SomeService?WSDL

The output contains classes (in JavaScript) that look like this:

public System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1") System.SerializableAttribute() System.Diagnostics.DebuggerStepThroughAttribute() System.ComponentModel.DesignerCategoryAttribute("code") System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:some.company") 
class SomeUser {
    private var domainNameField : System.String;
    private var userNameField : System.String;

    ///<remarks/>
    public final function get domainName() : System.String {
        return this.domainNameField;
    }
    public final function set domainName(value : System.String) {
        this.domainNameField = value;
    }

    ///<remarks/>
    public final function get userName() : System.String {
        return this.userNameField;
    }
    public final function set userName(value : System.String) {
        this.userNameField = value;
    }
}

Is it possible to write OOP JavaScript utilizing these classes? If so, what is the syntax, examples, etc.


Solution

  • When you specify the JS language for the Web Services Description Language Tool, you are NOT specifying JavaScript, but JScript. It's not even JScript that InternetExplorer can fully understand, it's JScript.NET.

    JScript.NET is a server side scripting language based on JScript but with added features - available only on the server side - like the class you've got in the code you posted.

    You should look for other ways of generating JavaScript code, maybe with a tool like Wsdl2js or performing your WS call with JQuery. You can't use the Wsdl.exe generated code inside InternetExplorer as InternetExplorer only supports the old JScript language (and non IE browsers don't even support that).