Amazon MWS Update tracking number - c#

I am using amazon api for update product's quantity using "POST_FULFILLMENT_ORDER_REQUEST_DATA"
feedtype
in https://mws.amazonservices.com/scratchpad/index.html like ,
<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>ATVPDKIKX0DER</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<AmazonOrderID>XXXXX</AmazonOrderID>
<FulfillmentDate>2020-09-12T11:00:00</FulfillmentDate>
<FulfillmentData>
<CarrierName>USPS</CarrierName>
<ShippingMethod>Standard</ShippingMethod>
<ShipperTrackingNumber>1234562312312</ShipperTrackingNumber>
</FulfillmentData>
</OrderFulfillment>
</Message>
</AmazonEnvelope>
I have tried add with suggest Oneida:
<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>ATVPDKIKX0DER</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<AmazonOrderID>XXX</AmazonOrderID>
<FulfillmentDate>2020-09-03T21:38:00+00:00</FulfillmentDate>
<FulfillmentData>
<CarrierCode>UPS</CarrierCode>
<ShippingMethod>Second Day</ShippingMethod>
<ShipperTrackingNumber>1234567890</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<AmazonOrderItemCode>XXX</AmazonOrderItemCode>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>
</AmazonEnvelope>
But I got same error Invalid creation request.
<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.02</DocumentVersion>
<MerchantIdentifier>XXXXXXXXX</MerchantIdentifier>
</Header>
<MessageType>ProcessingReport</MessageType>
<Message>
<MessageID>1</MessageID>
<ProcessingReport>
<DocumentTransactionID>XXXX</DocumentTransactionID>
<StatusCode>Complete</StatusCode>
<ProcessingSummary>
<MessagesProcessed>1</MessagesProcessed>
<MessagesSuccessful>0</MessagesSuccessful>
<MessagesWithError>1</MessagesWithError>
<MessagesWithWarning>0</MessagesWithWarning>
</ProcessingSummary>
<Result>
<MessageID>0</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>920001</ResultMessageCode>
<ResultDescription>Invalid creation request</ResultDescription>
</Result>
</ProcessingReport>
</Message>
</AmazonEnvelope>
Can anyone help me?
Thanks in advance.

You are leaving out the Item element ...
<MessageID>#</MessageID>
<OperationType>Update</OperationType>
<OrderFulfillment>
<AmazonOrderID>###-#######-#######</AmazonOrderID>
<FulfillmentDate>2020-09-09T00:00:00.00Z</FulfillmentDate>
<FulfillmentData>
<CarrierName>##Carrier##</CarrierName>
<ShippingMethod>##Method##</ShippingMethod>
<ShipperTrackingNumber>##TrackNum##</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<AmazonOrderItemCode>##ItemCode##</AmazonOrderItemCode>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>

Related

Removing Attribute value based on value from an XML using VB.Net

I have an XML as below
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope
xmlns="http://com/uhg/uht/uhtSoapMsg_V1"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<uhtHeader
xmlns="http://com/uhg/uht/uhtHeader_V1">
<consumer>COMET</consumer>
<auditId></auditId>
<sendTimestamp>2020-09-03T18:15:40.942-05:00</sendTimestamp>
<environment>P</environment>
<businessService version="24">getClaimHistory</businessService>
<status>success</status>
</uhtHeader>
</env:Header>
<env:Body>
<srvcRspn
xmlns="http://com/uhg/uht/getClaimHistory_V24">
<srvcErrList arrayType="srvcErrOccur[1]" type="Array">
<srvcErrOccur>
<orig>Foundation</orig>
<rtnCd>00</rtnCd>
<explCd>000</explCd>
<desc></desc>
</srvcErrOccur>
</SrvcErrList>
</srvcRspn>
</env:Body>
</env:Envelope>
I want to remove all the attribute values with "http" like below:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope
xmlns=""
xmlns:env="">
<env:Header>
<uhtHeader
xmlns="">
<consumer>COMET</consumer>
<auditId></auditId>
<sendTimestamp>2020-09-03T18:15:40.942-05:00</sendTimestamp>
<environment>P</environment>
<businessService version="24">getClaimHistory</businessService>
<status>success</status>
</uhtHeader>
</env:Header>
<env:Body>
<srvcRspn
xmlns="">
<srvcErrList arrayType="srvcErrOccur[1]" type="Array">
<srvcErrOccur>
<orig>Foundation</orig>
<rtnCd>00</rtnCd>
<explCd>000</explCd>
<desc></desc>
</srvcErrOccur>
</SrvcErrList>
</srvcRspn>
</env:Body>
</env:Envelope>
I have tried several ways but none of them has worked for me. Can anyone suggest what is fastest way to do it in VB.NET/C#.
The actual response is very large (approx 100000 lines of XML minimum) and using for each will consume a good amount of time. Is there any parsing method or LINQ query method which can do it faster.
I got the way to do it using Regex as below:
Return Regex.Replace(xmlDoc, "((?<=<|<\/)|(?<= ))[A-Za-z0-9]+:| xmlns(:[A-Za-z0-9]+)?="".*?""", "")
It serves my purpose completely. Thanks Cleptus for your quick reference.

VS Generated WSDL Namespace Issues

Good Afternoon,
We have been trying to consume a Carrier API, but have hit some issue with the WSDL Generation. The Example XML message the company has provided has ns1-3 and appears that it is important for the address fields. the XML generated from their WSDL seems to generate the same fields but has no name spaces like the original and fails with "Address details are invalid", Is there some setting we are missing so that it generates the correct XML?
This is their Example XML
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns3:CreateLabel xmlns:ns3="http://courier.ck.dx.metafour.com/" xmlns:ns2="http://www.thedx.co.uk/eai/canonical/types/v2.0">
<order>
<ns2:customerID>14337622</ns2:customerID>
<ns2:dates>
<date format="yyyy-MM-dd HH:mm:ss" type="requestedCollectionDate">2018-12-12 17:59:21</date>
</ns2:dates>
<sourceSystemReference xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">AMS207554</sourceSystemReference>
<customerReference xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">286956</customerReference>
<orderAttributes xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0" xsi:nil="true" />
<ns2:orderLines>
<ns2:consignment>
<pieces>
<dimensions>
<value>1.0</value>
<type>cdlWeight</type>
<UOM>KG</UOM>
</dimensions>
<barcode xsi:nil="true" />
<trackingNumber xsi:nil="true" />
</pieces>
<qty>1</qty>
<legacyService>
<name>serviceLevel</name>
<partyId>0</partyId>
<partyType>HITS</partyType>
</legacyService>
<legacyService>
<name>serviceType</name>
<partyId>2</partyId>
<partyType>HITS</partyType>
</legacyService>
<deliverTo>
<ns2:address primary="true">
<organisationName>Argos</organisationName>
<addressLine1>Argos</addressLine1>
<addressLine2>Argos Ltd</addressLine2>
<addressLine3>11 Canning Street</addressLine3>
<city>BURNLEY</city>
<postalCode>BB12 0AD</postalCode>
<country>
<countryCode>GB</countryCode>
<description>GB</description>
</country>
</ns2:address>
<contact />
</deliverTo>
</ns2:consignment>
</ns2:orderLines>
<labelType>ZPL</labelType>
</order>
<serviceHeader>
<password>test</password>
<userId>test</userId>
</serviceHeader>
</ns3:CreateLabel>
</s:Body>
</s:Envelope>
This is our Generated XML
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CreateLabel xmlns="http://courier.ck.dx.metafour.com/">
<order xmlns="">
<customerID xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">14337622</customerID>
<dates xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">
<date xmlns="" format="yyyy-MM-dd HH:mm:ss" type="requestedCollectionDate">2019-01-25 10:17:33</date>
</dates>
<sourceSystemReference xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">AMS207554</sourceSystemReference>
<customerReference xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">286956</customerReference>
<orderAttributes xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0" xsi:nil="true" />
<orderLines xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">
<consignment>
<pieces xmlns="">
<dimensions>
<value>1.0</value>
<type>cdlWeight</type>
<UOM>KG</UOM>
</dimensions>
<barcode xsi:nil="true" />
<trackingNumber xsi:nil="true" />
</pieces>
<qty>1</qty>
<legacyService xmlns="">
<name>serviceLevel</name>
<partyId>0</partyId>
<partyType>HITS</partyType>
</legacyService>
<legacyService xmlns="">
<name>serviceType</name>
<partyId>2</partyId>
<partyType>HITS</partyType>
</legacyService>
<deliverTo xmlns="">
<address xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">
<organisationName xmlns="">Argos</organisationName>
<addressLine1 xmlns="">Argos</addressLine1>
<addressLine2 xmlns="">Argos Ltd</addressLine2>
<addressLine3 xmlns="">11 Canning Street</addressLine3>
<city xmlns="">BURNLEY</city>
<postalCode xmlns="">BB12 0AD</postalCode>
<country xmlns="">
<countryCode>GB</countryCode>
<description>GB</description>
</country>
</address>
<contact xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0" />
</deliverTo>
</consignment>
</orderLines>
<labelType>ZPL</labelType>
</order>
<serviceHeader xmlns="">
<password>test</password>
<userId>test</userId>
</serviceHeader>
</CreateLabel>
</s:Body>
</s:Envelope>
Any help would be greatly appreciated!
This is resolved,
I could not figure out a way to change or add additional namespace to the generated references.cs file, and ended up sending the SOAP to their server manually with an XML string serialized using a httpWebRequest and XmlSerializer

EWS - determine if an attendee is a room or resource instead of a person

Given an Attendee in EWS, how can I determine if that attendee is a room or a resource, instead of a person?
The first thing would be just check if the Attendee is in the Resources Strongly typed property https://msdn.microsoft.com/en-us/library/exchangewebservices.calendaritemtype.resources(v=exchg.80).aspx if your getting a Calendar Item using EWS this is where Rooms and Resources will be returned vs Required and optional attendees.
If the Attendee is in the Global Address list and you have 2013 or greater then you can also use FindPeople and check the PersonaType returned eg
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
</soap:Header>
<soap:Body >
<m:FindPeople>
<m:PersonaShape>
<t:BaseShape>Default</t:BaseShape>
</m:PersonaShape>
<m:IndexedPageItemView BasePoint="Beginning" MaxEntriesReturned="100" Offset="0"/>
<m:ParentFolderId>
<t:DistinguishedFolderId Id="directory"/>
</m:ParentFolderId>
<m:QueryString>Adams#ddddd.onmicrosoft.com</m:QueryString>
</m:FindPeople>
</soap:Body>
</soap:Envelope>
should return something like the following for a room
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="15" MinorVersion="1" MajorBuildNumber="629" MinorBuildNumber="8" Version="V2016_07_13" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</s:Header>
<s:Body>
<FindPeopleResponse ResponseClass="Success" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ResponseCode>NoError</ResponseCode>
<People>
<Persona xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
<PersonaId Id="AAUQAGDlxBsmUDpClBbAI1WX04o=" />
<PersonaType>Room</PersonaType>
<CreationTime>0001-01-02T00:00:00Z</CreationTime>
<DisplayName>Conf Room Adams</DisplayName>
<DisplayNameFirstLast>Conf Room Adams</DisplayNameFirstLast>
<DisplayNameLastFirst>Conf Room Adams</DisplayNameLastFirst>
<FileAs />
<EmailAddress>
<Name>Conf Room Adams</Name>
<EmailAddress>Adams#dddddd.onmicrosoft.com</EmailAddress>
<RoutingType>SMTP</RoutingType>
<MailboxType>Mailbox</MailboxType>
</EmailAddress>
<EmailAddresses>
<Address>
<Name>Conf Room Adams</Name>
<EmailAddress>Adams#dddddd.onmicrosoft.com</EmailAddress>
<RoutingType>SMTP</RoutingType>
<MailboxType>Mailbox</MailboxType>
</Address>
</EmailAddresses>
<RelevanceScore>2147483647</RelevanceScore>
</Persona>
</People>
<TotalNumberOfPeopleInView>0</TotalNumberOfPeopleInView>
<FirstMatchingRowIndex>0</FirstMatchingRowIndex>
<FirstLoadedRowIndex>0</FirstLoadedRowIndex>
</FindPeopleResponse>
</s:Body>
</s:Envelope>

Convert XML Dom Structure while deserialization

I have to transform the XML DOM structure into another XML DOM structure, How can I perform it using custom serialization implemented via IXmlSerialization. The source and target XML structure are mentioned as below
Source XML
<?xml version="1.0"?>
<ConfigFileRoot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<DeviceConnectionParams>
<DeviceConnectionParam>
<UserId>administrator</UserId>
<Password>B670AAB84F449BF3953C5ABE947DEF0C</Password>
<IsManual>True</IsManual>
</DeviceConnectionParam>
</DeviceConnectionParams>
<AlarmMappings>
<Enabled>true</Enabled>
<AlarmA>
<Events>
<EventId>
<PanelId>1</PanelId>
<PanelName>TestAccess</PanelName>
<DeviceId>65</DeviceId>
<DeviceName>TestPanel</DeviceName>
</EventId>
<EventId>
<PanelId>1</PanelId>
<PanelName>TestAccess</PanelName>
<DeviceId>65</DeviceId>
<DeviceName>TestPanel</DeviceName>
</EventId>
</Events>
</AlarmA>
<AlarmB>
<AlarmId>0a103f2b3ce7498c4fcaafb965c742cca66a221027054490eab5459689303bbea1f81898380c</AlarmId>
<NvrUuid>0a1027054490eab5459689303bbea1f818983801</NvrUuid>
</AlarmB>
</AlarmMappings>
</ConfigFileRoot>
Target XML
<?xml version="1.0"?>
<ConfigFileRoot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<DeviceConnectionParams>
<DeviceConnectionParam>
<UserId>administrator</UserId>
<Password>B670AAB84F449BF3953C5ABE947DEF0C</Password>
<IsManual>True</IsManual>
</DeviceConnectionParam>
</DeviceConnectionParams>
<AlarmMappings>
<Enabled>true</Enabled>
<AlarmA>
<Events>
<EventId>
<PanelId>1</PanelId>
<PanelName>TestAccess</PanelName>
<DeviceId>65</DeviceId>
<DeviceName>TestPanel</DeviceName>
</EventId>
</Events>
</AlarmA>
<AlarmB> <AlarmId>0a103f2b3ce7498c4fcaafb965c742cca66a221027054490eab5459689303bbea1f81898380c</AlarmId>
<NvrUuid>0a1027054490eab5459689303bbea1f818983801</NvrUuid>
</AlarmB>
</AlarmMappings>
<AlarmMappings>
<Enabled>true</Enabled>
<AlarmA>
<Events>
<EventId>
<PanelId>1</PanelId>
<PanelName>TestAccess</PanelName>
<DeviceId>65</DeviceId>
<DeviceName>TestPanel</DeviceName>
</EventId>
</Events>
</AlarmA>
<AlarmB>
<AlarmId>0a103f2b3ce7498c4fcaafb965c742cca66a221027054490eab5459689303bbea1f81898380c</AlarmId>
<NvrUuid>0a1027054490eab5459689303bbea1f818983801</NvrUuid>
</AlarmB>
</AlarmMappings>
</ConfigFileRoot>

Remove the response wrapper from web service response?

Is it possible to remove the what appears to be automatic notificationRequestResponse node from the response?
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
...
<soap:Body>
<notificationRequestResponse xmlns="...">
<notificationResponse xmlns="...">
<success xmlns="">boolean</success>
<fault xmlns="">
...
</fault>
</notificationResponse>
</notificationRequestResponse>
</soap:Body>
</soap:Envelope>
I need to return the below:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
...
<soap:Body>
<notificationResponse xmlns="...">
<success xmlns="">boolean</success>
<fault xmlns="">
...
</fault>
</notificationResponse>
</soap:Body>
</soap:Envelope>
I want the notificationResponse to be the root of the response!
The WebMethod currently has no logic but:
return new notificationResponse()
Where is the notificationRequestResponse coming from? I can rename it using WebMethod SoapDocumentMethod(ResponseElementName="new name") but I want it gone. Working to a provided spec and have no choice.
Appreciated.
Found the answer...
SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Bare)

Categories