[OPEN-ILS-DEV] Help:opensrf over http using java

m3th0d . m3th0d.itbhu at gmail.com
Wed Mar 30 01:40:40 EDT 2011


thanks Bill, this is what , I was about to ask, creating JSON from Java
Using opensrf library.

On Wed, Mar 30, 2011 at 2:43 AM, Bill Erickson <erickson at esilibrary.com>wrote:

>
>
> On Mon, Mar 28, 2011 at 12:51 PM, chiwe123456 at gmail.com <
> chiragahuja.nsit at gmail.com> wrote:
>
>> Is the java implementation of evergreen complete?..i heard that its not
>> complete yet so i opted a different method ...
>>
>
> Correct, it's not complete.  There is no OpenSRF translator or gateway
> class in Java.  However, it does implement most of the basics for OpenSRF
> object handling and serialization.
>
>
>>
>> I am actually working on android and sending post message to my virtual
>> machine on which evergreen is installed so i used apache http library..but i
>> am having some problem..
>>
>> i am pasting the code written by me
>>
>> can you please help me out with it..i have browsed over web and this
>> method for sending json object appeared best to me..
>>
>> the above json written by me in previous mail is not correct so
>> for testing purpose i'm working on search books by barcode in which
>> barcade id is specified by user...
>>
>> curl -H "X-OpenSRF-service: open-ils.search" --data 'osrf-msg=[{"__p" : {"threadTrace" : 0, "payload" : { "__c" : "osrfMethod","__p" : { "params" :"30007004981493","method" : "open-ils.search.biblio.find_by_barcode"}},"type" : "REQUEST","locale" : "en-US"},"__c" : "osrfMessage"} ]' http://localhost/osrf-http-translator
>>
>>
>>
>>
>>
>> HttpParams httpParams = new BasicHttpParams();
>>
>>
>>     HttpClient client = new DefaultHttpClient(httpParams);
>>
>>
>>     HttpPost httpost = new HttpPost("http://"+hostname+"/osrf-http-translator");
>>
>>
>>
>>
>>   httpost.setHeader("Accept", "application/json");
>>      httpost.setHeader("Content-type", "application/json");
>>
>>
>>     httpost.setHeader("X-OpenSRF-service", "open-ils.search");
>>
>>
>>     System.out.println("2");
>>
>>
>>     JSONObject data = new JSONObject();
>>
>>
>>     JSONObject _p = new JSONObject();
>>
>>
> [snip...]
>
> It's not necessary to build the JSON by hand.  You can create an
> org.opensrf.Message object, pass in a Java Map or Java Array (or string,
> number, boolean, etc.  See [1] for options) as the payload object.  Then,
> simply calling toString() on the Message will generate the JSON for you.
>
> -b
>
> [1]
> http://svn.open-ils.org/trac/OpenSRF/browser/trunk/src/java/org/opensrf/util/JSONWriter.java
>
>
> --
> Bill Erickson
> | VP, Software Development & Integration
> | Equinox Software, Inc. / Your Library's Guide to Open Source
> | phone: 877-OPEN-ILS (673-6457)
> | email: erickson at esilibrary.com
> | web: http://esilibrary.com
>



-- 
Himanshu Singh (m3th0d)
IT-BHU

Play Hard !! Go Pro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://libmail.georgialibraries.org/pipermail/open-ils-dev/attachments/20110330/fe3c174d/attachment.htm 


More information about the Open-ils-dev mailing list