help on changind web service URL at runtime?

Last post 05-20-2008 12:30 PM by RogerRabbit. 15 replies.

Sort Posts:

  • help on changind web service URL at runtime?

    04-13-2008, 4:18 PM
    • Loading...
    • icm76
    • Joined on 10-29-2005, 9:37 AM
    • Posts 2

    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 URL Behavior for the Web service 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

  • Re: help on changind web service URL at runtime?

    04-24-2008, 1:14 AM

    Hai icm76, im working on exactly the same scenario, did you get any help to share with me ?

    Thanks...

  • Re: help on changind web service URL at runtime?

    05-13-2008, 5:13 AM
    • Loading...
    • talg
    • Joined on 08-22-2007, 11:49 AM
    • israel,tel aviv
    • Posts 37

    Hi Friends,

    It seem I have the Same problem,

    I have the  Same WS on difrent servers(it is a reportins services ws) ,and i need to change the web service   url on run time (e.g. proxy.url="http://localhost.../service.asmx)

    My assumption is that changing the url change or reset the scurity configuration?

    I look on the iis and report server logs file but didnt figure out what is the problems

    Any idea or diagnosis?

    Much thanks

    Tal gaviser,

     

    for

    My assumption (After checking the loging of the IIS) is that there are security

    changes ,I would be glad to here some expert opinion

    Tal Gaviser
    DB & GUI Developer
    Israel,tel aviv
  • Re: help on changind web service URL at runtime?

    05-14-2008, 2:41 AM
    • Loading...
    • talg
    • Joined on 08-22-2007, 11:49 AM
    • israel,tel aviv
    • Posts 37

    Hi,

     

    I belive that i figure it out , (maybe It is my  own problem only),

    as i thought the credential of my application was anonimus, but the

    intention was to set them as windows auth,I solved it after one week by adding 2 lines on

    the web config file:

     

    <system.web>

    <authentication mode="Windows"/>

    <identity impersonate="true"/>

     

    My conclution is checking the IIS log file (and if the 401 is answered - find the user name as

    it is get from the application)

     

    Tal Gaviser
    DB & GUI Developer
    Israel,tel aviv
  • Re: help on changind web service URL at runtime?

    05-15-2008, 12:18 AM

    Hi,

    Could you elaborate what you have mentioned above. In my case, i am using Form Authentication with asp.net. I cant switch over to Windows mode. Any ideas about that...

    Thanks...

  • Re: help on changing web service URL at runtime?

    05-15-2008, 9:53 AM
    • Loading...
    • TsofnasPaneach
    • Joined on 04-16-2007, 12:41 PM
    • New York
    • Posts 9
    So the question still remains: How do you change the url of the webservice you are requesting, dynamically, at runtime? In my case, we have servers internally for development that talk to one web server, but when deployed in production it obviously needs to point to a different server.
    Filed under:
  • Re: help on changing web service URL at runtime?

    05-15-2008, 12:39 PM

    In your project in Visual Studio you can right click on the web service reference and choose to make the URL "dynamic".  This will store the URL in the config file.  If you change the config file, it will change the destination for the web service.

     

    Alternativey, you can set the URL property of the web serivce object at runtime to whatever you want.

  • Re: help on changing web service URL at runtime?

    05-15-2008, 4:55 PM
    • Loading...
    • TsofnasPaneach
    • Joined on 04-16-2007, 12:41 PM
    • New York
    • Posts 9
    How would I change the value of the URL property programmatically?
  • Re: help on changing web service URL at runtime?

    05-16-2008, 9:57 AM
    • Loading...
    • talg
    • Joined on 08-22-2007, 11:49 AM
    • israel,tel aviv
    • Posts 37

    hi,

     

    1.  kashifdotnet ,Did you check the iis and reporting services permission?

        do you get error 401- access denied (find it on iis log file under window/system32/logs? ,if so it is only   amatter of system configuration.

    Did you ennable the reporing sevices(on the reporing services admin control page) to access of aspnet user?

    2. TsofnasPaneach -The ws (reporting services) which is created support a url property which can be changed on runtime(e.g. proxy.url=new uri ("localhost/ReportService.asmx"))

     

    Tal gaviser

    Tal Gaviser
    DB & GUI Developer
    Israel,tel aviv
  • Re: help on changing web service URL at runtime?

    05-16-2008, 12:42 PM

    SampleWebService service = new SampleWebService();

    service.URL="http://...";

     

  • Re: help on changing web service URL at runtime?

    05-16-2008, 12:49 PM
    • Loading...
    • TsofnasPaneach
    • Joined on 04-16-2007, 12:41 PM
    • New York
    • Posts 9

    That's what worked for me, Thanks!

  • Re: help on changing web service URL at runtime?

    05-18-2008, 5:41 AM

    Hi Tal,

    I never "Access Denied" problem. In my case, after i change the URL property to point to a different machine, it usually comes back with the message "Cannot convert type .... to localhost....". In general, the types (e.g. UserRecord, CourseRecord) pointed by localhost dont seem to match with the type returned from the other server. I can put it this way:

    localhost.UserRecord != devserver.UserRecord (!= not equal to)

    where localhost, devserver just represent the name I use for the reference added. But this shouldnt make any difference. Afterall the types on all machines are the same...

    Any help guys ???

    Thanks...

  • Re: help on changing web service URL at runtime?

    05-18-2008, 5:43 AM

    The exact error message I get is in the top post...

  • Re: help on changing web service URL at runtime?

    05-19-2008, 8:04 PM

    It looks like the two machines don't actually implement the same web service interface.  If the two interfaces are not identical (or at least compatible) then you can assign the URL a different server, but you will still get an error such as the the one you described.  What are the differences in the WSDL documents for the two computers?

     

  • Re: help on changing web service URL at runtime?

    05-20-2008, 1:40 AM

    Both machines have exactly the same WSDL documents. The only difference was the namespace being used by the WSDL docs. My machine has http://localhost.... and the other had http://devmcahine/... otherwise everything else is exactly the same. I even modified the WSDL Doc to have the same namespace such as http://tempuri.org/.... but it didnt work either. I just keep recieving the message mentioned at the top :) Shew Smile no luck yet...

Page 1 of 2 (16 items) 1 2 Next >