Error on dynamically changing the WS URL

Error on dynamically changing the WS URL

by Catalin Maican -
Number of replies: 1

Hello,

We have built one Moodle site for each of our faculties. Also, we have deployed a .NET Portal (DotNetNuke) where every teacher and student may login and see various resources.

One of this resources are the courses from Moodle (one for each faculty). Since a teacher may teach to several faculties we tried via WS/login to get his/her courses from Moodle via Web Services.

For achieving this we should change the Web Service URL dinamically, at runtime to the URL of the faculty one teaches.

The proxy for the WS is generated for one Moodle platform and, since all the platforms are exactly the same, changing the Web Service URL dynamically should work.... but it does not! meaning that I can change the proxy URL but invoking a method that is on a different platform that the original (the one the proxy was generated from) fails. The Web services URL behavior in Visual Studio 2008 is set to "dynamic".

All the platforms have the exact same web services version and they are on the same version of Moodle.

Help ?

System.InvalidOperationException: There is an error in XML document (2, 559). ---> System.InvalidCastException: Cannot assign object of type System.Xml.XmlNode[] to an object of type AGSISPortal.MoodleWS.fr.loginReturn. at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMoodleWS.Read46_loginResponse() at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer26.Deserialize(XmlSerializationReader reader) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) --- End of inner exception stack trace --- at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle) at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at AGSISPortal.MoodleWS.fr.MoodleWS.login(String username, String password) in e:\dnn_48\desktopmodules\agsisportal\agsisportal\web references\moodlews.fr\reference.cs:line 297 at AGSIS.E_Learning.Moodle_MyCourses_Profesor.gvFacultati_RowDataBound(Object sender, GridViewRowEventArgs e) in E:\dnn_48\DesktopModules\AGSISPortal\AGSISPortal\Moodle_MyCourses_Profesor.ascx.cs:line 107

Average of ratings: -
In reply to Catalin Maican

Re: Error on dynamically changing the WS URL

by Catalin Maican -
Hi,

I've found a solution - changing the targetNamespace to targetNamespace="http://tempuri.org/wspp/wsdl" and replacing all the ". $CFG->wwwroot ." from the wsdl_pp.php to http://tempuri.org. I have left the same only the location, at the bottom of the file (location="' . $CFG->wwwroot . '/wspp/service_pp.php") so that this URL might be changed dinamically at runtime, as in the attached file

Catalin