WCF Interface Design: No Ref Parameters or Parameters

I have a WCF service and a web client. The web service implements one SubmitOrders method. This method takes a set of orders. The problem is that the service must return an array of results for each order - true or false. Marking WCF parameters as outside or ref does not make sense. What would you recommend?

[ServiceContact] public bool SubmitOrders(OrdersInfo) [DataContract] public class OrdersInfo { Order[] Orders; } 
+5
source share
6 answers

Marking WCF parameters as outside or ref does not make sense.

Options

out make sense in WCF.

What would you recommend?

I recommend using options.


Note 1: It will move your out parameter to the first parameter.

Note 2: Yes, you can return objects with complex types in WCF. Mark your class with the [DataContract] attribute and your properties with the [DataMember] attribute.

+11
source

Use a complex type (another class with a DataContract attribute) in reverse order.

how

 [ServiceContact] public OrdersResult SubmitOrders(OrdersInfo) [DataContract] public class OrdersInfo { Order[] Orders; } [DataContract] public class OrdersResult { ..... } 

Also add DataMember to Order[] Orders;

+3
source

Well, if you want to avoid parameters and ref, you can always return an array of order IDs that were sent successfully.

+2
source

Yes, it makes sense to return the out parameter for WCF operations. In response to the message, SOAP will contain the element passed back.

MSDN has good data transfer content: Indication of data transfer in service contracts

In addition, you need to use OperationContractAttribute (not ServiceContractAttribute) on SubmitOrders.

+2
source

A special class that contains order and true / false, or an array of tags.

+1
source

The method will look like this:

 public OrdersInfo SubmitOrders(OrderInfo orders){ } 

where each item in OrderInfo will have a SubmissionStatusInfo, for example:

 class SubmissionStatusInfo{ enum Status { get; set; } string Message { get; set; } } 

where Status : Submitted, Failed, Error , etc.
Message : a string giving some additional status information ...

NTN

+1
source

All Articles