Hi Allan,

the mentioned tutorial is deprecated as stated in the information box on top of the article.

Apache Wink is retired and there were several API changes recently. It is not recommended to follow this tuturial.

Best regards,

Michael Brohl
ecomify GmbH
www.ecomify.de


Am 10.08.17 um 10:24 schrieb Lanzjess:
I am following the REST tutorial
https://cwiki.apache.org/confluence/display/OFBIZ/Export+service+using+REST
but still fails for Latest Version 16.11 Released.

LocalDispatcher dispatcher =
*GenericDispatcher*.getLocalDispatcher("default",delegator);

The above code in class PingResource  is not working. Currently, the class
GenericDispatcher is private as well as its constructor.
//=========================================================================
package restcomponent;
import java.util.Map; import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import javolution.util.FastMap; import org.apache.ofbiz.base.util.Debug;
import org.apache.ofbiz.base.util.UtilMisc;
import org.apache.ofbiz.entity.DelegatorFactory;
import org.apache.ofbiz.entity.GenericDelegator;
import org.apache.ofbiz.service.GenericDispatcher;
import org.apache.ofbiz.service.GenericServiceException;
import org.apache.ofbiz.service.LocalDispatcher;
import org.apache.ofbiz.service.ServiceUtil;
@Path("/ping")
public class PingResource {
@GET
     @Produces("text/plain")
     @Path("{message}")
     public Response sayHello(@PathParam("message") String message) {
GenericDelegator delegator = (GenericDelegator)
DelegatorFactory.getDelegator("default");
         LocalDispatcher dispatcher =
GenericDispatcher.getLocalDispatcher("default",delegator);
Map<String, String> paramMap = UtilMisc.toMap( "message", message ); Map<String, Object> result = FastMap.newInstance();
         try {
             result = dispatcher.runSync("ping", paramMap);
         } catch (GenericServiceException e1) {
             Debug.logError(e1, PingResource.class.getName());
             return Response.serverError().entity(e1.toString()).build();
         }
if (org.apache.ofbiz.service.ServiceUtil.isSuccess(result)) {
             return Response.ok("RESPONSE: *** " + result.get("message") + "
***").type("text/plain").build();
         }
if (org.apache.ofbiz.service.ServiceUtil.isError(result) ||
ServiceUtil.isFailure(result)) {
             return
Response.serverError().entity(ServiceUtil.getErrorMessage(result)).build();
         }
// shouldn't ever get here ... should we?
         throw new RuntimeException("Invalid ");
     }
}



--
View this message in context: 
http://ofbiz.135035.n4.nabble.com/REST-Tutorial-Not-Working-on-Latest-Version-16-11-Released-tp4709425.html
Sent from the OFBiz - User mailing list archive at Nabble.com.


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to