You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Kaleb Walton <kd...@us.ibm.com> on 2007/08/22 16:42:12 UTC
JSON output
Is there an easy way to use JSON as the transport protocol when configuring
a Service in Spring? I have a SOAP service working quite nicely but would
like to expose the same service using JSON with minimal additional
configuration. I looked at the instructions on the wiki but they only show
the programmatic way and I'd prefer to use Spring.
The pertinent parts of my current configuration are as follows:
<lang:groovy id="groovyService"
script-source="classpath:a/b/c/webservices/GroovyServiceImpl.groovy"/>
<simple:server id="groovy" serviceClass="a.b.c.webservices.GroovyService"
serviceBean="#groovyService" address="/Groovy"/>
It'd be great to be able to create another service that outputs JSON with
only a few extra lines of configuration. Please excuse me if this seems a
simple problem, I admit I'm having trouble figuring out the correlation
between the Spring server config and the programmatic ServerFactoryBean.
Regards,
Kaleb
Re: JSON output
Posted by Kaleb Walton <kd...@us.ibm.com>.
Thanks to both of you!
|------------>
| From: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|Dale Peakall <d....@oclcpica.org> |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|cxf-user@incubator.apache.org |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|08/23/2007 03:57 AM |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|Re: JSON output |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
The spring configuration will look something like this:
<jaxws:endpoint id="jsonWS"
implementor="#myService"
address="/json/MyService"
bindingUri="http://apache.org/cxf/binding/http">
<jaxws:properties>
<entry key="Content-Type" value="text/plain"/>
</jaxws:properties>
<jaxws:serviceFactory>
<bean
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
<property name="wrapped" value="false"/> <!-- Wrapped
services bugged: CXF-903 -->
<property name="properties">
<map>
<entry>
<key><value>javax.xml.stream.XMLInputFactory</value></key>
<bean
class="org.codehaus.jettison.mapped.MappedXMLInputFactory">
<constructor-arg>
<map>
<entry key=
"http://myserviceiface.example.org/" value="myservice"/>
<entry key=
"http://myserviceimpl.example.org/" value="myserviceimpl"/>
</map>
</constructor-arg>
</bean>
</entry>
<entry>
<key><value>javax.xml.stream.XMLOutputFactory</value></key>
<bean
class="org.codehaus.jettison.mapped.MappedXMLOutputFactory">
<constructor-arg>
<map>
<entry key=
"http://myserviceiface.example.org/" value="myservice"/>
<entry key=
"http://myserviceimpl.example.org/" value="myserviceimpl"/>
</map>
</constructor-arg>
</bean>
</entry>
</map>
</property>
</bean>
</jaxws:serviceFactory>
</jaxws:endpoint>
Liu, Jervis wrote:
Hi Kaleb, I am really not sure if it makes sense to convert SOAP
message to JSON. But if the payload is Plain-old--XML(POX), it should
be doable in CXF. At the moment, CXF HTTP binding can serve RESTful
service in both POX and JSON payload. Details can be found from
http://cwiki.apache.org/CXF20DOC/http-binding.html and
samples\restful_http_binding. If this is what you are looking for, we
can spend more time to figure what the spring configuration would
look like for JSON.
Cheers,
Jervis
-----Original Message-----
From: Kaleb Walton [mailto:kdwalton@us.ibm.com]
Sent: 2007?8?22? 22:42
To: cxf-user@incubator.apache.org
Subject: JSON output
Is there an easy way to use JSON as the transport protocol
when configuring
a Service in Spring? I have a SOAP service working quite
nicely but would
like to expose the same service using JSON with minimal
additional
configuration. I looked at the instructions on the wiki but
they only show
the programmatic way and I'd prefer to use Spring.
The pertinent parts of my current configuration are as follows:
<lang:groovy id="groovyService"
script-source="classpath:a/b/c/webservices/GroovyServiceImpl.groovy"/>
<simple:server id="groovy"
serviceClass="a.b.c.webservices.GroovyService"
serviceBean="#groovyService" address="/Groovy"/>
It'd be great to be able to create another service that
outputs JSON with
only a few extra lines of configuration. Please excuse me if
this seems a
simple problem, I admit I'm having trouble figuring out the
correlation
between the Spring server config and the programmatic
ServerFactoryBean.
Regards,
Kaleb
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
Ireland
Re: JSON output
Posted by Dale Peakall <d....@oclcpica.org>.
The spring configuration will look something like this:
<jaxws:endpoint id="jsonWS"
implementor="#myService"
address="/json/MyService"
bindingUri="http://apache.org/cxf/binding/http">
<jaxws:properties>
<entry key="Content-Type" value="text/plain"/>
</jaxws:properties>
<jaxws:serviceFactory>
<bean
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
<property name="wrapped" value="false"/> <!-- Wrapped
services bugged: CXF-903 -->
<property name="properties">
<map>
<entry>
<key><value>javax.xml.stream.XMLInputFactory</value></key>
<bean
class="org.codehaus.jettison.mapped.MappedXMLInputFactory">
<constructor-arg>
<map>
<entry
key="http://myserviceiface.example.org/" value="myservice"/>
<entry
key="http://myserviceimpl.example.org/" value="myserviceimpl"/>
</map>
</constructor-arg>
</bean>
</entry>
<entry>
<key><value>javax.xml.stream.XMLOutputFactory</value></key>
<bean
class="org.codehaus.jettison.mapped.MappedXMLOutputFactory">
<constructor-arg>
<map>
<entry
key="http://myserviceiface.example.org/" value="myservice"/>
<entry
key="http://myserviceimpl.example.org/" value="myserviceimpl"/>
</map>
</constructor-arg>
</bean>
</entry>
</map>
</property>
</bean>
</jaxws:serviceFactory>
</jaxws:endpoint>
Liu, Jervis wrote:
> Hi Kaleb, I am really not sure if it makes sense to convert SOAP message to JSON. But if the payload is Plain-old--XML(POX), it should be doable in CXF. At the moment, CXF HTTP binding can serve RESTful service in both POX and JSON payload. Details can be found from http://cwiki.apache.org/CXF20DOC/http-binding.html and samples\restful_http_binding. If this is what you are looking for, we can spend more time to figure what the spring configuration would look like for JSON.
>
> Cheers,
> Jervis
>
>
>
>> -----Original Message-----
>> From: Kaleb Walton [mailto:kdwalton@us.ibm.com]
>> Sent: 2007?8?22? 22:42
>> To: cxf-user@incubator.apache.org
>> Subject: JSON output
>>
>>
>>
>>
>> Is there an easy way to use JSON as the transport protocol
>> when configuring
>> a Service in Spring? I have a SOAP service working quite
>> nicely but would
>> like to expose the same service using JSON with minimal additional
>> configuration. I looked at the instructions on the wiki but
>> they only show
>> the programmatic way and I'd prefer to use Spring.
>>
>> The pertinent parts of my current configuration are as follows:
>>
>> <lang:groovy id="groovyService"
>> script-source="classpath:a/b/c/webservices/GroovyServiceImpl.groovy"/>
>> <simple:server id="groovy"
>> serviceClass="a.b.c.webservices.GroovyService"
>> serviceBean="#groovyService" address="/Groovy"/>
>>
>> It'd be great to be able to create another service that
>> outputs JSON with
>> only a few extra lines of configuration. Please excuse me if
>> this seems a
>> simple problem, I admit I'm having trouble figuring out the
>> correlation
>> between the Spring server config and the programmatic
>> ServerFactoryBean.
>>
>> Regards,
>> Kaleb
>>
>>
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>
RE: JSON output
Posted by "Liu, Jervis" <jl...@iona.com>.
Hi Kaleb, I am really not sure if it makes sense to convert SOAP message to JSON. But if the payload is Plain-old--XML(POX), it should be doable in CXF. At the moment, CXF HTTP binding can serve RESTful service in both POX and JSON payload. Details can be found from http://cwiki.apache.org/CXF20DOC/http-binding.html and samples\restful_http_binding. If this is what you are looking for, we can spend more time to figure what the spring configuration would look like for JSON.
Cheers,
Jervis
> -----Original Message-----
> From: Kaleb Walton [mailto:kdwalton@us.ibm.com]
> Sent: 2007?8?22? 22:42
> To: cxf-user@incubator.apache.org
> Subject: JSON output
>
>
>
>
> Is there an easy way to use JSON as the transport protocol
> when configuring
> a Service in Spring? I have a SOAP service working quite
> nicely but would
> like to expose the same service using JSON with minimal additional
> configuration. I looked at the instructions on the wiki but
> they only show
> the programmatic way and I'd prefer to use Spring.
>
> The pertinent parts of my current configuration are as follows:
>
> <lang:groovy id="groovyService"
> script-source="classpath:a/b/c/webservices/GroovyServiceImpl.groovy"/>
> <simple:server id="groovy"
> serviceClass="a.b.c.webservices.GroovyService"
> serviceBean="#groovyService" address="/Groovy"/>
>
> It'd be great to be able to create another service that
> outputs JSON with
> only a few extra lines of configuration. Please excuse me if
> this seems a
> simple problem, I admit I'm having trouble figuring out the
> correlation
> between the Spring server config and the programmatic
> ServerFactoryBean.
>
> Regards,
> Kaleb
>
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland