Need Help Consuming 3rd Party Web Service

Category: visual studio lightswitch

Question

MrGlimm on Mon, 23 Feb 2015 05:06:46


I am very new to VS and using this Lightswitch project to expose myself to understanding Visual Basic, and I thought RESTful requests would be a good start.

I'm trying to access a GPS service, and have gotten VS2013 to create the Service Reference, and received an auto generated 'reference.vb' which I believe to be the proxy class? It seems to contains functions to call from the service.

<System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property LastUpdate() As Date
            Get
                Return Me.LastUpdateField
            End Get
            Set
                If (Me.LastUpdateField.Equals(value) <> true) Then
                    Me.LastUpdateField = value
                    Me.RaisePropertyChanged("LastUpdate")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property MotionState() As String
            Get
                Return Me.MotionStateField
            End Get
            Set
                If (Object.ReferenceEquals(Me.MotionStateField, value) <> true) Then
                    Me.MotionStateField = value
                    Me.RaisePropertyChanged("MotionState")
                End If
            End Set
        End Property

Unfortunately the vendor only provides examples of C# requests, and I'm really only using VB. I understand I have a lot to learn regarding the code, I'm just trying to see the whole picture.
Here is a sample C# REST request they have given.

I'm not sure code converters are really the way to go for this I have noticed. But every tutorial I read seems to do something different in the request , and in different versions of VS so I get confused. Given that I properly convert this to VB, where is the table element this actually returning the result information to? (Sorry very stupid questions)

// Create HTTP GET request using driver web service
string uri = @"https://ws.examplegps.com/DriverWebService.svc/drivers/?limit=2&offset=1";
var request = System.Net.HttpWebRequest.Create(uri);
request.Method = "GET";

// Create authorization header (replace these values with actual credentials)
string companyLoginId = "{LogonID}";
string userName = "{UserName}";
string password = "{Password}";
string auth = companyLoginId + "|" + userName + ":" + password;
string authHeader = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(auth));
request.Headers["Authorization"] = authHeader;

// Request response from web service
try
{
    var httpWebResponse = (System.Net.HttpWebResponse)request.GetResponse();

    // Get response as string
    string strResponse;
    var responseEncoding = System.Text.Encoding.GetEncoding(httpWebResponse.CharacterSet);
    using (System.IO.StreamReader reader = new System.IO.StreamReader(httpWebResponse.GetResponseStream(),responseEncoding))
    {
        strResponse = reader.ReadToEnd();
    }
    Console.WriteLine(strResponse);
}
catch (Exception e)
{
    Console.WriteLine(e.Message);
}

(I have added the custom binding to web.config)

I have referenced these links which all seem really different

Beth Massi Tutorial

This makes the most sense but it's SOAP?

Lightswitch - Consuming Web Services

Would be very grateful for some patient dialogue.








Replies

Thomas Steen on Fri, 27 Feb 2015 10:44:48


Hello,

I am a litle bit confused. What do you want to achive? Getting Data from an external Service and enter this data into a lightswitch entity or do you want to share the lightswitzch database so anyone can get data from LS?

Kind Regards

Thomas

MrGlimm on Fri, 06 Mar 2015 04:34:56


Sorry if I wasn't clear. I now have code now that connects to my third party service, and displays the XML results to console, but I am new to VB and not sure how to approach the (logic?) of returning the certain sections of the data to a particular entity field.

XML Example:

<VehicleStatus>

        <LastLoginTime>21:53</LastLoginTime>  (return this value to entity.property)(when called from a button)

Sorry for my newbie knowledge...




Thomas Steen on Sat, 07 Mar 2015 15:57:06


No worries. One last question you are using silverlight or Lightswitch HTML?

When you are using HTML you can create a ashx file (Generic handler) and in the automatically created Sub "ProcessRequest" you copy your second code and Change the line with Console.WriteLine(strResponse)to
context.response.contenttype = "text/plain"
context.response.Write(strResponse)

This code from Michael Washington explains it in Detail.

Hope this helps

Thomas


 

reigh7 on Sun, 08 Mar 2015 02:43:41


If this is a Silverlight APP using the NON HTML Project type for Visual Basic then you should get a table after you import another data source then you can set up a relationship between that table and the one you will use in Light switch to show the data on a screen. Note when you do it this way you can select which Properties on the Data Source Table map to which properties on the LS Data table.

If you find code in Visual Basic from other projects that works but is the wrong version as long as that version is not newer than your version it shoud work or be a good place to start.


this Link should work it is a desktop project you though was a good match. The main difference here is they tell you to go to the solution explorer and go to file view. Visual studio 2013 combines the file view and logical view into one but everything is still there. see the differences at this link.

MrGlimm on Tue, 10 Mar 2015 13:29:37


Thank you both for the informative replies. I am using the Silverlight app version in fact.

Reigh, I would love a table that represents this data (is how I am using this data source in Excel), but it doesn't seem to create any table when the Service Reference is added. I have seen a couple tutorials regarding RIA that suggests this is a solution for that, but they're not very up to date with VS2013. I tried adding the service through Odata Data Sources but I'm afraid it doesn't work, or I'm just short of some knowledge with that.


I have been looking at that Currency Rate example for a bit, and get stumped at the Class for the service. Where does it go? Client, Server? Is this what's used to call the functions in the auto generated code provided by the service? (eg webservice.drivetime)?

reigh7 on Thu, 12 Mar 2015 01:05:22


download free excel add on power pivot link an follow this example Creating and Consuming LightSwitch OData Services for consuming your app o data. then use =cell("Contents", cellname) to pass the cell data to formulas ousideof the pivot tables DAX formula abilities.

reigh7 on Thu, 12 Mar 2015 01:24:27


sorry I may have this backwards your going from excel  to lightswitch or going to lightswitch table from excel tables? if the first than  just use the office integration pack to import from excel if the second follow my last post.

reigh7 on Thu, 12 Mar 2015 01:28:09


Also you have to create your own table in Lightswitch when tying it to a service class then you can relate that table to your lightswitch table or combine tables ect. Michael explains it step by step here. Link


MrGlimm on Fri, 13 Mar 2015 04:17:12


sorry I may have this backwards your going from excel  to lightswitch or going to lightswitch table from excel tables? if the first than  just use the office integration pack to import from excel if the second follow my last post.

No the use of Excel is completely separate from this Lighswitch solution. In Excel my connection to this service updates the entire table each time. In my Lighswitch solution I'm wanting to make calls for specific table properties on a current screen without having to update an entire table each time a call is made. Hopefully I'm not looking at this wrong..

reigh7 on Fri, 13 Mar 2015 16:16:30


Its getting more clear what you want. One question is it always the same call to a table? if so you just want to query an existing service or create your own? RIA services connect each property to each property so you would only call the properties you set one to another this is different than a straight table to table relationship in Lightswitch because you actually specify the relationship multiple times one to each property you relate. This means you could speed up the flow of data if there are so many table properties that it is slowing down a screen I would guess. I'm kind of sure I read that some things like photos can slow down queries between lightswitch tables because the single relationship still passes all of the properties with one summary property from the other table.

All that said you should be able to map the relationship after you consume the service weather and O-Data service or an RIA service. If the service is a table you are creating just follow Michael's post from beginning to end. If you are consuming a service from another database that already exists and you have all of the data just start about half way down were it says Consume the WCF RIA Service. See picture below. Then after you consume it assuming it is "targeted" at the right framework like it shows in the first steps of creating your own service then you should get a table in the end that you can set up a relationship to. It will show as a dotted line relationship not a solid line and you will be able to map each property to each in some Auto complete boxes see my other pic. for me the fact that the RIA service had to be targeted at my framework through me off because I had an older project targeted at .new 4.0 not 4.5.1 and I couldn't get the early steps of consuming to show the RIA service in the step were the window says "choose a service".



Consume The WCF RIA Service

"choose a service"

.

This is from My example were I made my own RIA service to combine Internal and external products into one table then consumed the table "combined Products". you don't have to do that but this shows you relationships being set between two separate data sources in the same project after being consumed. Note that there are two different data base icons one over my lightswitch tables and one over my RIA service.




Relationship setup

MrGlimm on Sat, 14 Mar 2015 02:26:15


This is helping me understand a bit more thank you. To answer your question, I do not think so no. 

My service for example is a GPS service for drivers. For each driver it has things like, Last Login Time, or Last Logout Time, or Last Known Location. Now, I may have a screen that only needs Last Known location in the Data Grid from this service, as all this service data is in constant change. I will have another screen for more detailed views of the driver which will need more properties displayed. Since most API's have call restrictions per month, I wanted to make sure I could call these properties as needed via update button, only for the driver property in the data grid, not update the property for every driver each time.

So at this point, I have a working VB code that calls the service and Gets all the data at once and puts it to a console screen. I wasn't sure if I needed a separate RIA/Odata, or just programmatically make the calls in an entity I create (using the code auto-generated by the service), and a button tell the screen which property to update...

Honestly I get a little hung up on the Class creation in the tutorial, I know you can't teach me everything just want some good direction to concentrate :-) I appreciate your help

reigh7 on Sat, 14 Mar 2015 04:42:18


Weird my pictures are not showing up for me right now hope you can see them.

just keep marking anything helpful I put up is all I ask I haven't used a GPS service but I assume the class creation you are referring to is the one in Micheal's instructions? if your stuck on the conversion from C# to VB try asking the VB code forum for help I ask question on the C# forum all of the time.
VB to C# code Converter this will only take small statements at a time but works

FIRST

ADD the right using statements and assembly references you will get a squiggly line under one just ignor it it goes away if you follow the steps to import the ApplicationDataObjectContex.cs

Make sure to call the variable before the defined class
{

        [Key]
        public int ID { get; set; }
        public DateTime OrderDate { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public decimal OrderTotal { get; set; }

}
//THEN Put in this reusable statement convert to VB of course
----------------------------------------------------------

publicclass WCF_RIA_Service : DomainService
    {
// This Context property is code that connects to the LightSwitch database
// The code in the Database connection region can be reused as it is 
        #region Database connection
private ApplicationData m_context;
public ApplicationData Context
        {
get
            {
if (this.m_context == null)
                {
string connString =
                        System.Web.Configuration.WebConfigurationManager
                        .ConnectionStrings["_IntrinsicData"].ConnectionString;
                    EntityConnectionStringBuilder builder = new EntityConnectionStringBuilder();
                    builder.Metadata =
                        "res://*/ApplicationData.csdl|res://*/ApplicationData.ssdl|res://*/ApplicationData.msl";
                    builder.Provider =
                        "System.Data.SqlClient";
                    builder.ProviderConnectionString = connString;
this.m_context = new ApplicationData(builder.ConnectionString);
                }
returnthis.m_context;
            }
        }
        #endregion

//THEN modify the below part to match your service
----------------------------------------------------

        [Query(IsDefault = true)]
        public IQueryable<EnhancedFlowerShopOrder> GetAllOrders()
        {
            // Get all the Orders
            var colFlowerShopOrders = from Order in this.Context.FlowerShopOrders
                                      // Shape the results into the 
                                      // EnhancedFlowerShopOrder class
                                      select new EnhancedFlowerShopOrder
                                      {
                                          // The Order ID
                                          ID = Order.Id,
                                          // The Order Date
                                          OrderDate = Order.OrderDate,
                                          // The first name of the Customer
                                          FirstName = Order.FlowerShopCustomer.FirstName,
                                          // The last name of the Customer
                                          LastName = Order.FlowerShopCustomer.LastName,
                                          // The order Total
                                          OrderTotal =
                                          // Get all order details lines of the Order
                                          (from FlowerShopOrderDetail in Order.FlowerShopOrderDetail
                                           // Group the products in the Order Details
                                           group FlowerShopOrderDetail 
                                           by FlowerShopOrderDetail.Id into g
                                           // Shape a new entity
                                           select new
                                           {
                                               // Create a total property that is the Quantity times the
                                               // Product price
                                               TotalOrder = g.Sum(x => x.Quantity) 
                                               * g.Sum(x => x.FlowerShopProduct.Price),
                                           }).Sum(x => x.TotalOrder) // Add the sum of all the TotalOrders
                                      };

            return colFlowerShopOrders;
        }

        // Override the Count method in order for paging to work correctly
        protected override int Count<T>(IQueryable<T> query)
        {
            return query.Count();
        }

MrGlimm on Wed, 18 Mar 2015 19:28:49


Just to clarify for this thread I'm using VS2013 and the tutorial for 2013 is here

Ok, I can see how the entity is suppose to be created but I am having a problem understanding what the code is that's auto-generated at install of my service reference. Here is what was created when I originally added the service reference.(pre RIA setup attempt)

Here is the auto-created Reference.vb, which to me looks like the strings, or entity properties I need

'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:4.0.30319.34209
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Strict On
Option Explicit On

Imports System
Imports System.Runtime.Serialization

Namespace xrsVehicleStatus
    
    <System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0"),  _
     System.Runtime.Serialization.DataContractAttribute(Name:="VehicleStatus", [Namespace]:="http://schemas.datacontract.org/2004/07/Xata.Ignition.WebServiceAPI.Contracts.Dat"& _ 
        "aContract.StatusAndEvents"),  _
     System.SerializableAttribute()>  _
    Partial Public Class VehicleStatus
        Inherits Object
        Implements System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
        
        <System.NonSerializedAttribute()>  _
        Private extensionDataField As System.Runtime.Serialization.ExtensionDataObject
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private DirectionField As String
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private DriverIDField As String
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private DriverNameField As String
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private DriverOrganizationNameField As String
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private DriverOrganizationSIDField As Long
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private DriverSIDField As Long
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private HeadingField As Double
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private LastUpdateField As Date
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private MotionStateField As String
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private OdometerField As Double
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private SiteIDField As String
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private SiteLatitudeField As Double
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private SiteLocationField As String
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private SiteLongitudeField As Double
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private SiteOrNameField As String
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private SiteSIDField As Long
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private SpeedField As Double
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private VehicleLatitudeField As Double
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private VehicleLocationField As String
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private VehicleLongitudeField As Double
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private VehicleNameField As String
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private VehicleOrganizationNameField As String
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private VehicleOrganizationSIDField As Long
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private VehicleSIDField As Long
        
        <Global.System.ComponentModel.BrowsableAttribute(false)>  _
        Public Property ExtensionData() As System.Runtime.Serialization.ExtensionDataObject Implements System.Runtime.Serialization.IExtensibleDataObject.ExtensionData
            Get
                Return Me.extensionDataField
            End Get
            Set
                Me.extensionDataField = value
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property Direction() As String
            Get
                Return Me.DirectionField
            End Get
            Set
                If (Object.ReferenceEquals(Me.DirectionField, value) <> true) Then
                    Me.DirectionField = value
                    Me.RaisePropertyChanged("Direction")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property DriverID() As String
            Get
                Return Me.DriverIDField
            End Get
            Set
                If (Object.ReferenceEquals(Me.DriverIDField, value) <> true) Then
                    Me.DriverIDField = value
                    Me.RaisePropertyChanged("DriverID")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property DriverName() As String
            Get
                Return Me.DriverNameField
            End Get
            Set
                If (Object.ReferenceEquals(Me.DriverNameField, value) <> true) Then
                    Me.DriverNameField = value
                    Me.RaisePropertyChanged("DriverName")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property DriverOrganizationName() As String
            Get
                Return Me.DriverOrganizationNameField
            End Get
            Set
                If (Object.ReferenceEquals(Me.DriverOrganizationNameField, value) <> true) Then
                    Me.DriverOrganizationNameField = value
                    Me.RaisePropertyChanged("DriverOrganizationName")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property DriverOrganizationSID() As Long
            Get
                Return Me.DriverOrganizationSIDField
            End Get
            Set
                If (Me.DriverOrganizationSIDField.Equals(value) <> true) Then
                    Me.DriverOrganizationSIDField = value
                    Me.RaisePropertyChanged("DriverOrganizationSID")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property DriverSID() As Long
            Get
                Return Me.DriverSIDField
            End Get
            Set
                If (Me.DriverSIDField.Equals(value) <> true) Then
                    Me.DriverSIDField = value
                    Me.RaisePropertyChanged("DriverSID")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property Heading() As Double
            Get
                Return Me.HeadingField
            End Get
            Set
                If (Me.HeadingField.Equals(value) <> true) Then
                    Me.HeadingField = value
                    Me.RaisePropertyChanged("Heading")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property LastUpdate() As Date
            Get
                Return Me.LastUpdateField
            End Get
            Set
                If (Me.LastUpdateField.Equals(value) <> true) Then
                    Me.LastUpdateField = value
                    Me.RaisePropertyChanged("LastUpdate")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property MotionState() As String
            Get
                Return Me.MotionStateField
            End Get
            Set
                If (Object.ReferenceEquals(Me.MotionStateField, value) <> true) Then
                    Me.MotionStateField = value
                    Me.RaisePropertyChanged("MotionState")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property Odometer() As Double
            Get
                Return Me.OdometerField
            End Get
            Set
                If (Me.OdometerField.Equals(value) <> true) Then
                    Me.OdometerField = value
                    Me.RaisePropertyChanged("Odometer")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property SiteID() As String
            Get
                Return Me.SiteIDField
            End Get
            Set
                If (Object.ReferenceEquals(Me.SiteIDField, value) <> true) Then
                    Me.SiteIDField = value
                    Me.RaisePropertyChanged("SiteID")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property SiteLatitude() As Double
            Get
                Return Me.SiteLatitudeField
            End Get
            Set
                If (Me.SiteLatitudeField.Equals(value) <> true) Then
                    Me.SiteLatitudeField = value
                    Me.RaisePropertyChanged("SiteLatitude")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property SiteLocation() As String
            Get
                Return Me.SiteLocationField
            End Get
            Set
                If (Object.ReferenceEquals(Me.SiteLocationField, value) <> true) Then
                    Me.SiteLocationField = value
                    Me.RaisePropertyChanged("SiteLocation")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property SiteLongitude() As Double
            Get
                Return Me.SiteLongitudeField
            End Get
            Set
                If (Me.SiteLongitudeField.Equals(value) <> true) Then
                    Me.SiteLongitudeField = value
                    Me.RaisePropertyChanged("SiteLongitude")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property SiteOrName() As String
            Get
                Return Me.SiteOrNameField
            End Get
            Set
                If (Object.ReferenceEquals(Me.SiteOrNameField, value) <> true) Then
                    Me.SiteOrNameField = value
                    Me.RaisePropertyChanged("SiteOrName")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property SiteSID() As Long
            Get
                Return Me.SiteSIDField
            End Get
            Set
                If (Me.SiteSIDField.Equals(value) <> true) Then
                    Me.SiteSIDField = value
                    Me.RaisePropertyChanged("SiteSID")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property Speed() As Double
            Get
                Return Me.SpeedField
            End Get
            Set
                If (Me.SpeedField.Equals(value) <> true) Then
                    Me.SpeedField = value
                    Me.RaisePropertyChanged("Speed")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property VehicleLatitude() As Double
            Get
                Return Me.VehicleLatitudeField
            End Get
            Set
                If (Me.VehicleLatitudeField.Equals(value) <> true) Then
                    Me.VehicleLatitudeField = value
                    Me.RaisePropertyChanged("VehicleLatitude")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property VehicleLocation() As String
            Get
                Return Me.VehicleLocationField
            End Get
            Set
                If (Object.ReferenceEquals(Me.VehicleLocationField, value) <> true) Then
                    Me.VehicleLocationField = value
                    Me.RaisePropertyChanged("VehicleLocation")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property VehicleLongitude() As Double
            Get
                Return Me.VehicleLongitudeField
            End Get
            Set
                If (Me.VehicleLongitudeField.Equals(value) <> true) Then
                    Me.VehicleLongitudeField = value
                    Me.RaisePropertyChanged("VehicleLongitude")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property VehicleName() As String
            Get
                Return Me.VehicleNameField
            End Get
            Set
                If (Object.ReferenceEquals(Me.VehicleNameField, value) <> true) Then
                    Me.VehicleNameField = value
                    Me.RaisePropertyChanged("VehicleName")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property VehicleOrganizationName() As String
            Get
                Return Me.VehicleOrganizationNameField
            End Get
            Set
                If (Object.ReferenceEquals(Me.VehicleOrganizationNameField, value) <> true) Then
                    Me.VehicleOrganizationNameField = value
                    Me.RaisePropertyChanged("VehicleOrganizationName")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property VehicleOrganizationSID() As Long
            Get
                Return Me.VehicleOrganizationSIDField
            End Get
            Set
                If (Me.VehicleOrganizationSIDField.Equals(value) <> true) Then
                    Me.VehicleOrganizationSIDField = value
                    Me.RaisePropertyChanged("VehicleOrganizationSID")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property VehicleSID() As Long
            Get
                Return Me.VehicleSIDField
            End Get
            Set
                If (Me.VehicleSIDField.Equals(value) <> true) Then
                    Me.VehicleSIDField = value
                    Me.RaisePropertyChanged("VehicleSID")
                End If
            End Set
        End Property
        
        Public Event PropertyChanged As System.ComponentModel.PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
        
        Protected Sub RaisePropertyChanged(ByVal propertyName As String)
            Dim propertyChanged As System.ComponentModel.PropertyChangedEventHandler = Me.PropertyChangedEvent
            If (Not (propertyChanged) Is Nothing) Then
                propertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(propertyName))
            End If
        End Sub
    End Class
    
    <System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0"),  _
     System.Runtime.Serialization.DataContractAttribute(Name:="FaultData", [Namespace]:="http://schemas.datacontract.org/2004/07/Xata.Ignition.Common.Contract"),  _
     System.SerializableAttribute()>  _
    Partial Public Class FaultData
        Inherits Object
        Implements System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
        
        <System.NonSerializedAttribute()>  _
        Private extensionDataField As System.Runtime.Serialization.ExtensionDataObject
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private ErrorMessageField As String
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private EventCodeField As ULong
        
        <System.Runtime.Serialization.OptionalFieldAttribute()>  _
        Private ParametersField() As String
        
        <Global.System.ComponentModel.BrowsableAttribute(false)>  _
        Public Property ExtensionData() As System.Runtime.Serialization.ExtensionDataObject Implements System.Runtime.Serialization.IExtensibleDataObject.ExtensionData
            Get
                Return Me.extensionDataField
            End Get
            Set
                Me.extensionDataField = value
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property ErrorMessage() As String
            Get
                Return Me.ErrorMessageField
            End Get
            Set
                If (Object.ReferenceEquals(Me.ErrorMessageField, value) <> true) Then
                    Me.ErrorMessageField = value
                    Me.RaisePropertyChanged("ErrorMessage")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property EventCode() As ULong
            Get
                Return Me.EventCodeField
            End Get
            Set
                If (Me.EventCodeField.Equals(value) <> true) Then
                    Me.EventCodeField = value
                    Me.RaisePropertyChanged("EventCode")
                End If
            End Set
        End Property
        
        <System.Runtime.Serialization.DataMemberAttribute()>  _
        Public Property Parameters() As String()
            Get
                Return Me.ParametersField
            End Get
            Set
                If (Object.ReferenceEquals(Me.ParametersField, value) <> true) Then
                    Me.ParametersField = value
                    Me.RaisePropertyChanged("Parameters")
                End If
            End Set
        End Property
        
        Public Event PropertyChanged As System.ComponentModel.PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
        
        Protected Sub RaisePropertyChanged(ByVal propertyName As String)
            Dim propertyChanged As System.ComponentModel.PropertyChangedEventHandler = Me.PropertyChangedEvent
            If (Not (propertyChanged) Is Nothing) Then
                propertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(propertyName))
            End If
        End Sub
    End Class
    
    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0"),  _
     System.ServiceModel.ServiceContractAttribute(ConfigurationName:="xrsVehicleStatus.IVehicleStatusWebService")>  _
    Public Interface IVehicleStatusWebService
        
        <System.ServiceModel.OperationContractAttribute(Action:="http://tempuri.org/IVehicleStatusWebService/GetVehicleStatusById", ReplyAction:="http://tempuri.org/IVehicleStatusWebService/GetVehicleStatusByIdResponse"),  _
         System.ServiceModel.FaultContractAttribute(GetType(xrsVehicleStatus.FaultData), Action:="http://tempuri.org/IVehicleStatusWebService/GetVehicleStatusByIdFaultDataFault", Name:="FaultData", [Namespace]:="http://schemas.datacontract.org/2004/07/Xata.Ignition.Common.Contract")>  _
        Function GetVehicleStatusById(ByVal VehicleSID As String, ByVal asOfDateTime As String) As xrsVehicleStatus.VehicleStatus
        
        <System.ServiceModel.OperationContractAttribute(Action:="http://tempuri.org/IVehicleStatusWebService/GetVehicleStatusById", ReplyAction:="http://tempuri.org/IVehicleStatusWebService/GetVehicleStatusByIdResponse")>  _
        Function GetVehicleStatusByIdAsync(ByVal VehicleSID As String, ByVal asOfDateTime As String) As System.Threading.Tasks.Task(Of xrsVehicleStatus.VehicleStatus)
        
        <System.ServiceModel.OperationContractAttribute(Action:="http://tempuri.org/IVehicleStatusWebService/GetVehicleStatus", ReplyAction:="http://tempuri.org/IVehicleStatusWebService/GetVehicleStatusResponse"),  _
         System.ServiceModel.FaultContractAttribute(GetType(xrsVehicleStatus.FaultData), Action:="http://tempuri.org/IVehicleStatusWebService/GetVehicleStatusFaultDataFault", Name:="FaultData", [Namespace]:="http://schemas.datacontract.org/2004/07/Xata.Ignition.Common.Contract")>  _
        Function GetVehicleStatus(ByVal VehicleID As String, ByVal asOfDateTime As String) As xrsVehicleStatus.VehicleStatus
        
        <System.ServiceModel.OperationContractAttribute(Action:="http://tempuri.org/IVehicleStatusWebService/GetVehicleStatus", ReplyAction:="http://tempuri.org/IVehicleStatusWebService/GetVehicleStatusResponse")>  _
        Function GetVehicleStatusAsync(ByVal VehicleID As String, ByVal asOfDateTime As String) As System.Threading.Tasks.Task(Of xrsVehicleStatus.VehicleStatus)
        
        <System.ServiceModel.OperationContractAttribute(Action:="http://tempuri.org/IVehicleStatusWebService/GetAllVehicleStatus", ReplyAction:="http://tempuri.org/IVehicleStatusWebService/GetAllVehicleStatusResponse"),  _
         System.ServiceModel.FaultContractAttribute(GetType(xrsVehicleStatus.FaultData), Action:="http://tempuri.org/IVehicleStatusWebService/GetAllVehicleStatusFaultDataFault", Name:="FaultData", [Namespace]:="http://schemas.datacontract.org/2004/07/Xata.Ignition.Common.Contract")>  _
        Function GetAllVehicleStatus(ByVal organizationSID As String, ByVal resourceGroupSID As String, ByVal asOfDateTime As String, ByVal limit As String, ByVal offset As String, ByVal organizationID As String, ByVal resourceGroupID As String) As xrsVehicleStatus.VehicleStatus()
        
        <System.ServiceModel.OperationContractAttribute(Action:="http://tempuri.org/IVehicleStatusWebService/GetAllVehicleStatus", ReplyAction:="http://tempuri.org/IVehicleStatusWebService/GetAllVehicleStatusResponse")>  _
        Function GetAllVehicleStatusAsync(ByVal organizationSID As String, ByVal resourceGroupSID As String, ByVal asOfDateTime As String, ByVal limit As String, ByVal offset As String, ByVal organizationID As String, ByVal resourceGroupID As String) As System.Threading.Tasks.Task(Of xrsVehicleStatus.VehicleStatus())
    End Interface
    
    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")>  _
    Public Interface IVehicleStatusWebServiceChannel
        Inherits xrsVehicleStatus.IVehicleStatusWebService, System.ServiceModel.IClientChannel
    End Interface
    
    <System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")>  _
    Partial Public Class VehicleStatusWebServiceClient
        Inherits System.ServiceModel.ClientBase(Of xrsVehicleStatus.IVehicleStatusWebService)
        Implements xrsVehicleStatus.IVehicleStatusWebService
        
        Public Sub New()
            MyBase.New
        End Sub
        
        Public Sub New(ByVal endpointConfigurationName As String)
            MyBase.New(endpointConfigurationName)
        End Sub
        
        Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
            MyBase.New(endpointConfigurationName, remoteAddress)
        End Sub
        
        Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
            MyBase.New(endpointConfigurationName, remoteAddress)
        End Sub
        
        Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
            MyBase.New(binding, remoteAddress)
        End Sub
        
        Public Function GetVehicleStatusById(ByVal VehicleSID As String, ByVal asOfDateTime As String) As xrsVehicleStatus.VehicleStatus Implements xrsVehicleStatus.IVehicleStatusWebService.GetVehicleStatusById
            Return MyBase.Channel.GetVehicleStatusById(VehicleSID, asOfDateTime)
        End Function
        
        Public Function GetVehicleStatusByIdAsync(ByVal VehicleSID As String, ByVal asOfDateTime As String) As System.Threading.Tasks.Task(Of xrsVehicleStatus.VehicleStatus) Implements xrsVehicleStatus.IVehicleStatusWebService.GetVehicleStatusByIdAsync
            Return MyBase.Channel.GetVehicleStatusByIdAsync(VehicleSID, asOfDateTime)
        End Function
        
        Public Function GetVehicleStatus(ByVal VehicleID As String, ByVal asOfDateTime As String) As xrsVehicleStatus.VehicleStatus Implements xrsVehicleStatus.IVehicleStatusWebService.GetVehicleStatus
            Return MyBase.Channel.GetVehicleStatus(VehicleID, asOfDateTime)
        End Function
        
        Public Function GetVehicleStatusAsync(ByVal VehicleID As String, ByVal asOfDateTime As String) As System.Threading.Tasks.Task(Of xrsVehicleStatus.VehicleStatus) Implements xrsVehicleStatus.IVehicleStatusWebService.GetVehicleStatusAsync
            Return MyBase.Channel.GetVehicleStatusAsync(VehicleID, asOfDateTime)
        End Function
        
        Public Function GetAllVehicleStatus(ByVal organizationSID As String, ByVal resourceGroupSID As String, ByVal asOfDateTime As String, ByVal limit As String, ByVal offset As String, ByVal organizationID As String, ByVal resourceGroupID As String) As xrsVehicleStatus.VehicleStatus() Implements xrsVehicleStatus.IVehicleStatusWebService.GetAllVehicleStatus
            Return MyBase.Channel.GetAllVehicleStatus(organizationSID, resourceGroupSID, asOfDateTime, limit, offset, organizationID, resourceGroupID)
        End Function
        
        Public Function GetAllVehicleStatusAsync(ByVal organizationSID As String, ByVal resourceGroupSID As String, ByVal asOfDateTime As String, ByVal limit As String, ByVal offset As String, ByVal organizationID As String, ByVal resourceGroupID As String) As System.Threading.Tasks.Task(Of xrsVehicleStatus.VehicleStatus()) Implements xrsVehicleStatus.IVehicleStatusWebService.GetAllVehicleStatusAsync
            Return MyBase.Channel.GetAllVehicleStatusAsync(organizationSID, resourceGroupSID, asOfDateTime, limit, offset, organizationID, resourceGroupID)
        End Function
    End Class
End Namespace

Do I even need this code? This keeps convincing me that all I need is my working connection string, and logic that uses properties from this class(s)

reigh7 on Thu, 19 Mar 2015 20:07:27


It sounds more like you are consuming an already existing service the artical you linked to is for creating a new service you make from scratch. By the way the instructions for previous versions of visual studio will work RIA services which has been around for a long time for backwards compatibility of older legacy data applications.

If you are consuming a service that you already have access to and know how to find just follow beth massi's older video on adding external data sources.


Also watch these two videos they are on O-Data but there are many similarities while using LightSwitch to consume RIA services for older legacy systems.
Video 1 Consuming O Data link
Video 2 Creating O Data link