2017-08-12 22 views
0

我試圖使用Broadleaf API來創建購物車,在消費者應用程序中添加項目和簽出。 克隆演示應用程序和修改的配置按照鏈接: https://www.broadleafcommerce.com/docs/core/current/broadleaf-concepts/rest/rest-tutorialsBroadleaf APIs無法正常工作

問題: 1.創建新Cart-> POST:http://localhost:8080/api/v1/cart 異常:HttpRequestMethodNotSupportedException:請求方法 'POST' 不支持 隨着GET請求:奮力

  • 添加產品編號: POST:http://localhost:8080/api/v1/cart/1?categoryId=1&customerId=100 異常:HttpRequestMethodNotSupportedException:請求方法 'POST' 不支持 ģ ET請求工作,但沒有添加產品。
  • 3.添加付款到Order POST:如在上述URL 異常提到http://localhost:8080/api/v1/cart/checkout/payment?customerId=100 添加了OrderPaymentWrapper在體內: messageKey 「: 」queryParameterNotPresent「, 」消息「:」 COM。 broadleafcommerce.rest.api.exception.BroadleafWebServicesException.queryParameterNotPresent」

    另外,簡稱https://demo.broadleafcommerce.org/api/v2/swagger-ui.html#/調用API按招搖文檔。 同樣的問題,無法創建訂單流。

    我試過通過在本地主機上運行來調試https://github.com/BroadleafCommerce/DemoSite 同樣的問題。

    請指教。

    +0

    您使用的是什麼版本的Broadleaf? 5.2 API(我們的最新版本)在端口8082和8445上監聽,但如果您使用的是8080,則表示您沒有使用最新版本。正確的答案取決於你使用的是什麼版本。 – phillipuniverse

    +0

    謝謝@phillipuniverse。是的,我克隆了最新的Broadleaf spring引導應用程序並運行了API模塊。提到的localhost:8082/api/v1/swagger-ui.html(同上面的問題,例如創建購物車說不支持POST請求)。無法使用API​​創建訂單。請建議我是否缺少任何東西。 –

    回答

    0

    這看起來像是我們的@FrameworkController註釋中的一個突出問題。我在Broadleaf開設了一個問題https://github.com/BroadleafCommerce/Issues/issues/3,並提供更多關於它目前失敗的信息。

    解決方法是在API項目中修改CustomCartEndpoint,您必須在createNewCartForCustomer()方法中添加該項目。 CustomCartEndpoint的最終實現應該如下所示:

    @RestController 
    @RequestMapping(value = "/cart", 
          produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE }) 
    public class CustomCartEndpoint extends CartEndpoint { 
    
        @Override 
        @RequestMapping(value = "", method = RequestMethod.GET) 
        public OrderWrapper findCartForCustomer(HttpServletRequest request) { 
         try { 
          return super.findCartForCustomer(request); 
         } catch (Exception e) { 
          // if we failed to find the cart, create a new one 
          return createNewCartForCustomer(request); 
         } 
        } 
    
        @Override 
        @RequestMapping(value = "", method = RequestMethod.POST) 
        public OrderWrapper createNewCartForCustomer(HttpServletRequest request) { 
         return super.createNewCartForCustomer(request); 
        } 
    }