0

I think this guy has the same problem as me, but I need clarification:

wcf service with params

Anyway, I'm trying to write a WCF operation contract that takes in a string the same way as String.Format does using a params array of objects, and a formatting string. That way, I can call the operation like this:

OperationContractMethod("Hello {0}", "Dave");

Instead of doing it like this:

OperationContractMethod(String.Format("Hello {0}", "Dave"));

Basically, the operation contract method takes a string, but I just want to be able to pass the string in formatted form for convenience. It works well with normal methods, because I can just create the function explicitly, but WCF presents the challenge that I have to write this in interface form first. The other guy said something about not all objects being serializable. Is it possible to do this or not?

1 Answer 1

1

No, I don't think it is possible. The data contract needs to be specific, and attributed, e.g.

[DataContract]
public class Contact
{
    [DataMember]
    public string Name { get; set; }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.