Le 2012-05-22 à 09:41, Kieran Kelleher a écrit : > By the way, you could also use a stateless WOComponent to generate your > custom XML response. Instead of HTML, you would just have XML in the > WOComponent.html file and use WOString elements to render the variables. In > the DA, you can just create the WOComponent, use a setter to push in some > variable(s) and return the component. > > > ERRest is a rich framework that can render EOEnterpriseObjects (and plain > POJOs) as xml (and many other format) responses. It also understands xml (and > all supported format) requests (for CREATE, PUT, UPDATE http methods). > > As Pascal said, look at ERXRouteExample. ERRest is the business. > > You just create Controller classes for your different object types, usually > extending ERXRouteController (or you may have your own BaseController with > common logic that in turn extends ERXRouteController), use ERXKeyFilters to > filter object keys that are viewable, updatable etc for your various REST > actions, configure routes in Application startup and then the magic begins. > > > There is documentation in ERRest, so look at that too.
And many recordings on wocommunity.org > On May 22, 2012, at 9:04 AM, Kalpana Vaka wrote: > >> Hi Kieren, >> >> Can you please help us with sample program using ERRest? We figured out the >> direct action code based on your comments. >> >> Thanks & Regards, >> Kalpana. >> >> From: Kalpana Vaka [mailto:[email protected]] >> Sent: 22 May 2012 18:21 >> To: 'Kieran Kelleher' >> Cc: '[email protected]' >> Subject: RE: REST APIs in WO applications >> >> Hi Kieren, >> >> Thanks for the response. >> >> Can you help us with sample direct action code that returns XML in the >> response? >> >> Thanks & Regards, >> Kalpana. >> >> From: Kieran Kelleher [mailto:[email protected]] >> Sent: 21 May 2012 23:57 >> To: Kalpana Vaka >> Cc: [email protected] >> Subject: Re: REST APIs in WO applications >> >> Since you are having to do this backwards and implement an API that someone >> else designed for you as shown below, the fastest thing to do IMHO would be >> this: >> >> (1) Implement a Direct Action to handle the invoke action. You can use >> apache redirect as needed to rewrite the pre-defined base URL to WO direct >> action URL. >> >> (2) For the response body, just use two text String templates for the 2 >> possible response formats and use ERXSimpleTemplateParser to fill in the >> variables and set the WOResponse content as the text result and return that. >> (or just use a StringBuilder to build the simple XML response as shown in >> your example. >> >> >> Next time, implement your API using ERRest in a nice standardized way and >> tell your client how you want them to call your REST service. >> >> HTH, Kieran >> >> >> >> >> On May 21, 2012, at 2:11 PM, Kalpana Vaka wrote: >> >> >> Hi All, >> >> We have an urgent requirement from a customer to support REST APIs. >> They are using some other system and these APIs are in production now. >> They want us to receive these API calls now. The question is how we can >> implement these in our WO application. I am giving an example of the API >> below. >> Thanks for your help! Can anyone help us with this? Can we do this with >> direct action? >> >> >> Method: createUser >> >> >> Input: >> >> Parameter Nane >> Type >> Required* >> Description >> Notes >> partnerId >> String >> Y >> Partner Identifier. i.e. une >> >> partnerPassword >> String >> Y >> Password i.e admin@une >> >> email >> String >> Y >> User email >> Max 50 chars >> password >> String >> Y >> User password >> Max 30 chars >> firstname >> String >> Y >> User First Name >> Max 50 chars >> lastname >> String >> Y >> User Last Name >> Max 50 chars >> birthdate >> String >> N >> User birthdate >> dd/mm/yyyyy >> cellphone >> String >> N >> User cellphone >> Max 10 chars >> country >> String >> Y >> Default MX >> 2 character >> regionCode >> String >> N >> ISO Codes >> 2 character >> address >> String >> N >> User address >> Max 255 chars >> city >> String >> N >> User City >> Max 100 chars >> zipcode >> String >> N >> User Zip Code >> Max 10 chars >> freetrial >> Char >> N >> [Y|N] >> >> subid1 - subid5 >> String >> N >> Five parameters (your partnername as part of subid1, any other information >> as part of subid2 – 5. >> >> >> *Required Fields: All the required fields (Y) are mandatory. >> Output: >> status: Success/Fail >> >> In case of Success: >> userId (unique user id) >> accountId (internal account id for cross-reference purposes) >> >> Invoke Example: >> >> >> https://test.com/rest/createUser?partnerId=TESTPARTNER&partnerPassword=PASSWORD123&[email protected]&password=pass123&firstname=Terry&lastname=Tester&country=MX&subid1=xyz1&subid2=xyz2&subid3=xyz3&freetrial=y >> Output Examples: >> >> >> Success: >> >> <createUserResponse> >> <tmResponseCode>000000000</tmResponseCode> >> <message> >> <accountID>2105033283</accountID> >> <user_id>[email protected]</user_id> >> </message> >> </createUserResponse> >> >> The ‘000000000’ value of <tmResponseCode> represents success. >> >> >> Fail: >> >> <createUserResponse> >> <detail> >> <responseCode>100_02_30007</responseCode> >> <responseMessage>Email id mentioned in profile >> already exists in database.</responseMessage> >> </detail> >> <tmResponseCode>111111111</tmResponseCode> >> </createUserResponse> >> >> The ‘111111111’ value of <tmResponseCode> represents failure. >> >> >> Thanks & Regards, >> Kalpana. >> _______________________________________________ >> Do not post admin requests to the list. They will be ignored. >> Webobjects-dev mailing list ([email protected]) >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/webobjects-dev/kelleherk%40gmail.com >> >> This email sent to [email protected] > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list ([email protected]) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/probert%40macti.ca > > This email sent to [email protected] _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
