| 7473 |
vikram.rag |
1 |
/*******************************************************************************
|
|
|
2 |
* Copyright 2008-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
|
3 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
4 |
*
|
|
|
5 |
* You may not use this file except in compliance with the License.
|
|
|
6 |
* You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
|
|
|
7 |
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
|
8 |
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
|
9 |
* specific language governing permissions and limitations under the License.
|
|
|
10 |
* *****************************************************************************
|
|
|
11 |
*
|
|
|
12 |
* Marketplace Web Service Orders Java Library
|
|
|
13 |
* API Version: 2011-01-01
|
|
|
14 |
*
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
package com.amazonservices.mws.orders.samples;
|
|
|
20 |
|
|
|
21 |
import java.util.List;
|
|
|
22 |
import java.util.ArrayList;
|
|
|
23 |
import com.amazonservices.mws.orders.*;
|
|
|
24 |
import com.amazonservices.mws.orders.model.*;
|
|
|
25 |
import com.amazonservices.mws.orders.mock.MarketplaceWebServiceOrdersMock;
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
*
|
|
|
29 |
* Get Service Status Samples
|
|
|
30 |
*
|
|
|
31 |
*
|
|
|
32 |
*/
|
|
|
33 |
public class GetServiceStatusSample {
|
|
|
34 |
|
|
|
35 |
/**
|
|
|
36 |
* Just add few required parameters, and try the service
|
|
|
37 |
* Get Service Status functionality
|
|
|
38 |
*
|
|
|
39 |
* @param args unused
|
|
|
40 |
*/
|
|
|
41 |
public static void main(String... args) {
|
|
|
42 |
|
|
|
43 |
MarketplaceWebServiceOrders service = new MarketplaceWebServiceOrdersClient(
|
|
|
44 |
OrdersConfig.accessKeyId,
|
|
|
45 |
OrdersConfig.secretAccessKey,
|
|
|
46 |
OrdersConfig.applicationName,
|
|
|
47 |
OrdersConfig.applicationVersion,
|
|
|
48 |
OrdersConfig.config);
|
|
|
49 |
|
|
|
50 |
/************************************************************************
|
|
|
51 |
* Uncomment to try out Mock Service that simulates Marketplace Web Service Orders
|
|
|
52 |
* responses without calling Marketplace Web Service Orders service.
|
|
|
53 |
*
|
|
|
54 |
* Responses are loaded from local XML files. You can tweak XML files to
|
|
|
55 |
* experiment with various outputs during development
|
|
|
56 |
*
|
|
|
57 |
* XML files available under com/amazonservices/mws/orders/mock tree
|
|
|
58 |
*
|
|
|
59 |
***********************************************************************/
|
|
|
60 |
// MarketplaceWebServiceOrders service = new MarketplaceWebServiceOrdersMock();
|
|
|
61 |
|
|
|
62 |
/************************************************************************
|
|
|
63 |
* Setup request parameters and uncomment invoke to try out
|
|
|
64 |
* sample for Get Service Status
|
|
|
65 |
***********************************************************************/
|
|
|
66 |
GetServiceStatusRequest request = new GetServiceStatusRequest();
|
|
|
67 |
request.setSellerId(OrdersConfig.sellerId);
|
|
|
68 |
|
|
|
69 |
// @TODO: set request parameters here
|
|
|
70 |
|
|
|
71 |
invokeGetServiceStatus(service, request);
|
|
|
72 |
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
/**
|
|
|
78 |
* Get Service Status request sample
|
|
|
79 |
* Returns the service status of a particular MWS API section. The operation
|
|
|
80 |
* takes no input.
|
|
|
81 |
*
|
|
|
82 |
* @param service instance of MarketplaceWebServiceOrders service
|
|
|
83 |
* @param request Action to invoke
|
|
|
84 |
*/
|
|
|
85 |
public static void invokeGetServiceStatus(MarketplaceWebServiceOrders service, GetServiceStatusRequest request) {
|
|
|
86 |
try {
|
|
|
87 |
|
|
|
88 |
GetServiceStatusResponse response = service.getServiceStatus(request);
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
System.out.println ("GetServiceStatus Action Response");
|
|
|
92 |
System.out.println ("=============================================================================");
|
|
|
93 |
System.out.println ();
|
|
|
94 |
|
|
|
95 |
System.out.println(" GetServiceStatusResponse");
|
|
|
96 |
System.out.println();
|
|
|
97 |
if (response.isSetGetServiceStatusResult()) {
|
|
|
98 |
System.out.println(" GetServiceStatusResult");
|
|
|
99 |
System.out.println();
|
|
|
100 |
GetServiceStatusResult getServiceStatusResult = response.getGetServiceStatusResult();
|
|
|
101 |
if (getServiceStatusResult.isSetStatus()) {
|
|
|
102 |
System.out.println(" Status");
|
|
|
103 |
System.out.println();
|
|
|
104 |
System.out.println(" " + getServiceStatusResult.getStatus().value());
|
|
|
105 |
System.out.println();
|
|
|
106 |
}
|
|
|
107 |
if (getServiceStatusResult.isSetTimestamp()) {
|
|
|
108 |
System.out.println(" Timestamp");
|
|
|
109 |
System.out.println();
|
|
|
110 |
System.out.println(" " + getServiceStatusResult.getTimestamp());
|
|
|
111 |
System.out.println();
|
|
|
112 |
}
|
|
|
113 |
if (getServiceStatusResult.isSetMessageId()) {
|
|
|
114 |
System.out.println(" MessageId");
|
|
|
115 |
System.out.println();
|
|
|
116 |
System.out.println(" " + getServiceStatusResult.getMessageId());
|
|
|
117 |
System.out.println();
|
|
|
118 |
}
|
|
|
119 |
if (getServiceStatusResult.isSetMessages()) {
|
|
|
120 |
System.out.println(" Messages");
|
|
|
121 |
System.out.println();
|
|
|
122 |
MessageList messages = getServiceStatusResult.getMessages();
|
|
|
123 |
java.util.List<Message> messageList = messages.getMessage();
|
|
|
124 |
for (Message message : messageList) {
|
|
|
125 |
System.out.println(" Message");
|
|
|
126 |
System.out.println();
|
|
|
127 |
if (message.isSetLocale()) {
|
|
|
128 |
System.out.println(" Locale");
|
|
|
129 |
System.out.println();
|
|
|
130 |
System.out.println(" " + message.getLocale());
|
|
|
131 |
System.out.println();
|
|
|
132 |
}
|
|
|
133 |
if (message.isSetText()) {
|
|
|
134 |
System.out.println(" Text");
|
|
|
135 |
System.out.println();
|
|
|
136 |
System.out.println(" " + message.getText());
|
|
|
137 |
System.out.println();
|
|
|
138 |
}
|
|
|
139 |
}
|
|
|
140 |
}
|
|
|
141 |
}
|
|
|
142 |
if (response.isSetResponseMetadata()) {
|
|
|
143 |
System.out.println(" ResponseMetadata");
|
|
|
144 |
System.out.println();
|
|
|
145 |
ResponseMetadata responseMetadata = response.getResponseMetadata();
|
|
|
146 |
if (responseMetadata.isSetRequestId()) {
|
|
|
147 |
System.out.println(" RequestId");
|
|
|
148 |
System.out.println();
|
|
|
149 |
System.out.println(" " + responseMetadata.getRequestId());
|
|
|
150 |
System.out.println();
|
|
|
151 |
}
|
|
|
152 |
}
|
|
|
153 |
System.out.println();
|
|
|
154 |
System.out.println(response.getResponseHeaderMetadata());
|
|
|
155 |
System.out.println();
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
} catch (MarketplaceWebServiceOrdersException ex) {
|
|
|
159 |
|
|
|
160 |
System.out.println("Caught Exception: " + ex.getMessage());
|
|
|
161 |
System.out.println("Response Status Code: " + ex.getStatusCode());
|
|
|
162 |
System.out.println("Error Code: " + ex.getErrorCode());
|
|
|
163 |
System.out.println("Error Type: " + ex.getErrorType());
|
|
|
164 |
System.out.println("Request ID: " + ex.getRequestId());
|
|
|
165 |
System.out.println("XML: " + ex.getXML());
|
|
|
166 |
System.out.print("ResponseHeaderMetadata: " + ex.getResponseHeaderMetadata());
|
|
|
167 |
}
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
}
|