Saturday, April 20, 2013

ByPassHttpAdapter | XML post to commerce URL

This is a very useful extension when you need to build an extension where if SOAP is not accepted and authToken based authentication is not an option for inbound request.
if you want an external site to post XML into commerce. This would be a good approach.

Sample code and wc-server.xml

public class BypassHttpProgramAdapterImpl extends HttpProgramAdapterImpl implements
HttpAdapter, HttpAdapterFactory {

/*override the method to return a null if bypass condition is true, you can add bypass condition as a custom XML element in wc-server.xml*/
public HttpAdapter createAdapter(HttpServletRequest request, HttpServletResponse  response, TypedProperty param ) {
    //check for extension code.


      factoryClassname="com.custom.programadapter.XXBypassHttpProgramAdapterImpl" name="XML/HTTP">
        <SessionContext ....
          supportedCharacterEncoding="ISO8859-1, UTF-8, utf-8"
          supportedContentTypes="text/xml, text/xml; charset=UTF-8, text/xml-SOAP, text/xml; charset=utf-8"
          supportedMessageMappers="WCS.SOAPINTEGRATION, WCS.INTEGRATION" supportedMethods="POST, M-POST"/>

Thursday, April 11, 2013

Pros and Cons of Ajax

Ajax Simplified: I have been meaning to put this together, even for my own understanding and pros and cons and the SEO impact of using Ajax.

1. Ajax does a great job of not fully loading the page, so refresh smaller areas/faster
2. A lot of fancy things auto complete\Edit in place\ratings\RSS reader and also sorts of gimmicks.
3. On refresh, it does not trigger a HTTP Post as opposed to traditional web apps.
4. Simpler actions makes the over all site faster, things like e.g. Facebook like

1. SEO suffers as most crawlers are links based and have limited JS support so if you use fewer URL's to do a lot of actions, this is bad for SEO visibility of the site.
2. User experience, can not navigate to the path on refresh, so this could be bad user experience, if the Ajax is heavily used and you navigate to 3-4 levels and if you need to go back or forward.

Good Example of Ajax implemented site with SEO friendly URLs:
As you would see here with github, even though it is Ajax, the links are changing which is kind of best of both worlds:
Limitation of the above approach: Only HTML5 supports this feature--History supported browsers (most modern browsers). Push the URL to the browsers and ajax takes care of all the handling.You need to implement If\Else for older browsers and fortunately there is an API available, please find below link

Top 10 Ajax applications in commerce (WCS):  I will fill this soon.