none
Cache a value based on ISA values. Use for each invoice in envelope RRS feed

  • Question

  • These must be a straight foward way to do this.
    Right now when I receive a message, each 810 invoice is mapped to an xml format.
    Then I have an orchestration that does some work further enriching the data.  One of the things it does is call a webservice that based on the ISA party data, returns a client numberr that goes into the xml invoice.
    If a doc has 200 invoices in it, I call the service 200 times but realy it should only be called once per EDI Document and the value used for each of the internal invoices.

    Is there a way to do this?  I was going to call a static class and keep a dictionary of values there. If there is no value, web service is called, otherwise take it from the class.

    But then multiple invoices will all start calling hte service before the first one returns and populates the dictionary.

    I'm thinking of locking the dictionary.  Call Webservice, get value.  Call static class, put value in dictionary. Unlock the dictionary.

    Tuesday, March 10, 2009 4:19 PM

Answers

  • So basically you are trying to implement a singleton pattern in C# which calls the web service during the construction of the class. Here is a link that compares a singleton use to static class use: http://dotnet.dzone.com/news/c-singleton-pattern-vs-static- I would use a static class.

    So that your orchestration can handle dehydration, be sure to roundtrip the data returned from the singleton class back to BizTalk so that if the orchestration dehydrates you still have the data. Then you just need to pass back the data to the singleton class from BizTalk to the method call each time so that if the orchestration did dehydrate you will not need to call the web service once again.

    Thanks,
    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Wednesday, March 11, 2009 12:05 PM
    Moderator

All replies

  • So basically you are trying to implement a singleton pattern in C# which calls the web service during the construction of the class. Here is a link that compares a singleton use to static class use: http://dotnet.dzone.com/news/c-singleton-pattern-vs-static- I would use a static class.

    So that your orchestration can handle dehydration, be sure to roundtrip the data returned from the singleton class back to BizTalk so that if the orchestration dehydrates you still have the data. Then you just need to pass back the data to the singleton class from BizTalk to the method call each time so that if the orchestration did dehydrate you will not need to call the web service once again.

    Thanks,
    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Wednesday, March 11, 2009 12:05 PM
    Moderator
  • Is this the only way to do this? I imagine many people have values that are the same for every invoice in a message but change with each new message. 
    Wednesday, March 11, 2009 2:18 PM
  • I could also see this done in the Business Rules Engine with the lookup as a fact provider. I am not sure how well this would cache though so you might get sequential web service calls for each execution.

    Thanks,


    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Wednesday, March 11, 2009 2:31 PM
    Moderator