2012-07-30 117 views
1

我需要通過eBay API標記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

什麼'ebayService.CompleteSale'回報,因爲它顯然不是一個'CompleteSaleResponseType'我們需要更多的信息。 – 2012-07-30 13:14:17

+0

它返回CompleteSaleResponseType對象 – ihorko 2012-07-30 13:33:25

回答

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); 
    } 
相關問題