You can use the Accept parameter in the HTTP header which is set to
‘application/json’. But for that the content-negotiation parameter in the
DSS server has to be set to true. By default this parameter is disabled.
This can be enabled by adding the following parameter in axis2.xml to true.

'<parameter name="httpContentNegotiation">true</parameter>'

Thanks


On Wed, Dec 4, 2013 at 2:14 PM, Samisa Abeysinghe <[email protected]> wrote:

> That seems a bug that accept does not work, but content-type does?
>
> Thanks,
> Samisa...
>
>
> Samisa Abeysinghe
>
> Vice President Training
>
> WSO2 Inc.
> http://wso2.com
>
>
>
> On Wed, Dec 4, 2013 at 2:13 PM, Samisa Abeysinghe <[email protected]> wrote:
>
>> However, I figured that
>> curl  -H "Content-Type: application/json" -X GET
>> http://localhost:9763/services/samples/ResourcesSample.HTTPEndpoint/products
>> works!
>>
>>
>> Thanks,
>> Samisa...
>>
>>
>> Samisa Abeysinghe
>>
>> Vice President Training
>>
>> WSO2 Inc.
>> http://wso2.com
>>
>>
>>
>> On Wed, Dec 4, 2013 at 2:11 PM, Samisa Abeysinghe <[email protected]>wrote:
>>
>>> With the REST sample, I tried
>>> curl -H "Accept: application/json" -X GET
>>> http://localhost:9763/services/samples/ResourcesSample.HTTPEndpoint/products
>>>
>>> but it still returns XML.
>>>
>>> Thanks,
>>> Samisa...
>>>
>>>
>>> Samisa Abeysinghe
>>>
>>> Vice President Training
>>>
>>> WSO2 Inc.
>>> http://wso2.com
>>>
>>>
>>>
>>> On Wed, Dec 4, 2013 at 2:04 PM, Anjana Fernando <[email protected]> wrote:
>>>
>>>> Hi Samisa,
>>>>
>>>> We don't actually have a specific sample for JSON as I know, Chanika
>>>> was writing an article for this, with some scenarios, but didn't publish
>>>> yet as I know. Chanika, do put a section to the docs to mention how to do
>>>> JSON with DSS.
>>>>
>>>> The content negotiation in data service simply works by setting the
>>>> HTTP header "Accept", with the content type as the value. For example, to
>>>> get a JSON response, you would have a HTTP header like the following:
>>>>
>>>> "Accept: application/json".
>>>>
>>>> Cheers,
>>>> Anjana.
>>>>
>>>>
>>>> On Wed, Dec 4, 2013 at 12:52 PM, Samisa Abeysinghe <[email protected]>wrote:
>>>>
>>>>> To ask a related question, how do I do content negotiation with DSS
>>>>> REST?
>>>>>
>>>>> Thanks,
>>>>> Samisa...
>>>>>
>>>>>
>>>>> Samisa Abeysinghe
>>>>>
>>>>> Vice President Training
>>>>>
>>>>> WSO2 Inc.
>>>>> http://wso2.com
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Dec 4, 2013 at 12:32 PM, Samisa Abeysinghe <[email protected]>wrote:
>>>>>
>>>>>> I am looking to do REST with JSON as content type with DSS.
>>>>>>
>>>>>> Do we have a sample that I can use to get started with?
>>>>>>
>>>>>> Thanks,
>>>>>> Samisa...
>>>>>>
>>>>>>
>>>>>> Samisa Abeysinghe
>>>>>>
>>>>>> Vice President Training
>>>>>>
>>>>>> WSO2 Inc.
>>>>>> http://wso2.com
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> *Anjana Fernando*
>>>> Technical Lead
>>>> WSO2 Inc. | http://wso2.com
>>>> lean . enterprise . middleware
>>>>
>>>
>>>
>>
>


-- 
Best Regards..

Chanika Geeganage
Software Engineer
WSO2, Inc.; http://wso2.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to