InvokeWebServiceActivity tips

Per poter modificare il puntamento ad un web service a runtime e modificarne il timeout:

   1: private void callWsOperation_Invoking(object sender, InvokeWebServiceEventArgs e)
   2:     {
   3:         ((MathWS.Operations)e.WebServiceProxy).Url = ((NameValueCollection)ConfigurationManager.GetSection("MyCalculator/OperationsWf"))["OperationsWS"];
   4:         ((MathWS.Operations)e.WebServiceProxy).Timeout = 900000;
   5:     }

Dove MathWS.Operations e’ il nome del Web Service. Gestendo l’evento Invoking e’cosi’ possibile cambiare il Ws a cui punta l’activity cosi’ come il limite di timeout nella risposta.

   1: <!-- Custom sections-->
   2:    <sectionGroup name="MyCalculator">
   3:      <section name="OperationsWf" type="System.Configuration.NameValueSectionHandler"/>
   4:    </sectionGroup>
   5: ......
   6: ......
   7: <!-- Custom SETTINGS -->
   8: <MyCalculator>
   9:   <!-- Url of the Operations WS -->
  10:   <OperationsWf>
  11:     <add key="OperationsWS" value="http://localhost/MySampleWs/Operations.asmx"/>
  12:   </OperationsWf>
  13: </MyCalculator>
Advertisements