[ 
https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12793579#action_12793579
 ] 

Sergey Beryozkin commented on CXF-2585:
---------------------------------------

Hi,

@Path("/webform.html?cmd=execute")

identifies the value for the uri path component, so '?' and '=' have to be 
encoded. JAXRS does not provide for embedding query values inside a @Path 
annotation

How is the service endpoint written ? Is it a 3rd-party endpoint or is it 
yourself who wrote it ? If yes then may be that service endpoint can be updated 
to default to "execute" if no "cmd" query is provided ?

Another option to try is to change your method signature like this :

String createCustomer(@QueryParam("") QueryBean bean);

public class QueryBean {
    private String cmd = "execute";
    private String workflow;

    public QueryBean() {
         this("defaultWorkflowValue")
    }
    public QueryBean(String workflow) { 
         this.workflow = workflow;
    }

    public void setCmd(String value) {
        cmd = value;
    }
    public String getCmd() {
        return cmd;
    }

    public void setWorkflow(String value) {
        workflow = value;
    }
    public String getWorkflow() {
        return workflow;
    }
}

and then

proxy.createCustomer(new QueryBean("SomeWorkflowValue"));

This option is good in that you can add a support for new queries by updating 
the query bean and the service implementation but without changing the signature

Finally, you can try to do

@Path("/webform.html")
public String createCustomer(@QueryParam("workflow") String workflow);

But then update Message.REQUEST_URI value on the current message in the CXF out 
interceptor, by appending "&cmd=execute" to it

hope it helps, Sergey

 

> Already connected exception when using a proxy created with JAXRSClientFactory
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2585
>                 URL: https://issues.apache.org/jira/browse/CXF-2585
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.2.5
>         Environment: JDK 1.5.0.18
>            Reporter: S.Allegro
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2.6, 2.3
>
>
> I'm trying to get a very simple Rest client working, but I always got this 
> exception:
> java.lang.IllegalStateException: Already connected
>       at 
> java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:100)
>       at 
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1885)
>       at 
> org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
>       at 
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1976)
>       at 
> org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
>       at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
>       at 
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
>       at 
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
>       at 
> org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
>       at 
> org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
>       at $Proxy16.doSomething(Unknown Source)
>       at com.francetelecom.resttest.RestTest.main(RestTest.java:27)
> Here is my jax-rs interface:
> @Path("/")
> public interface RestWS {
>     @POST
>     @Path("/test")
>     public String doSomething( @QueryParam("param") String paramName);
> }
> And here the way my client uses it:
> RestWS proxy = 
> JAXRSClientFactory.create("http://localhost:8080/RestWSMock",RestWS.class);
> proxy.doSomething("bob");
> I can not get it simpler. Any idea what's wrong ?
> regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to