• Question

  • Hi, i have on the following code error on: 

    1) ----> System.Xml.XmlDocument()

    Error: not Defined

    2) ---> Dim response1 As System.Net.HttpWebResponse = request.GetResponse()

    Error: GetResponse is not a member of system.net.httwebrequest

    This code work fine on Server Side, but i need to execute on Client Side, on a button execute....

    Option Explicit On'Option Strict On

    Imports System.Web.HttpUtility Imports System.Xaml Imports System.Net Imports System.IO Imports System.Xml.Linq Imports System.Xml Imports Microsoft.LightSwitch.Threading Imports <xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1"> Imports System.Windows Imports System Imports System.Text Namespace LightSwitchApplication     PublicClassRequestWebPagePrivateSub test_Execute()             ' Escriba el código aquí.

    Dim url4 = String.Format("http://Anyurl with a return XML file")             'MsgBox(url4.ToString)

    Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url4)             request.Credentials = New System.Net.NetworkCredential("user""pwd")             Dim response1 As System.Net.HttpWebResponse = request.GetResponse()             Dim stream As System.IO.Stream = response1.GetResponseStream()             '    '    ' Create a reader for the stream objectDim reader AsNew System.IO.StreamReader(stream)             '    '    ' Read from the stream object using the reader, put the contents in a stringDim contents AsString = reader.ReadToEnd()             '    '    ' Create a new, empty XML documentDim document AsNew System.Xml.XmlDocument()

    Dim _xmlDoc AsNew System.Xml.Linq.XmlDocument()             _xmlDoc.LoadXml(contents)             Dim elemStatusCode = _xmlDoc.GetElementsByTagName("STATUS_CODE").Item(0)             Dim elemStatusDesc = _xmlDoc.GetElementsByTagName("STATUS_DESC").Item(0)             Dim elemnrecip = _xmlDoc.GetElementsByTagName("NUM_RECIPIENTS").Item(0)             Dim elemnreinvrec = _xmlDoc.GetElementsByTagName("NUM_INVALID_RECIPIENTS").Item(0)             Dim elemcredit = _xmlDoc.GetElementsByTagName("CREDIT").Item(0)             Dim elemident = _xmlDoc.GetElementsByTagName("SMS_ID").Item(0)             Dim statusCode AsString = elemStatusCode.InnerText             Dim statusDesc AsString = elemStatusDesc.InnerText             Dim statusrecip AsString = elemnrecip.InnerText             Dim statusinvrec AsString = elemnreinvrec.InnerText             Dim statuscredit AsString = elemcredit.InnerText             Dim statusident AsString = elemident.InnerText             entity.RESPUESTA = statusCode & "-" & statusDesc             entity.SMS_ID = statusident             entity.CREDIT = statuscredit             entity.NUM_RECIPIENTS = statusrecip             entity.NUM_INVALID_RECIPIENTS = statusinvrec         EndSub




    Wednesday, March 19, 2014 7:54 AM

All replies

  • anyone can help me?

    Friday, March 21, 2014 7:52 AM
  • 1) XmlDocument is not part of the Silverlight framework, thus you cannot write code in the client (which is Silverlight) that uses this class.

    2) HttpWebRequest does not have a member called GetResponse in the Silverlight framework, thus you cannot write code in the client that uses this method.

    If you really need these and cannot find alternatives, then you need to execute this code on the server and either use a command pattern or use something like WebAPI to communicate the need to execute the code from the client to the server.

    Justin Anderson, LightSwitch Development Team

    Friday, March 21, 2014 4:45 PM
  • Hi Justin, thanks for your response.

    I mind that this one is very needed to add to SL / LS support, no?

    It's a Standard Protocol to get information from other sources.... If i Execute these code on Server side, i cannot handle result in time of execution... on see a result on a field... no?

    I need to catch result and then make an action....

    There are some method to make this possible?

    Saturday, March 22, 2014 12:25 AM