Just how to pass enumerated values to an internet solution

My predicament is, primarily, just how to share a list in between 2 applications.

The customers post records via a front-end application that gets on the internet. This application calls an internet solution of the back-end application and also passes the record to it. The back-end application conserves the record and also inserts a row in the Document table.

The record type (7 feasible record kinds: Billing, Contract and so on) is passed as a parameter to the internet solution's UploadDocument method. The inquiry is, what need to the type (and also feasible values) of this parameter be?

Given that you require to hardcode these values in both applications, I assume it is O.K. to make use of a detailed string (Invoice, Contract, WorkOrder, SignedWorkOrder).

Is it possibly a far better strategy to create a DocumentTypes list in the first application, and also to duplicate it additionally in the 2nd application, and afterwards pass the equivalent integer value to the internet solution in between them?

0
2019-05-04 02:07:24
Source Share
Answers: 5

I would certainly recommend versus passing an integer in between them, merely for objectives of readability and also debugging. Claim you're experiencing your logs and also you see a number of 500 mistakes for DocumentType= 4. Currently you've reached go seek out which DocumentType is 4. Or if among the applications describes a number that does not exist in the various other, probably as a result of dissimilar variations.

It's a little bit extra code, and also it massages the fixed keying component of the mind a little bit raw, yet in methods in addition to HTTP the obtained knowledge is to agree understandable strings over nontransparent lists.

0
2019-05-07 18:38:14
Source

I can just talk about.net, yet if you have an ASP.net Webservice, you need to have the ability to add a list straight to it.

When you after that make use of the "Add Web Reference" in your Client Application, the resulting Class needs to include that enum

But this is from the top of my head, i'm rather certain i've done it in the past, yet I can not claim without a doubt.

0
2019-05-07 18:32:55
Source

I would certainly still make use of list inside yet would certainly anticipate customers to pass me just the name, not the numerical value itself.

simply some foolish instance to highlight :

public enum DocumentType
{
  Invoice,
  Contract,
  WorkOrder,
  SignedWorkOrder
}

[WebMethod]
public void UploadDocument(string type, byte[] data)
{
  DocumentType docType = (DocumentType)Enum.Parse(typeof(DocumentType), type);
}
0
2019-05-07 18:30:38
Source

In.NET, list values are (by default ) serialized right into xml with the name. As an examples where you can have numerous values (flags ), after that it places a room in between the values. This functions due to the fact that the list does not have rooms, so you can get the value once more by splitting the string (ie. "Invoice Contract SignedWorkOrder", making use of lubos's instance ).

You can regulate the serialization of values of in asp.net web services making use of the XmlEnumAttribute, or making use of the EnumMember feature when making use of WCF.

0
2019-05-07 18:00:32
Source

If you are eating your Web solution from a.NET page/application, you need to have the ability to access the list after you add your Web reference to the task that is eating the solution.

0
2019-05-07 17:53:31
Source