<process name="simple" 
         targetNamespace="urn:news:NewsService"
         xmlns:tns="urn:news:NewsService"
         xmlns:babelfish="http://www.xmethods.net/sd/BabelFishService.wsdl"
	 xmlns:html2text="http://mycompany.com/services/util/html2text"
	 xmlns:hnews="http://www.SoapClient.com/xml/SQLDataSoap.wsdl"
         xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">

  <variables>
    <variable name="userRequest" messageType="tns:userRequest"/>
    <variable name="newsRequest" messageType="hnews:ProcessSRL"/>
    <variable name="newsResponse" messageType="hnews:ProcessSRLResponse"/>
    <variable name="htmlNews" messageType="html2text:html"/>
    <variable name="textNews" messageType="html2text:text"/>
    <variable name="englishNews" messageType="babelfish:BabelFishRequest"/>
    <variable name="translatedNews" messageType="babelfish:BabelFishResponse"/>
    <variable name="userResponse" messageType="tns:userResponse"/>
  </variables>

  <partners>
    <partner name="User" serviceLinkType="tns:UserSLT"/>
    <partner name="EnglishNewsService" serviceLinkType="tns:EnglishNewsSLT"/>
    <partner name="HTML2TextService" serviceLinkType="tns:HTML2TextSLT"/>
    <partner name="BabelFishService" serviceLinkType="tns:BabelFishServiceSLT"/>
  </partners>

  <sequence name="sequence">
    <!-- get news request from the user -->
    <receive name="receiveRequest" partner="User" portType="tns:NewsPT" 
             operation="getNews" variable="userRequest"
             createInstance="yes"/>
    <!-- create input message required by news service -->
    <assign name="CreateNewsInput">
      <copy>
          <from expression="'/xml/NEWS.SRI'"/>
          <to variable="newsRequest" part="SRLFile"/>
      </copy>
      <copy>
          <from expression="'yahoo'"/>
          <to variable="newsRequest" part="RequestName"/>
      </copy>
      <copy>
          <from expression="''"/>
          <to variable="newsRequest" part="key"/>
      </copy>
    </assign>
    <!-- invoke news service -->
    <invoke name="invokeNewsService" partner="EnglishNewsService" portType="hnews:SQLDataSoapPortType"
            operation="ProcessSRL" inputVariable="newsRequest"
            outputVariable="newsResponse"/>
    <!-- map news response to input data reqd by html2text conversion service -->
    <assign name="mapNewsOutputToConversionInput">
      <copy>
          <from variable="newsResponse" part="return"/>
          <to variable="htmlNews" part="content"/>
      </copy>
    </assign>
    <!-- invoke convertor to strip off HTML tags from English news -->
    <invoke name="invokeConvertor" partner="HTML2TextService" portType="html2text:Html2TextPortType"
            operation="convertHTML2Text" inputVariable="htmlNews"
            outputVariable="textNews"/>
    <!-- copy user's language preference to input data reqd by translation service -->
    <assign name="copyUserPreferenceToTranslationInput">
      <copy>
          <from variable="userRequest" part="language"/>
          <to variable="englishNews" part="translationmode"/>
      </copy>
    </assign>
    <!-- map convertor output to input data reqd by translation service -->
    <assign name="mapConvertedNewsToTranslationInput">
      <copy>
          <from variable="textNews" part="content"/>
          <to variable="englishNews" part="sourcedata"/>
      </copy>
    </assign>
    <!-- invoke translation service to translate into language of choice -->
    <invoke name="invokeTranslator" partner="BabelFishService" portType="babelfish:BabelFishPortType"
            operation="BabelFish" inputVariable="englishNews"
            outputVariable="translatedNews"/>
    <!-- map the translated news output to the output the user expects -->
    <assign name="mapTranslatedNewsToUserOutput">
      <copy>
          <from variable="translatedNews" part="return"/>
          <to variable="userResponse" part="news"/>
      </copy>
    </assign>
    <!-- respond to the user -->
    <reply name="sendNews" partner="User" portType="tns:NewsPT"
           operation="getNews" variable="userResponse"/>
  </sequence>

</process>
