我需要将eBay订单标记为通过eBay API发送。
有方法:
public void ShippEbayOrder(EbayOrder ebayOrder)
{
string Developer = WebConfigurationManager.AppSettings["EbayProductionDevID"];
string Application = WebConfigurationManager.AppSettings["EbayProductionAppID"];
string Certificate = WebConfigurationManager.AppSettings["EbayProductionCertID"];
string eBayToken = WebConfigurationManager.AppSettings["EbayProductionUserToken"];
string SoapApiServerUrl = WebConfigurationManager.AppSettings["EbayProductionApiServerUrl"];
string SignInUrl = WebConfigurationManager.AppSettings["EbayProductionSignInUrl"];
string EPSServerUrl = WebConfigurationManager.AppSettings["EbayProductionEPSUrl"];
var ebayService = GetebayService();
CompleteSaleRequestType completeSaleRequestType = new CompleteSaleRequestType();
completeSaleRequestType.Version = version;
if (ebayOrder.ContainsOrderType == EbayOrder.OrderType.Transaction)
{
completeSaleRequestType.TransactionID = ebayOrder.SourceOrderId;
completeSaleRequestType.ItemID = ebayOrder.ItemsInfo[0].SourceItemId;
}
else
completeSaleRequestType.OrderID = ebayOrder.SourceOrderId;
completeSaleRequestType.Shipped = true;
completeSaleRequestType.ShippedSpecified = true;
CompleteSaleResponseType completeSaleResponseType = ebayService.CompleteSale(completeSaleRequestType);
但是当代码调用CompleteSale方法时,它会抛出一个exeption:
java.lang.ClassCastException: com.ebay.domain.apisoap.pres.service.hosting.soap.basecomponents.GetSellerTransactionsResponseType incompatible with com.ebay.domain.apisoap.pres.service.hosting.soap.basecomponents.CompleteSaleResponseType
谁能帮帮我?谢谢!
答案 0 :(得分:0)
正确的代码和方法应该是:
public void ShippEbayOrder(EbayOrder ebayOrder)
{
string Developer = WebConfigurationManager.AppSettings["EbayProductionDevID"];
string Application = WebConfigurationManager.AppSettings["EbayProductionAppID"];
string Certificate = WebConfigurationManager.AppSettings["EbayProductionCertID"];
string eBayToken = WebConfigurationManager.AppSettings["EbayProductionUserToken"];
string SoapApiServerUrl = WebConfigurationManager.AppSettings["EbayProductionApiServerUrl"];
string SignInUrl = WebConfigurationManager.AppSettings["EbayProductionSignInUrl"];
string EPSServerUrl = WebConfigurationManager.AppSettings["EbayProductionEPSUrl"];
var ebayService = new eBayAPIInterfaceService();
string version = "551";
string requestUrl = SoapApiServerUrl + "?callname=CompleteSale&siteid=0"
+ "&appid=" + Application + "&version=" + version + "&routing=default";
ebayService.Url = requestUrl;
ebayService.RequesterCredentials = new CustomSecurityHeaderType();
ebayService.RequesterCredentials.Credentials = new UserIdPasswordType();
ebayService.RequesterCredentials.Credentials.AppId = Application;
ebayService.RequesterCredentials.Credentials.DevId = Developer;
ebayService.RequesterCredentials.Credentials.AuthCert = Certificate;
ebayService.RequesterCredentials.eBayAuthToken = eBayToken;
CompleteSaleRequestType completeSaleRequestType = new CompleteSaleRequestType();
completeSaleRequestType.Version = version;
if (ebayOrder.ContainsOrderType == EbayOrder.OrderType.Transaction)
{
completeSaleRequestType.TransactionID = ebayOrder.SourceOrderId;
completeSaleRequestType.ItemID = ebayOrder.ItemsInfo[0].SourceItemId;
}
else
completeSaleRequestType.OrderID = ebayOrder.SourceOrderId;
completeSaleRequestType.Shipped = true;
completeSaleRequestType.ShippedSpecified = true;
CompleteSaleResponseType completeSaleResponseType = ebayService.CompleteSale(completeSaleRequestType);
}