头图

wrong information:

 {
    "errors": [
        {
            "message": "There is no resource for path /occ/v2/powertools/xxx/",
            "type": "UnknownResourceError"
        }
    ]
}

You can use @SecurePortalUnauthenticatedAccess to bypass the Authorization check.

The help documentation for this annotation can be found on the SAP official website .

Commerce Cloud introduced an annotation called SecurePortalUnauthenticatedAccess to keep the list of OCC endpoints public. You can also add annotations to endpoints that you think should be publicly accessible.

OCC does not use sessions. This means that the JSESSIONID cookie can (and should) be ignored. In order to access resources from a specific user, the URL convention described below needs to be followed:

https://localhost:9002/rest/v2/{baseSiteID}/users/{userID}/...

Valid user ids:

  • anonymous
    Anonymous user.
  • ${uid} :ID of the registered user.

Example: GET https://localhost:9002/rest/v2/wsTest/users/username@emai.com/addresses

A cache sits between one or more web servers (also called origin servers) and one or more clients, and monitors requests for incoming, saving copies of responses, such as HTML pages, images, and files. Then, if another request is made to the same URL, it can use one of the responses collected instead of requesting it from the origin server again. The following describes how to use caching in OCC. It provides detailed information about client-side caching and server-side caching.

The webservicescommons extension defines the @CacheControl annotation, which can be used to generate a Cache-Control Header in response. If you want to enable client-side caching for a specific method or an entire controller, just annotate it with @CacheControl and specify the appropriate directive. An example of annotation usage can be noticed in the ProductsController.java class:

 @RequestMapping(value = "/{productCode}", method = RequestMethod.GET)
    @CacheControl(directive = CacheControlDirective.PRIVATE, maxAge = 120)
    @ResponseBody
    public ProductWsDTO getProductByCode(@PathVariable final String productCode,
            @RequestParam(defaultValue = DEFAULT_FIELD_SET) final String fields)
    {
     ...
    }

Note: Since the Cache-Control annotation only applies to the GET and HEAD methods, it does not affect any other request methods.

The @CacheControl annotation only works when CacheControlHandlerInterceptor is added to the mvc interceptor.

 <mvc:interceptors>
        <bean class="de.hybris.platform.webservicescommons.interceptors.CacheControlHandlerInterceptor"/>
    </mvc:interceptors>

Spring cache configuration can be found in the following file: ycommercewebservices/web/webroot/WEB-INF/config/cache-config-spring.xml.

Caching must be enabled. This can be done using the <cache:annotation-driven> element. This element also allows to define the default key generator and cache manager that will be used for caching.


注销
1k 声望1.6k 粉丝

invalid