I need to update MerchantOrderID in Amazon Marketplace via Amazon MWS API using C#.
So, first I created XML file like:
<?xml version="1.0"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>M_STORE_3918753</MerchantIdentifier>
</Header>
<MessageType>OrderAcknowledgement</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderAcknowledgement>
<AmazonOrderID>104-9209939-0469021</AmazonOrderID>
<MerchantOrderID>100828163</MerchantOrderID>
<StatusCode>Success</StatusCode>
<Item>
<AmazonOrderItemCode>11111111111111</AmazonOrderItemCode>
<MerchantOrderItemID>111111</MerchantOrderItemID>
<AmazonOrderItemCode>22222222222222</AmazonOrderItemCode>
<MerchantOrderItemID>222222222</MerchantOrderItemID>
</Item>
</OrderAcknowledgement>
</Message>
</AmazonEnvelope>
then I try to call Amazon MWS SubmitFeed:
SubmitFeedRequest request = new SubmitFeedRequest();
request.Merchant = merchantId;
request.MarketplaceIdList = new IdList();
request.MarketplaceIdList.Id = new List<string>(new string[] { marketplaceId });
request.FeedContent = File.Open(path, FileMode.Open, FileAccess.Read);
request.ContentMD5 = MarketplaceWebServiceClient.CalculateContentMD5(request.FeedContent);
request.FeedContent.Position = 0;
request.FeedType = "_POST_ORDER_ACKNOWLEDGEMENT_DATA_";
MarketplaceWebService.MarketplaceWebService serviceFeed = new MarketplaceWebServiceClient(
accessKeyId,
secretAccessKey,
applicationName,
applicationVersion,
configFeed);
SubmitFeedResponse response = serviceFeed.SubmitFeed(request);
it succesfully submits but when I open my order in Amazon (sellercentral.amazon.com) it says "none saved":
Your Merchant Order ID: # none saved
Who can help me, what is wrong or what should I do?
Thanks!
For those who want to update merchant order id in multiple orders at once, here is example (also works in amazon mws scratchpad):
<?xml version="1.0"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>ALVH0CYWPBFNA</MerchantIdentifier>
</Header>
<MessageType>OrderAcknowledgement</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderAcknowledgement>
<AmazonOrderID>000-0000000-0000000</AmazonOrderID>
<MerchantOrderID>YOUR_MERCHANT_ORDER_ID</MerchantOrderID>
<StatusCode>Success</StatusCode>
</OrderAcknowledgement>
</Message>
<Message>
<MessageID>2</MessageID>
<OrderAcknowledgement>
<AmazonOrderID>000-0000000-0000000</AmazonOrderID>
<MerchantOrderID>YOUR_MERCHANT_ORDER_ID</MerchantOrderID>
<StatusCode>Success</StatusCode>
</OrderAcknowledgement>
</Message>
</AmazonEnvelope>
It's actually right code. Somehow amazon doesn't mark some special orders or marks them later.
Related
var baseAddress = new Uri("http://www.easyredmine.com/");
using (var httpClient = new HttpClient { BaseAddress = baseAddress })
{
using (var response = await httpClient.GetAsync("issues/{id}.xml{?include}"))
{
string responseData = await response.Content.ReadAsStringAsync();
}
}
in this link you can found the API documentation of Redmine:
https://easyredmine.docs.apiary.io/
However, you can take all issue list with this url:
http://www.easyredmine.com/issues.xml
You have to create the model to map the result of the call and then with linq you can filter the list of objects obtained.
The model of reponse is this:
<issues total_count="1" offset="0" limit="25" type="array">
<issue>
<id>765</id>
<project id="71" name="Administration"/>
<tracker id="13" name="Other"/>
<status id="1" name="Planned"/>
<priority id="12" name="High"/>
<author id="5" name="Andrew Smith"/>
<assigned_to id="5" name="Andrew Smith"/>
<subject>issue subject</subject>
<description>
issue description
</description>
<start_date>2014-04-11</start_date>
<due_date>2014-04-11</due_date>
<done_ratio>0</done_ratio>
<estimated_hours>1.0</estimated_hours>
<easy_email_to>test#test.com</easy_email_to>
<easy_email_cc>test#test.com</easy_email_cc>
<created_on>2014-04-11T08:24:47Z</created_on>
<updated_on>2014-04-11T08:24:47Z</updated_on>
<closed_on/>
<sprint id="1" name="Sprint" due_date="2014-04-11"></sprint>
</issue>
</issues>
I think you’ll have to filter through the 'status' field
I need help exporting data into a xml Term Base eXchange format in a aspnet core application.
I am able to successfully export to UTF8 xml but I can't get any resource to help me export to a tbx format.
Thanks
This is my code:
[HttpGet]
public ContentResult ExtractTBX()
{
var movies = _context.Movie;
XmlSerializer serializer = new XmlSerializer(movies.GetType());
string utf8;
using (StringWriter writer = new Utf8StringWriter())
{
serializer.Serialize(writer, movies);
utf8 = writer.ToString();
}
return Content(utf8);
}
private class Utf8StringWriter : StringWriter
{
public override Encoding Encoding => Encoding.UTF8;
}
This is my output:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfMovie xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Movie>
<Id>1</Id>
<Title>When Harry Met Sally</Title>
<ReleaseDate>1989-02-12T00:00:00</ReleaseDate>
<Genre>Romantic Comedy</Genre>
<Price>7.99</Price>
<Rating>R</Rating>
</Movie>
...
</ArrayOfMovie>
This is my desired output:
<?xml version="1.0" encoding="UTF-8"?>
<martif type="TBX" xml:lang="en-US">
<martifHeader>
<fileDesc>
<titleStmt>
<title>CJO 116253 Net Software Engineer (gText)</title>
</titleStmt>
<sourceDesc>
<p>{Your Name}</p>
</sourceDesc>
</fileDesc>
</martifHeader>
<text>
<body>
<termEntry id="1">
<langSet xml:lang="en-US">
<descripGrp>
<descrip type="definition">{Genre}</descrip>
</descripGrp>
<ntig>
<termGrp>
<term id="6">Title</term>
<termNote type="partOfSpeech">{Rating}</termNote>
</termGrp>
</ntig>
</langSet>
</termEntry>
...
</body>
</text>
</martif>
I have a SOAP web service that I need to call in a wide array applications, so I created a service DLL that targets both .net standard 2.0 and .net framework 4.6.1.
The DLL seems to work fine with on Desktop Framework applications, and on Desktop Core applications. However, the behavior on a Xamarin Android project is just slightly off of what the other two are.
A correctly sent message from the other two applications looks like this:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ZBAPI_GOODSMVT_CREATE xmlns="urn:sap-com:document:sap:rfc:functions">
<CODE xmlns="">
<GM_CODE>03</GM_CODE>
</CODE>
<HEADER xmlns="">
<PSTNG_DATE>2019-12-08</PSTNG_DATE>
<DOC_DATE>2019-12-08</DOC_DATE>
</HEADER>
<ITEM xmlns="">
... data here ...
</ITEM>
<RETURN xmlns="">
... data here ...
</RETURN>
</ZBAPI_GOODSMVT_CREATE>
</s:Body>
And the a successfully sent(but not processed) message from the android device is so:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ZBAPI_GOODSMVT_CREATE>
<CODE>
<GM_CODE>03</GM_CODE>
</CODE>
<HEADER>
<PSTNG_DATE>2019-12-08</PSTNG_DATE>
<DOC_DATE>2019-12-08</DOC_DATE>
</HEADER>
<ITEM>
... data here ...
</ITEM>
<RETURN>
... data here ...
</RETURN>
</ZBAPI_GOODSMVT_CREATE>
</s:Body>
So nearly identical, except every namespace inside the body element has been stripped out.
I've confirmed with SOAPUI that All the namespaces are needed, even the blank ones.
The DLL in question is, as stated, a .net standard 2.0, and the service was imported using the vendor provided wsdl file.
inside the DLL code I am calling the service like so:
private void RunRequest(ServiceData payload)
{
var binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Basic;
var address = new EndpointAddress("https:\\serviceaddress.com\service");
new ChannelFactory<ServiceChannel>(binding, address).Using(factory =>
{
factory.Credentials.UserName.UserName = "Uset";
factory.Credentials.UserName.Password = "Pass";
var proxy = factory.CreateChannel();
proxy.Open();
var context = new OperationContext((IClientChannel)proxy);
var prevOpContext = OperationContext.Current;
OperationContext.Current = context;
try
{
var results = proxy.ServiceChannel_CREATEAsync(payload).ConfigureAwait(false).GetAwaiter().GetResult().SerivceChannelResponse;
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(ServiceChannelResponse));
using StringWriter text = new StringWriter();
serializer.Serialize(text, results);
Message = text.ToString();
}
catch
{
throw;
}
});
how can I force the xmlns namespaces inclusion across all platforms?
I am new to using Webservice. I implemented a soap Post action to an external Company. Working great. I now want to start creating my own for people to interact with us. I have created the basic add service as all tutorial etc.
Now I want to create a service that you place orders from. Currently I just write the order to a text file with the PO nr as the file name. Got testing working with submitting just 1 item to it. But I want them to pass it with mutiple items on the call. Here is what I got now.
c#
public struct OrderSystem
{
public string ResultMsg;
}
[WebMethod(MessageName = "Submit Order", Description = "Submit Order")]
public OrderSystem Order(string Custnr,string POnr, string[] Item , int[] qty)
{
using (System.IO.StreamWriter file =
new System.IO.StreamWriter(#"C:\Users\Public\TestFolder\"+POnr+".txt"))
{
file.WriteLine(Custnr);
file.WriteLine(POnr);
for (int i =0; i< Item.Length; i++)
{
file.WriteLine("LineItem" + i +Item[i] + " | "+qty[i]);
}
}
OrderSystem result;
result.ResultMsg = "Complete";
return (result);
}
Current XML way to call it. Not friendly for them to design a Call to me
POST /Orders.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Submit Order"
<?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>
<Submit_x0020_Order xmlns="http://tempuri.org/">
<Custnr>string</Custnr>
<POnr>string</POnr>
<Item>
<string>string</string>
<string>string</string>
</Item>
<qty>
<int>int</int>
<int>int</int>
</qty>
</Submit_x0020_Order>
</soap:Body>
</soap:Envelope>
How I want to make the xml call file to look at.
POST /Orders.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Submit Order"
<?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>
<Submit_x0020_Order xmlns="http://tempuri.org/">
<Custnr>000223</Custnr>
<POnr>988590</POnr>
<ItemList>
<Item>
<ItemNr>1</Item>
<Item>ABC123</Item>
<Qty>2</Qty>
</Item>
<Item>
<ItemNr>2</Item>
<Item>ASC123</Item>
<Qty>45</Qty>
</Item>
<Item>
<ItemNr>3</Item>
<Item>XYZKKF</Item>
<Qty>4</Qty>
</Item>
<Item>
<ItemNr>4</Item>
<Item>FGH789</Item>
<Qty>6</Qty>
</Item>
</ItemList>
</Submit_x0020_Order>
</soap:Body>
</soap:Envelope>
How Can I go about and Change my C# service to handle that XML file.
Thank you in advance
Regards
First of all, don't create new services using ASMX in 2018. It's been deprecated for a couple of years already. Use WCF or Web API.
The solution applies to all technologies. Simply create a class:
public class Item
{
public string ItemNr { get; set; }
public int Quantity { get; set; }
}
And let your service accept a list of that class.
I have an XML file (it's a SOAP request to an SAP ME Service).
The file looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:me="http://sap.com/xi/ME">
<soapenv:Header />
<soapenv:Body>
<me:ShopOrderByBasicDataQuery_sync>
<me:ShopOrderByBasicDataQuery>
<me:ShopOrder>BOXBUILD_LASER_TEST</me:ShopOrder>
<me:SiteRef>
<me:Site>TEST1</me:Site>
</me:SiteRef>
</me:ShopOrderByBasicDataQuery>
</me:ShopOrderByBasicDataQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
Using Paste Special I used Paste XML as Classes and got a number of classes.
I the created a new Envelope object
Envelope shoporder = new Envelope();
EnvelopeBody shoporderBody = new EnvelopeBody();
ShopOrderByBasicDataQuery_sync shoporderSync = new ShopOrderByBasicDataQuery_sync();
ShopOrderByBasicDataQuery_syncShopOrderByBasicDataQuery shoporderDataQuery = new ShopOrderByBasicDataQuery_syncShopOrderByBasicDataQuery();
shoporderSync.ShopOrderByBasicDataQuery = shoporderDataQuery;
shoporderDataQuery.ShopOrder = "BOXBUILD_LASER_TEST";
shoporderDataQuery.SiteRef = new ShopOrderByBasicDataQuery_syncShopOrderByBasicDataQuerySiteRef();
shoporderDataQuery.SiteRef.Site = "TEST1";
shoporderSync.ShopOrderByBasicDataQuery = shoporderDataQuery;
shoporderBody.ShopOrderByBasicDataQuery_sync = shoporderSync;
shoporder.Body = shoporderBody;
string tmp = (string)SoapHelper.SerializeToXmlString(shoporder);
The string tmp contains this (after a bit of formatting)
<?xml version="1.0" encoding="utf-16"?>
<Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<ShopOrderByBasicDataQuery_sync xmlns="http://sap.com/xi/ME">
<ShopOrderByBasicDataQuery>
<ShopOrder>BOXBUILD_LASER_TEST</ShopOrder>
<SiteRef>
<Site>TEST1</Site>
</SiteRef>
</ShopOrderByBasicDataQuery>
</ShopOrderByBasicDataQuery_sync>
</Body>
</Envelope>
Which is not a correct file! What have I done wrong?