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 6142659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:25:05+00:00 2026-05-23T18:25:05+00:00

I am learning WCF . where I tried to return an object from my

  • 0

I am learning WCF. where I tried to return an object from my service to client after the operation completed from my client as required. But Its not giving any error and also not returning the result.

Service.svc.cs

public class myWCF : ImyWCF
{
    public int myAddition(int IP_One, int IP_Two, out int IP_Three)
    {
        IP_Three = IP_One + IP_Two;
        return IP_Three;
    }
    public MYTYPE mySubstraction()
    {
        MYTYPE mType = new MYTYPE();
        mType.InpOne = 10;
        mType.InpTwo = 20;
        mType.InpThree = mType.InpTwo - mType.InpOne;
        return mType;
    }
}

Interface and Classes

[ServiceContract]
public interface ImyWCF
{
    [OperationContract]
    int myAddition(int IP_One, int IP_Two, out int IP_Three);
    [OperationContract]
    MYTYPE mySubstraction();
}

[DataContract]
public class myArithmatics
{
    [DataMember]
    public int IP_One;
    [DataMember]
    public int IP_Two;
    [DataMember]
    public int IP_Three;
}

[Serializable]
[DataContractAttribute(IsReference=true)]
public class MYTYPE
{
    public int inpOne = 0;
    public int inpTwo = 0;
    public int inpThree = 0;
    [DataMemberAttribute]
    public int InpOne
    {
        get { return inpOne; }
        set { inpOne = value; }
    }
    [DataMemberAttribute]
    public int InpTwo
    {
        get { return inpTwo; }
        set { inpTwo = value; }
    }
    [DataMemberAttribute]
    public int InpThree
    {
        get { return inpThree; }
        set { inpThree = value; }
    }
}

Client App

Console.WriteLine("Service Started");
ClientMyWCF.ImyWCFClient oMYWcf = new ClientMyWCF.ImyWCFClient();
int INP_One = 10;
int INP_Two = 20;
int INP_Three = 0;
oMYWcf.myAddition(out INP_Three,INP_One,INP_Two);
Console.WriteLine("Out put from Service :"+ INP_Three.ToString());
ClientMyWCF.MYTYPE objMT = new ClientMyWCF.MYTYPE();
objMT.InpOne = 10;
objMT.InpTwo = 20;
//objMT.InpThree = 0;
oMYWcf.mySubstraction();
Console.WriteLine("Out put from Service :" + objMT.InpThree.ToString());
Console.ReadLine();

So any idea how to get the object returned?

  • 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-23T18:25:05+00:00Added an answer on May 23, 2026 at 6:25 pm

    I’m not sure why you’re using an OUT parameter in the first call when you’re returning the result of the operation as well as the OUT parameter.

    Also, in the first method call (addition) you have the parameters in the wrong order.
    In the second method call, you’re not assigning the MYTYPE object to a variable.

    I would suggest the following code:

    public class myWCF : ImyWCF
    {
        // remove the OUT parameter
        public int myAddition(int IP_One, int IP_Two)
        {
            return IP_One + IP_Two;
        }
        public MYTYPE mySubstraction()
        {
            MYTYPE mType = new MYTYPE();
            mType.InpOne = 10;
            mType.InpTwo = 20;
            mType.InpThree = mType.InpTwo - mType.InpOne;
            return mType;
        }
    }
    

    Use the following in your program code:

    Console.WriteLine("Service Started");
    ClientMyWCF.ImyWCFClient oMYWcf = new ClientMyWCF.ImyWCFClient();
    int INP_One = 10;
    int INP_Two = 20;
    int INP_Three = 0;
    
    INP_Three = oMYWcf.myAddition(INP_One, INP_Two);
    Console.WriteLine("Out put from Service :"+ INP_Three.ToString());
    
    ClientMyWCF.MYTYPE objMT = new ClientMyWCF.MYTYPE();
    // Not needed - these are set in the mySubtraction method
    //objMT.InpOne = 10;
    //objMT.InpTwo = 20;
    //objMT.InpThree = 0;
    objMT = oMYWcf.mySubstraction();
    Console.WriteLine("Out put from Service :" + objMT.InpThree.ToString());
    Console.ReadLine();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

a) I plan to start learning WCF, but I’m not sure whether it’s important
I'm currently learning wcf for an up and coming project. The service I am
I spent a long time learning how to customise WCF from the point of
Its a newbie question, and I have just been learning WCF. Can we change
I just started learning on WCF and is trying to create a WCF service
Yesterday I began learning WCF by porting an existing ASP.NET Web Service. Creating the
I have not worked on the WSE/ASMX webs services and I am learning WCF
I am learning and designing a WCF service. I have picked to use Windows
I have started learning WCF. I wrote a simple service to query a SQL
I am learning WCF,one of the benefits of WCF is that you can use

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.