Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

Moodle and C# - Web Service Configuration

General Tech Learning Aids/Tools

Max. 2000 characters
Replies

usr_profile.png

User

( 5 months ago )

 

I'm currently stuck with quite a significant issue that i'm hoping someone may be able to shed some light on, regarding configuring an XML-RPC based web service to talk between my game based learning virtual world and a dedicated Moodle site

To the best of my knowledge, from following some sparse information on how to configure a Moodle web service, i've done the following steps:

  • Enabled Web Services
  • Enabled the XML-RPC protocol
  • Edited my admin role to allow use of the protocol and creation of a token for logging in
  • Creation of a service for authenticated users which my admin has been added to

The moodle documentation sends you in a bit of a loop but from what I can see i've the check list covered

I'm now trying to plug this into the backend of my virtual world to populate my dynamic terrain engine with sets of topics,assignments etc based on what the user would have access to etc

My issue comes from the simple HttpWebRequest for retrieving the token for the user I'm using the following method to return a string containing the token

    public string GetToken(string uname,string pword)
    {
        byte[] buffer = Encoding.ASCII.GetBytes("username="+uname+"&password="+pword+"&service=reflex");

        HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(url + "login/token.php?username=" + uname + "&password=" + pword + "&service=myservice");
        WebReq.Method = WebRequestMethods.Http.Post;
        WebReq.ContentType = "application/x-www-form-urlencoded";

        WebReq.ContentLength = buffer.Length;
        using(Stream PostData = WebReq.GetRequestStream())
            PostData.Write(buffer, 0, buffer.Length);

        HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
        using(StreamReader reader = new StreamReader(WebResp.GetResponseStream()))
            return token = reader.ReadToEnd();
    }

When I debug this to validate the token is generated, it throws an error saying the web service is down, but to the best of my knowledge the web service isnt called here, this uses a built in primitive php file to return a string and no more. I have checked the PostData.Write and its throwing a .Length NotSupportedException which i'm unsure as to if its having an impact upon the second using statement

I'm hoping if someone can aid regarding configuration settings that the next steps should fall into place easily as the XML-RPC dll seems quite robust and easy to use

Any help would be greatly appreciated

Many thanks Barry

usr_profile.png

User

( 5 months ago )

Now resolved

Worked around to retrieve the token manually through a sql call and have the web service functioning now

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif