Product prod = new Product("Widget", 1.5M); string accessKeyId = ConfigurationSettings.AppSettings["AmazonAccessKeyID"]; string secretAccessKey = ConfigurationSettings.AppSettings["AmazonSecretAccessKey"]; AmazonSQS service = new AmazonSQSClient(accessKeyId, secretAccessKey); SendMessageRequest request = new SendMessageRequest(); request.MessageBody = prod.ToXml(); request.QueueName = "TestQueue"; SendMessageResponse response = service.SendMessage(request); if (response.IsSetSendMessageResult()) { Console.WriteLine("Send Message Response: "); SendMessageResult sendMessageResult = response.SendMessageResult; if (sendMessageResult.IsSetMessageId()) { Console.WriteLine(String.Format("MessageId {0}", sendMessageResult.MessageId)); } if (sendMessageResult.IsSetMD5OfMessageBody()) { Console.WriteLine(String.Format("MD5OfMessageBody: {0}", sendMessageResult.MD5OfMessageBody)); } } |
Product prod = null; string accessKeyId = ConfigurationSettings.AppSettings["AmazonAccessKeyID"]; string secretAccessKey = ConfigurationSettings.AppSettings["AmazonSecretAccessKey"]; AmazonSQS service = new AmazonSQSClient(accessKeyId, secretAccessKey); ReceiveMessageRequest request = new ReceiveMessageRequest(); request.QueueName = "TestQueue"; ReceiveMessageResponse response = service.ReceiveMessage(request); if (response.IsSetReceiveMessageResult()) { Console.WriteLine("Receive Message Result:"); ReceiveMessageResult receiveMessageResult = response.ReceiveMessageResult; List<Message> messageList = receiveMessageResult.Message; foreach (Message message in messageList) { if (message.IsSetMessageId()) { Console.WriteLine(String.Format("MessageId: {0}", message.MessageId)); } if (message.IsSetBody()) { Console.WriteLine(string.Format("Body: {0}", message.Body)); String xml = message.Body; StringReader sr = new StringReader(xml); XmlSerializer serializer = new XmlSerializer(typeof(Product)); prod = (Product) serializer.Deserialize(sr); Console.WriteLine(string.Format("Id: {0}", prod.Id)); Console.WriteLine(string.Format("Name: {0}", prod.ProductName)); Console.WriteLine(string.Format("Price: {0}", prod.ProductPrice)); } } } |
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="PurchaseOrder"> <xs:complexType> <xs:sequence> <xs:element name="Id" type="xs:string" minOccurs="0" /> <xs:element name="OrderDate" type="xs:string" minOccurs="0" /> <xs:element name="Company" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="CompanyName" type="xs:string" minOccurs="0" /> <xs:element name="StreetAddress" type="xs:string" minOccurs="0" /> <xs:element name="City" type="xs:string" minOccurs="0" /> <xs:element name="State" type="xs:string" minOccurs="0" /> <xs:element name="ZipCode" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="Vendor" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="CompanyName" type="xs:string" minOccurs="0" /> <xs:element name="StreetAddress" type="xs:string" minOccurs="0" /> <xs:element name="City" type="xs:string" minOccurs="0" /> <xs:element name="State" type="xs:string" minOccurs="0" /> <xs:element name="ZipCode" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="Items" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="Item" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:attribute name="Id" type="xs:string" /> <xs:attribute name="Name" type="xs:string" /> <xs:attribute name="Quantity" type="xs:string" /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> |
关键元素
|
描述
|
Id
|
包含 Purchase Order 的唯一标识符的字符串
|
OrderDate
|
包含 Purchase Order 日期的字符串
|
Company
|
包含分销商的关键地址信息,包括公司名称、街道地址、城市、州和邮政编码
|
Vendor
|
包含制造商的关键地址信息,包括公司名称、街道地址、城市、州和邮政编码
|
Items
|
包含订购商品的所有信息,包括商品 ID、商品名称和数量
|
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="OrderSummary"> <xs:complexType> <xs:sequence> <xs:element name="OrderId" type="xs:string" minOccurs="0" /> <xs:element name="ReferenceId" type="xs:string" minOccurs="0" /> <xs:element name="OrderDate" type="xs:string" minOccurs="0" /> <xs:element name="CompanyAddress" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="CompanyName" type="xs:string" minOccurs="0" /> <xs:element name="StreetAddress" type="xs:string" minOccurs="0" /> <xs:element name="City" type="xs:string" minOccurs="0" /> <xs:element name="State" type="xs:string" minOccurs="0" /> <xs:element name="ZipCode" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="CustomerAddress" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="CompanyName" type="xs:string" minOccurs="0" /> <xs:element name="StreetAddress" type="xs:string" minOccurs="0" /> <xs:element name="City" type="xs:string" minOccurs="0" /> <xs:element name="State" type="xs:string" minOccurs="0" /> <xs:element name="ZipCode" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="Items" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="Item" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:attribute name="ItemId" type="xs:string" /> <xs:attribute name="ItemName" type="xs:string" /> <xs:attribute name="Quantity" type="xs:string" /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> |
Id
|
包含 Order Summary 的唯一标识符的字符串
|
ReferenceId
|
包含初始 Purchase Order 的 ID 的字符串
|
OrderDate
|
包含 Order Summary 日期的字符串
|
CustomerAddress
|
包含分销商的关键地址信息,包括公司名称、街道地址、城市、州和邮政编码
|
VendorAddress
|
包含制造商的关键地址信息,包括公司名称、街道地址、城市、州和邮政编码
|
Items
|
包含订购商品的所有信息,包括商品 ID、商品名称和数量
|
(责任编辑:)
如今随着企业的信息化水平不断提高,IT系统的规模在不断的扩大,网络结构也日益复杂,...[详细]
经历了几次跳票之后Fedora 18正式版于2013年1月15日面世,凝聚了许多开发者的心血。很...[详细]
.Net环境,上传处未限制Ashx和Asmx,后者上传无法运行,提示Asmx脚本只能在本地运行,...[详细]
随着网络信息安全的需求度提高,个人信息与网络安全逐渐被提上了台面。人们越来越意识...[详细]
目前互联网上的病毒集团越来越猖狂,对用户的危害也愈演愈烈,大家要懂得保护自己的电...[详细]