• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 719
  • Last Modified:

Consuming a service to create validation app

Hi.

I'm trying to figure out how WCF services work, and am trying to follow some work that was half done.

A web service was already written, and I successfully called it into a Windows forms application.  This application should validate banking details.

The code behind the validate button is here:

private void button1_Click(object sender, EventArgs e)
        {
            var proxy =  new bnk.BankingClient("BasicHttpBinding_IBanking");
            var result = new bnk.CDVResult();

            //result = proxy.Validate(0987654, 1, 2000001, "A Person");

            //result = proxy.Validate(0323453, 6, 2000002, "S Smith");
            //Bank details invalid

            result = proxy.Validate(0121245, 1, 200003, "T Mark");
           
            //Invalid Branch

        }

What do I need to do in order to get the result to actually produce a result on the screen?  What am I missing?
0
Jasmin01
Asked:
Jasmin01
1 Solution
 
Vel EousResearch & Development ManagerCommented:
The return type of proxy.Validate(...); is an instance of the object CDVResult();.  Without knowing the internal structure of this object I cannot say exactly how you should be processing this result.

However as an example if your proxy.Validate(...); method returned an instance of the following object:
public class ValidationReturnObject
{
	public bool Result { get; set; }
	public string Message { get; set; }
}

Open in new window

Then you could use the following to display your result message:
lblResult.Text = result.Message;

Open in new window

The above assumes you have a Label control on your form named lblResult.

What we're doing above is:
var result = new bnk.CDVResult(); creates a new instance of the CDVResult(); object.  Your service call result = proxy.Validate(...); effectively populates that instance with data returned from your service call.  You now have a local object to work with and can therefore perform actions on it as you would any other local object instance;
myObjectInstance.Property;

Open in new window

or
myObjectInstance.Method(...);

Open in new window


I apologise if I have misunderstood your question.
0
 
Jasmin01Author Commented:
Thank you.  I have been researching as well and I now have a better understanding.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now