You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Janos Haber <bo...@gmail.com> on 2007/08/09 16:14:15 UTC

Restful service parameter

Hi!

I create a simple echo restful service.
The java side:

@WebService(endpointInterface = "hu.javaportal.www.test.TestService")
public class TestServiceImpl implements TestService {

    @Get
    @Override
    @HttpResource(location="/echo/{echoData}")
    public String echo(String echoData) {
        return "Echo:" + echoData;
    }

}

The spring xml:
    <bean id="xmlServiceFactory"
        class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
        <property name="wrapped" value="true" />
    </bean>
...
    <jaxws:endpoint id="echoXML"
        implementor="hu.javaportal.www.test.impl.TestServiceImpl"
        address="/service/xml"
        bindingUri="http://apache.org/cxf/binding/http">
        <jaxws:serviceFactory>
            <ref bean="xmlServiceFactory" />
        </jaxws:serviceFactory>
    </jaxws:endpoint>


I tried to call my service like:
http://localhost:8080/testproject/service/xml/echo?echoData=test
http://localhost:8080/testproject/service/xml/echo/echoData=test
etc...
but without success
the method called but the parameter is empty...

How can I solve this problem?

Cow

RE: Restful service parameter

Posted by "Liu, Jervis" <jl...@iona.com>.
Hi, I am afraid there is a bug in the way how CXF HTTP binding handles wrapped request, filed a jira for this: https://issues.apache.org/jira/browse/CXF-903

At the mean time, you can try unwrapped style as a work around. Note, you will need to create a wrapper class for EchoData in this case, sth like below:

@XmlRootElement
public class EchoData {
    private String echoData;

    public String getEchoData() {
        return echoData;
    }

    public void setEchoData(String b) {
        this.echoData = b;
    }
}

public class TestServiceImpl implements TestService {
    @Get
    @HttpResource(location = "/echo/{echoData}")
    String echo(EchoData echoData) {
    .........
    }

Cheers,
Jervis

> -----Original Message-----
> From: Janos Haber [mailto:boci.list@gmail.com]
> Sent: 2007?8?9? 22:14
> To: cxf-user@incubator.apache.org
> Subject: Restful service parameter
> 
> 
> Hi!
> 
> I create a simple echo restful service.
> The java side:
> 
> @WebService(endpointInterface = "hu.javaportal.www.test.TestService")
> public class TestServiceImpl implements TestService {
> 
>     @Get
>     @Override
>     @HttpResource(location="/echo/{echoData}")
>     public String echo(String echoData) {
>         return "Echo:" + echoData;
>     }
> 
> }
> 
> The spring xml:
>     <bean id="xmlServiceFactory"
>         class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
>         <property name="wrapped" value="true" />
>     </bean>
> ...
>     <jaxws:endpoint id="echoXML"
>         implementor="hu.javaportal.www.test.impl.TestServiceImpl"
>         address="/service/xml"
>         bindingUri="http://apache.org/cxf/binding/http">
>         <jaxws:serviceFactory>
>             <ref bean="xmlServiceFactory" />
>         </jaxws:serviceFactory>
>     </jaxws:endpoint>
> 
> 
> I tried to call my service like:
> http://localhost:8080/testproject/service/xml/echo?echoData=test
> http://localhost:8080/testproject/service/xml/echo/echoData=test
> etc...
> but without success
> the method called but the parameter is empty...
> 
> How can I solve this problem?
> 
> Cow
> 

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland