Using the Web Service Notifications

Amazon FPS allows you to handle the asynchronous transaction responses using the web service notification. You can subscribe to the web service notification using the SubscribeForCallerNotification operation. After you subscribe to the notification service, all the asynchronous responses are sent as web service notifications. Asynchronous responses for the transactions executed during this period (after subscribing for the web service notification) are no longer available in the GetResults operation response.

If you want to use the GetResults operation for asynchronous responses again you must unsubscribe to the web service notification. Call the the UnSubscribeForCallerNotification operation to unsubscribe.

The notification functionality allows you to receive notifications after you make a transaction operation or cancel a token. To receive these notifications you must set up and host a web service as described in this topic.

[Important]Important

Amazon FPS sends the notifications only using the HTTPS protocol.

Amazon FPS currently sends the notifications for the transaction operations and token cancellations. The following transaction operations are supported:

Setting Up Your Web Service to Receive Notifications

To build the web service application

  • Implement the web service using the Amazon FPS notification service WSDL. The notification service WSDL is available in the JAVA web service notification sample uploaded in the Amazon FPS Resource center (Community Code category).

    The sample applications in Java SDK uses Apache Axis to generate server side stubs to implement the notification service.

To create server trust store

  1. Your web server's trust store must contain the Amazon FPS notification certificate. Download the sandbox and production X.509 certificates from the Amazon FPS Resource Center (http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=59).

  2. Import the notification service certificate using the keytool.

    keytool -import -file cert.pem -alias alias -keystore keystore_filename -storepass keystore_password

To set up the Tomcat server

  1. You must create a keystore using the AWS X.509 certificate (public) and the private key pair associated with your AWS developer account. You can download these key pairs from the AWS web site (http://aws.amazon.com). These keys are required to set up an SSL connection between Amazon FPS and your service. See the Setting Up Your AWS Developer Account section in the Getting Started Guide for more information.

    [Note]Note

    If you have created a keystore for the SDK application you can use the same keystore for setting up the web service and skip to step 3.

  2. Execute the following command from the folder that contains the private key file and the certificate file:

    openssl pkcs12 -export -inkey  private_key_file_name.pem -in certificate_file_name.pem -name "tomcat" -out keystore

    This creates the keystore.

  3. After you generate the keystore, host the web service on the default HTTPS port (443) on your Tomcat server. An example of the server.xml file (TOMCAT_BASE/conf folder) for setting up the web service on Tomcat is given below.

    ...
    <Connector port="443" maxHttpHeaderSize="8192"
    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" disableUploadTimeout="true"
    acceptCount="100" scheme="https" secure="true"
    clientAuth="false" sslProtocol="TLS"
    keystoreFile="keystore filename" keystorePass="keystore password"
    keystoreType="pkcs12"/>
    ...
  4. Restart Tomcat.

    You web server is now ready to receive notifications from Amazon FPS.

Sample Notification

The following SOAP request is an example notification sent by Amazon FPS to your web server after a Pay operation.

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
	<SOAP-ENV:Header>
		<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" SOAP-ENV:mustUnderstand="1">
		        <wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
                        EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" 
                        ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" 
                        wsu:Id="XWSSGID-1182867517338-658334378">MIICjzCCAXcCAgZGMA0GCSqGSIb3DQEBBQUAMDkxIjAgBgNVBAMTGUFtYXpvbi5jb20gSVQgU2Vj
                        dXJpdHkgQ0ExEzARBgNVBAoTCkFtYXpvbi5jb20wHhcNMDcwNDA5MTExNzQ5WhcNMTIwNDA4MTExNzQ5WjBlMQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2
                        FzaGluZ3RvbjEYMBYGA1UEChMPQW1hem9uLmNvbSBJbmMuMScwJQYDVQQDEx5mcHMtbm90aWZzZXJ2aWNlLmFtYXpvbmF3cy5jb20wgZ8wDQYJKoZIhvcN
                        AQEBBQADgY0AMIGJAoGBALBZncasOW4eObM2ZbVEs50IzDbJe8inZ+SUE+/KIWiVSk5VvHXu6aTBw8eKCC2pAaxDBktnXZdTqW8kVUexUVyvZ2Mbw1m5I+
                        9B7rDIWal11moRxEvBlbWfKaA/eyHtH+zq053OsHFGQ+2iofYKIb8GWgJ2SjaJioC5ds7UjtN7AgMBAAEwDQYJKoZIhvcNAQEFBQADggEBALWRYBv/WNxv
                        0g+JKIGo3tgRnccQ0FfuTlsvzLd6ZRvTfltKX2WL4pQsf4ZF/yqA41ZSLC3ca5OKhiEcQrNWnBRmQPIwuVw3FESylfl/ymAJ93yuFtg3TL6F0eyQP6Sn2q
                        DODIdevJfII5qsaj+Nt0xkCSesFTq7UVfyIDCnPVJqPvX3YafYLZUbXMhFdIeT5LXyhVyKwWWZfzDSZuJZjpg6w2d5fFIWVm+C5YDPggsDhyZoxwIKVp13
                        HYpyhw+5S8/FNmKfoGbCkz462Y2n95gASrQtXMIgYfF0xQ+1dDC+OAuRvkmAwUApaPiz6H/3sRB9/J/UKOPkrBY6nWmvFWc=
                        </wsse:BinarySecurityToken>
                        <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
			        <ds:SignedInfo>
			        	<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
				        	<InclusiveNamespaces xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="wsse SOAP-ENV"/>
                                        </ds:CanonicalizationMethod>
                                        <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
                                        <ds:Reference URI="#XWSSGID-1182867517343-1343126905">
					        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                                                <ds:DigestValue>qaYXYFqSz8Gg4whrN3ZIF32sE5k=</ds:DigestValue>
                                        </ds:Reference>
                                        <ds:Reference URI="#XWSSGID-11828675173431600396273">
					        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                                                <ds:DigestValue>wtZ2j+DBvYhDOlXSPNxqIH7GqG8=</ds:DigestValue>
                                        </ds:Reference>
                                 </ds:SignedInfo>
                                 <ds:SignatureValue>
                                         HxC16F/yMDeLk+rXGx8p7s18iitnrmhloqFSWWSmcForyrp8GBYEmJ5BhpXb9H0b51N0k4EDxVTr
                                         TR4sFD4W4Gl+zkBZcPSO7Kfq6Qd7NjgpjQf3plTTCQBIWE8vMXv5Er5HlX79tz9NFHwn88QbfcnK
                                         qtNXYnHDfQhzcgsWTHg=
                                 </ds:SignatureValue>
                                 <ds:KeyInfo>
                                        <wsse:SecurityTokenReference xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
                                        wsu:Id="XWSSGID-1182867517342-1418216523">
					<wsse:Reference URI="#XWSSGID-1182867517338-658334378" ValueType=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
				</wsse:SecurityTokenReference>
			</ds:KeyInfo>
                </ds:Signature>
                <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="XWSSGID-11828675173431600396273">
                      <wsu:Created>2007-06-26T14:18:37Z</wsu:Created>
                      <wsu:Expires>2007-06-26T14:18:42Z</wsu:Expires>
                 </wsu:Timestamp>
		</wsse:Security>
	</SOAP-ENV:Header>
	<SOAP-ENV:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="XWSSGID-1182867517343-1343126905">
		<TransactionResult xmlns="http://notifservice.amazonaws.com/doc/2005-10-15/">
			<TransactionId>12DK6BJOD5BOE7GZF8N54DP67OP5NE2F4VQ</TransactionId>
			<OperationType>Pay</OperationType>
			<CallerReference>ReferenceStringŭŴŻŕuC8j11828675090491</CallerReference>
			<TransactionStatus>SUCCESS</TransactionStatus>
		</TransactionResult>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>