Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4580456
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:47:10+00:00 2026-05-21T20:47:10+00:00

I am new to WCF and I’m also learning the MVP design pattern. I

  • 0

I am new to WCF and I’m also learning the MVP design pattern. I have a test project with a working WCF service. I am able to test with the WCF test client and it works fine.

I need help with how to call the WCF service from my Presenter layer and then have the Presenter pass the data back to the View (winforms). I have a Windows Form with two textboxes named txtProductID and txtDescription. I also have a button named btnGetProductData. I would like the following to happen:

  1. I will put a product id in the txtProductID field.
  2. I will click the btnGetProductData button and the presenter should call the GetProductData method from the WCF service and return the product description to the txtProductDescription field on my form.

Here is the pertinent code from the WCF service library:

IProductService.cs
------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace MyWCFServices.ProductService
{
   [ServiceContract]
    public interface IProductService
    {
        [OperationContract]
        Product GetProductData(string ProductId);     
    }

    [DataContract]
    public class Product
    {
        [DataMember]
        public string ProductID { get; set; }
        [DataMember]
        public string ProductDescription { get; set; }

    }
}

ProductService.cs
--------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using MyWCFServices.ProductEntities;
using MyWCFServices.ProductBusinessLogic;

namespace MyWCFServices.ProductService
{

    public class ProductService : IProductService
    {
        ProductLogic productLogic = new ProductLogic();

        public Product GetProductData(string ProductId)
        {

            ProductEntity productEntity = productLogic.
                GetProductData(ProductId);
            Product product = new Product();

            TranslateProductEntityToProductContractData(productEntity, 
                product);
            return product;

        }

        private Product TranslateProductEntityToProductContractData(
            ProductEntity productEntity, Product product)
        {

            product.ProductID = productEntity.ProductID;
            product.ProductDescription = productEntity.ProductDescription;

            return product;                     
        }        
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T20:47:11+00:00Added an answer on May 21, 2026 at 8:47 pm

    I’m not sure where you’re having issues, so I’ll start at the beginning.

    1. You need to add a “Service Reference” to your Presentation Tier Project (this generates a proxy class you can use to call your service)
    2. You need to create an instance of the generated proxy class
    3. You need to call a method on the proxy class and store its value

    From Visual Studio, right click your project and choose “Add Service Reference” and then navigate to the endpoint for your service.

    Example Code:

    // Presentation Tier (button event handler)
    var proxy = new ServiceReference1.ProductServiceClient();
    var prod = proxy.GetProductData("yourProductID");
    txtDescription.Text = prod.Description;
    txtProductID.Text = prod.ProductID; // same as passed parameter
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a new WCF service library type project. I have created a
When creating a new service in a WCF service project, Visual Studio will automatically
I'm working on a new WCF web service that's to be hosted within an
I'm trying to get going with a new WCF service. The service was working
I just created a new WCF Service Application project in VS2010 (Premium), and it
I created a new wcf rest service using .net 4. I have created a
I have created a new wcf4 web application and added a new wcf service.
Recently we added the new WCF Routing Service to our project. While debugging a
I'm trying to learn WCF and I've created a new WCF Service Library project
I have been looking into refactoring some old code into a new WCF service,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.