Java ApacheCXF-jaxrs客户端spring配置(注入代理)
我使用(示例)URL使用REST Web服务,如:Java ApacheCXF-jaxrs客户端spring配置(注入代理),java,web-services,spring-mvc,jax-rs,cxf,Java,Web Services,Spring Mvc,Jax Rs,Cxf,我使用(示例)URL使用REST Web服务,如: http://www.restsampleservice.com/api?username=tom&password=jerry 此url处的ws返回用户securedcode 目标: 我想将Rest ws集成到我的Spring web应用程序中。那么,我的JaxRS客户机服务类和地址在上下文xml中应该是怎样的呢 请在下面找到我的假设: <jaxrs:client id="restClient" address=" htt
http://www.restsampleservice.com/api?username=tom&password=jerry
此url处的ws返回用户securedcode
目标:
我想将Rest ws集成到我的Spring web应用程序中。那么,我的JaxRS客户机服务类和地址在上下文xml中应该是怎样的呢
请在下面找到我的假设:
<jaxrs:client id="restClient"
address=" http://www.restsampleservice.com/api?username=tom&password=jerry"
serviceClass=?
inheritHeaders="true">
<jaxrs:headers>
<entry key="Accept" value="text/plain"/>
</jaxrs:headers>
</jaxrs:client>
您需要这样的代理类
public interface RestClient{
@GET
@Path("/")
public String getUserSecureCode( @QueryParam("username") String username ,@QueryParam("password") String password)
}
<jaxrs:client id="restClient"
address="http://www.restsampleservice.com/api"
serviceClass="test.RestClient"
inheritHeaders="true">
<jaxrs:headers>
<entry key="Accept" value="text/plain"/>
</jaxrs:headers>
</jaxrs:client>
spring文件如下所示
public interface RestClient{
@GET
@Path("/")
public String getUserSecureCode( @QueryParam("username") String username ,@QueryParam("password") String password)
}
<jaxrs:client id="restClient"
address="http://www.restsampleservice.com/api"
serviceClass="test.RestClient"
inheritHeaders="true">
<jaxrs:headers>
<entry key="Accept" value="text/plain"/>
</jaxrs:headers>
</jaxrs:client>
您需要这样一个代理类
public interface RestClient{
@GET
@Path("/")
public String getUserSecureCode( @QueryParam("username") String username ,@QueryParam("password") String password)
}
<jaxrs:client id="restClient"
address="http://www.restsampleservice.com/api"
serviceClass="test.RestClient"
inheritHeaders="true">
<jaxrs:headers>
<entry key="Accept" value="text/plain"/>
</jaxrs:headers>
</jaxrs:client>
spring文件如下所示
public interface RestClient{
@GET
@Path("/")
public String getUserSecureCode( @QueryParam("username") String username ,@QueryParam("password") String password)
}
<jaxrs:client id="restClient"
address="http://www.restsampleservice.com/api"
serviceClass="test.RestClient"
inheritHeaders="true">
<jaxrs:headers>
<entry key="Accept" value="text/plain"/>
</jaxrs:headers>
</jaxrs:client>
试着重新考虑你的设计。将用户名和密码作为查询参数发送不是一个好主意。请尝试重新考虑您的设计。发送用户名和密码作为查询参数不是一个好主意。