0

I have no previous knowledge of connecting to a web service using JSON and I haven't been able to find any examples online that clearly explain how I would go about connecting using authentication.

I have the following documentation:

Credential (type: Credential) - An object used to authenticate the client
MMCode (type: String)
RegYear (type: Int32)

The Credential object is made up of:

Username (type: String/nvarchar – length between 5 and 50 characters)
Password (type: String/nvarchar – length between 5 and 50 characters)
ClientIdentifier (type: String)

How do I go about doing this?

3
Contributors
6
Replies
19
Views
5 Years
Discussion Span
Last Post by Szabi Zsoldos
0

Your JSON object should probably look something like this:

var postData = {
  "Credential": {
    "Username" : "user",
    "Password" : "pass",
    "ClientIdentifier" : "ident"
  },
  "MMCode" : "code",
  "RegYear" : 2012
};
0

Hi pritaeas

I have the variable setup like that at the moment but I'm not having any luck getting a proper response.

Here's my code as it stands

<script type="text/javascript">
var usernameString = 'username';
var passwordString = 'pass';


    var postdata = { 
        "Credentials": {
            "Username": usernameString,
            "Password": passwordString,
            "ClientIdentifier": "string"
        },
        "MMCode" : "code",
        "RegYear" : 2012
    }


    //alert(postdata);
    var jsonstr = JSON.stringify(postdata);
    alert(jsonstr);

    var xmlhttp = new XMLHttpRequest;
    xmlhttp.onreadystatechange = function()
    {
        if(xmlhttp.readyState ==4)
        {

            alert(xmlhttp.responseText);

        }

    }
    serverURL = "serverUrl?wsdl";
    //alert(serverURL);
    xmlhttp.open("GET",serverURL,true);
    xmlhttp.send(null);
</script>

The responseText just comes back blank.

Edited by Venom Rush

0

Usually you don't post to the ?wsdl URL. That is just for retrieving the possible functions. Are you sure you need to send by GET?

If you use SoapUI, do you get a response? Personally, that would be the first thing I'd try before starting to code.

0

I've never heard of SoapUI until now. I'll download it and feed back once I know more.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.