おはようございます。誰かこれを見て、なぜ私が反応しか得られないのかを理解していただけないでしょうか。
{"d":"success : False, message : "}
理想的には、応答を取得したいと思います。
{"success" : true, "message" : "***Message Here***"}
以下は私のコードです...
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string CheckFeedSubmission()
{
string responseText = "";
bool responseSuccess = false;
try
{
aboDataDataContext dc = new aboDataDataContext();
List<string> id = (from fl in dc.feedLogs where fl.feedStatus == "_SUBMITTED_" select fl.feedSubmissionId).ToList();
foreach (var submissionId in id)
{
try
{
MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();
config.ServiceURL = "https://mws.amazonservices.co.uk";
config.SetUserAgentHeader("twe-amazon-mws", "1.0", "c#");
MarketplaceWebService.MarketplaceWebService service = new MarketplaceWebServiceClient(accesskeyID, secretkey, config);
GetFeedSubmissionResultRequest request = new GetFeedSubmissionResultRequest();
MemoryStream ms = new MemoryStream();
request.Merchant = merchantID;
request.Marketplace = marketids[0];
request.FeedSubmissionId = submissionId;
request.FeedSubmissionResult = ms;
try
{
GetFeedSubmissionResultResponse resp = service.GetFeedSubmissionResult(request);
if (resp.IsSetGetFeedSubmissionResultResult() == false)
{
responseText = "IsSetGetFeedSubmissionResultResult=false";
responseSuccess = false;
}
else
{
StreamReader sr = new StreamReader(ms);
string srs = sr.ReadToEnd();
XmlDocument doc = new XmlDocument();
doc.LoadXml(srs);
try
{
feedLog feedUpdate = dc.feedLogs.Single(l => l.feedSubmissionId == submissionId);
feedUpdate.feedStatus = "_" + doc.SelectSingleNode("/AmazonEnvelope/Message/ProcessingReport/StatusCode").InnerText.ToUpper().ToString() + "_";
feedUpdate.totalProcessed = Convert.ToInt32(doc.SelectSingleNode("/AmazonEnvelope/Message/ProcessingReport/ProcessingSummary/MessagesProcessed").InnerText);
feedUpdate.sucessfulPublish = Convert.ToInt32(doc.SelectSingleNode("/AmazonEnvelope/Message/ProcessingReport/ProcessingSummary/MessagesSuccessful").InnerText);
feedUpdate.publishwithErrors = Convert.ToInt32(doc.SelectSingleNode("/AmazonEnvelope/Message/ProcessingReport/ProcessingSummary/MessagesWithError").InnerText);
feedUpdate.publishwithWarning = Convert.ToInt32(doc.SelectSingleNode("/AmazonEnvelope/Message/ProcessingReport/ProcessingSummary/MessagesWithWarning").InnerText);
feedUpdate.feedResponseXML = doc.InnerXml.ToString();
if (doc.SelectSingleNode("/AmazonEnvelope/Message/ProcessingReport/StatusCode").InnerText.ToUpper().ToString() == "COMPLETE")
{
try
{
dc.tweProducts.Where(p => p.feedSubmitId == submissionId).ToList().ForEach(i => i.prodPublished = 1);
}
catch (Exception ee) { responseSuccess = false; responseText = "db update tweProducts exception:" + ee.Message; }
}
dc.SubmitChanges();
}
catch (Exception ex) { responseSuccess = false; responseText += "\n db update feedLog exception : " + ex.Message; }
XDocument pxerror = XDocument.Parse(srs);
var results = pxerror.Root.Descendants("Result")
.Where(p => p.Element("ResultCode").Value == "Error");
if (results != null)
{
foreach (var t in results)
{
publishError perrors = new publishError();
{
try
{
var resultCode = t.Element("ResultMessageCode").Value;
var resultDescription = t.Element("ResultDescription").Value;
var sku = t.Element("AdditionalInfo").Element("SKU").Value;
perrors.sku = sku;
perrors.errorId = resultCode;
perrors.description = resultDescription;
perrors.feedSubmissionId = submissionId;
perrors.errorResolved = false;
dc.publishErrors.InsertOnSubmit(perrors);
dc.SubmitChanges();
}
catch (Exception ex) { responseSuccess = false; responseText += "db update publishError exception: " + ex.Message; }
}
}
}
#endregion
responseSuccess = true;
responseText = "Complete";
}
}
catch (Exception ex) { responseSuccess = false; responseText = "GetFeedSubmissionResultResponse error" + ex.Message; }
}
catch (MarketplaceWebServiceException ex) { responseSuccess = false; responseText = "starts MarketplaceWebServiceConfig, exception message:" + ex.Message + ",status code:" + ex.StatusCode; }
}
}
catch (Exception ex) { responseSuccess = false; responseText = "starts at aboDataDataContext, exception message:" + ex.Message; }
return "success : " + responseSuccess + ", message : " + responseText ;
}
}
これは私の前の質問のフォローアップです - How to return JSON from webservice
また、コードを改善する方法があれば教えてください:)
事前に感謝します。