summaryrefslogtreecommitdiffstats
path: root/sandbox/travelsample/paymentprocess-contribution/src/scatours/paymentprocess/paymentprocess.bpel
blob: f1faf982aa392c19dfdf5347d1c04bea31872a69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements.  See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership.  The ASF licenses this file
  ~ to you under the Apache License, Version 2.0 (the
  ~ "License"); you may not use this file except in compliance
  ~ with the License.  You may obtain a copy of the License at
  ~
  ~    http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing,
  ~ software distributed under the License is distributed on an
  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~ KIND, either express or implied.  See the License for the
  ~ specific language governing permissions and limitations
  ~ under the License.
  -->
<process name="PaymentProcess"
    targetNamespace="http://www.example.org/PaymentProcess"
    xmlns="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
    xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
    xmlns:tns="http://tuscany.apache.org/PaymentProcess"    
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:pp="http://www.example.org/PaymentProcess/"
    xmlns:ccp="http://www.example.org/CreditCardPayment/"
    xmlns:eg="http://www.example.org/EmailGateway/"
    queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
    expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">

  <import location="PaymentProcess.wsdl" 
          importType="http://schemas.xmlsoap.org/wsdl/"
          namespace="http://www.example.org/PaymentProcess/"/>     

  <import location="CreditCardPayment.wsdl" 
          importType="http://schemas.xmlsoap.org/wsdl/"
          namespace="http://www.example.org/CreditCardPayment/"/>
          
  <import location="EmailGateway.wsdl" 
          importType="http://schemas.xmlsoap.org/wsdl/"
          namespace="http://www.example.org/EmailGateway/"/>          
          
   <partnerLinks>
      <partnerLink name="paymentProcessPartnerLink" partnerLinkType="pp:PaymentProcessLinkType" myRole="forward" />
      <partnerLink name="creditCardPaymentPartnerLink" partnerLinkType="ccp:CreditCardPaymentLinkType" partnerRole="forward" initializePartnerRole="yes" />
      <partnerLink name="emailGatewayPartnerLink" partnerLinkType="eg:EmailGatewayLinkType" partnerRole="forward" initializePartnerRole="yes" />
   </partnerLinks>
    
   <variables>
     <variable name="makePaymentRequestMessage" messageType="pp:MakePaymentRequest"/>
     <variable name="makePaymentResponseMessage" messageType="pp:MakePaymentResponse"/>
     <variable name="makePaymentResponse" type="pp:MakePaymentResponseType"/>
     <variable name="authorizeRequestMessage" messageType="ccp:AuthorizeRequest"/>
     <variable name="authorizeResponseMessage" messageType="ccp:AuthorizeResponse"/>
     <variable name="authorizeRequest" type="ccp:AuthorizeType"/>
     <variable name="sendEmailRequestMessage" messageType="eg:SendEmailRequest"/>
     <variable name="sendEmailResponseMessage" messageType="eg:SendEmailResponse"/>
   </variables>

   <sequence>
       <receive name="start"
                partnerLink="paymentProcessPartnerLink"
                portType="pp:PaymentProcess"
           	    operation="makePayment"
                variable="makePaymentRequestMessage"
                createInstance="yes"/>

       <!-- set up call to payments service -->
       <assign name="assign1">
          <copy>
              <from>
                  <literal>
                    <ccp:Authorize>
                        <ccp:CreditCard>
                            <ccp:CreditCardType>Visa</ccp:CreditCardType>
                            <ccp:CreditCardNumber>12345678</ccp:CreditCardNumber>
                            <ccp:ExpMonth>2</ccp:ExpMonth>
                            <ccp:ExpYear>2010</ccp:ExpYear>
                            <ccp:CardOwner>
                                <ccp:Name>Empty</ccp:Name>
                                <ccp:Address>
                                    <ccp:Street>1 The Road</ccp:Street>
                                    <ccp:City>Winchester</ccp:City>
                                    <ccp:State>Hampshire</ccp:State>
                                    <ccp:ZipCode>AB1 2CD</ccp:ZipCode>
                                    <ccp:HomePhone>12345678</ccp:HomePhone>
                                </ccp:Address>
                            </ccp:CardOwner>
                        </ccp:CreditCard>                    
                        <ccp:Amount>0.0</ccp:Amount>
                    </ccp:Authorize>
                  </literal>
              </from>
              <to>$authorizeRequestMessage.parameters</to>
          </copy>
          <copy>
              <from>$makePaymentRequestMessage.parameters/CustomerId/text()</from>
              <to>$authorizeRequestMessage.parameters/ccp:CreditCard/ccp:CardOwner/ccp:Name</to>
          </copy>
          <copy>
              <from>$makePaymentRequestMessage.parameters/Amount/text()</from>
              <to>$authorizeRequestMessage.parameters/ccp:Amount</to>
          </copy>                    
       </assign>
       
       
       <invoke name="invokeCreditCardPayment"
               operation="authorize"
               inputVariable="authorizeRequestMessage"
               outputVariable="authorizeResponseMessage"
               partnerLink="creditCardPaymentPartnerLink"
               portType="ccp:CreditCardPayment" />
       
       <!-- set up call to email gateway service -->
       
       <!-- call the email gateway to send a confirmation -->
       
       
       <!-- set up the response -->
       <assign name="assign2">
          <!--copy>
              <from><literal><Status>OK</Status></literal></from>
              <to>$makePaymentResponse</to>
          </copy-->
          <copy>
              <from>$authorizeResponseMessage.parameters</from>
              <to>$makePaymentResponseMessage.parameters</to>
          </copy>
       </assign>
       
       <!-- email a confirmation -->
       
       <reply name="end"  
              partnerLink="paymentProcessPartnerLink"
              portType="pp:PaymentProcess" 
              operation="makePayment"
              variable="makePaymentResponseMessage">
       </reply>
   </sequence>
</process>