Question Advice on what type of app to build for exchanging xml data between servers

fisherRon

New member
Joined
Feb 15, 2013
Messages
3
Location
Utah
Programming Experience
1-3
I have a project that I need to build that gathers data from a local database, packages it into an xml file (as specified by receiving server) and send it to another server via an API they provide.
I then need to be able to receive data back from that remote server and display it to the user (or users).

I know how to get the data and package it. I'm just not sure how to do the part that sends it to a remote server via their API and receive data back from them.

A user needs to be able to access the system (with secure login) and simply tell it what data is needed (by selecting a case) then clicking a button or something to initiate the process of sending out the data and then waiting for a response.

The 2 ways I thought about doing this are: 1. Build a web app to deploy on the local server that has the user interface - it is self-contained and doesn't need to communicate with a client - just the other remote server. Once the user logs in and initiates the data exchange, the app would process everything and send it to the remote server, then receive the response and notify the user and display it.
2. Build a client that the user accesses and the client would gather the necessary data, then send it to the local server in some manner (xml, json, whatever), then the local server would process it and package it appropriately and send it to the remote server. Then, when a response was received, it would notify the client and send the response back to the client.

The problem is that I'm not sure what type(s) of apps to use to accomplish this. I'm fairly new to visual studio, but I know how to get the data and package it and once data is received from the remote server, I know how to de-serialize it and display it. I just am not sure how to manage the communications between the servers and/or the client.

If someone can steer me in the direction I should look, I would greatly appreciate it. I was thinking of doing an MVC app for the server portion, but I don't know enough about it to know if that's the best way to go or if it's only part of the solution.

Do I need 1 app or several working together? I would prefer to just do a web app, but may need to do the client / server depending on issues yet to be finalized.

Thanks,

Ron
 

Herman

Well-known member
Joined
Oct 18, 2011
Messages
882
Location
Montreal, QC, CA
Programming Experience
10+
Well the issue is you need to exchange some data with a server. For various reasons you cannot just open up a SQL server and make a client app over the web. The solution is to run a web service on the server that handles the data. The WCF library project template is perfect for that. Once you build your web service as a library, you can host it inside a windows service app that you install on the server. Now to design your client application, add a service reference to your app. Now you can access all the operation contracts you defined in your WCF service.
 

fisherRon

New member
Joined
Feb 15, 2013
Messages
3
Location
Utah
Programming Experience
1-3
Intermediary between 2 API services

Thanks for your replies. I was thinking of using the WCF project to build a web service on the server and a client app that references that to use it from the client.
I am not an expert in WCF and have only used it in tutorials and academic situations which, while helpful, are not real world scenarios.
I am confident that I can get the data I need from the client and send it to the server and get responses back using a WCF project. What I am not sure of is if the WCF Service will work for sending out data packages to a 2nd, third party API. We do need a user interface on the client side.

I get data on the client from using a third party API that is already done in WCF, then with the data I retrieve from that service, I package it up into a XML file for the other (2nd) API. That package of data must be received from a server with a static IP address, thus the need to forward it from the client to a server on our side, then that server needs to send it on to the 2nd API service for processing and acceptance. I also need to be able to receive responses back from that 2nd API hosted on their side.

So basically, it's kind of like this: OUR SIDE: Client / Server using WCF to communicate and retrieve data - then format it in the package as expected by the 2nd API service and send it via the server. THEIR SIDE: Receive our package and process it. Send us messages indicating whether it was accepted and then the result of the process including data that we need in our system.
OUR SIDE: Receive the responses back from the 2nd API server, process them and display them to the client.

The 1st API (on our side) is a WCF web service API.
The 2nd API (on their side) is a web service API but all I know about it is the address and methods available. I'm not sure yet whether I will have to poll their server for results or if their server will send the results to our server. I'm still waiting on all the details about their services (paperwork and non-disclosure agreements pending ...).

Given what I know of the situation, I believe that a WCF solution will work fine, but I am not certain since I have little experience with it. Even if it will work, is there a better way (MVC type app using REST) or is it mostly personal preference?

Thanks
 

Herman

Well-known member
Joined
Oct 18, 2011
Messages
882
Location
Montreal, QC, CA
Programming Experience
10+
With a WCF service, whatever composite types you will use to transmit data must be declared with the DataContract attribute, that will make the type public to the client application. Any methods you wish to make available must be declared with the OperationContract attribute. A client application referencing the service will automagically see those types and methods and be allowed to call/use them. Any data transmitted to and from the service is serialized/deserialized using the DataContract "schemas" supplied. For example, let's say I want a WCF service that has a function that will take in a List(Of Integer) and return an object containing both the sum and product of the supplied integers...

First you define your service, data, and operation contracts:

<ServiceContract()>
Public Class Service1

    <OperationContract()>
    Public Function ProcessListOfIntegers(ByVal intList As List(Of Integer)) As ResultCompositeType
        Dim result As New ResultCompositeType

        For Each i In intList
            result.Sum += i
            result.Product *= i
        Next

        Return result
    End Function

End Class

<DataContract()>
Public Class ResultCompositeType
    Public Sum As Integer = 0
    Public Product As Integer = 1
End Class


And then you can consume them in your client application, after adding a service reference:

Public Class Form1

    Dim wcfService As New WcfServiceLibrary1.Service1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim r As WcfServiceLibrary1.ResultCompositeType = wcfService.ProcessListOfIntegers({2, 3, 4, 5, 6}.ToList)
    End Sub

End Class


It's really quite simple to use...
 

fisherRon

New member
Joined
Feb 15, 2013
Messages
3
Location
Utah
Programming Experience
1-3
Thanks Herman

That really helps me get moving on with this. I'm going to get working on it.
I appreciate the simple and effective example.
 
Top Bottom