Setting Http-conduit using spring configuration file

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting Http-conduit using spring configuration file

vijayvaleti
Hi,

I am using the following client configuration file for setting the receive timeout options on the http-conduit object using a configurations file.

clientConfig.xml

I am using the following client code.
AuthServiceFactory.java

her is my wsdl
authorizationService.wsdl

timouts are defaulted to 60 sec always . please let me know if anything is wrong in the configurations deatils.

i am using apache cxf 2.2.6 and tomcat for this

Thanks
Vijay.v
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

vijayvaleti
i also tried separating the beans and http conduit properties in doffrent config files still its not working

Thanks
vijay.v
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

Daniel  Kulp
Administrator
In reply to this post by vijayvaleti


Couple thoughts:

1) You aren't setting the wsdlLocation attribute on the JaxWsProxyFactory
thing so it may be looking for a different endpoint name.    I would suggest
completely filling in the extra details there including the wsdlLocation and
serviceName and endpointName.    

Alternatively:

2) Change the http:conduit name to be a wildcard URL:

<http-conf:conduit name="http://localhost:8080/.*">
                <http-conf:client ReceiveTimeout="3000"/>
</http-conf:conduit>


which should catch it as well.

Dan


On Monday 23 August 2010 4:29:20 am vijayvaleti wrote:

> Hi,
>
> I am using the following client configuration file for setting the receive
> timeout options on the http-conduit object using a configurations file.
>
> http://cxf.547215.n5.nabble.com/file/n2644363/clientConfig.xml
> clientConfig.xml
>
> I am using the following client code.
> http://cxf.547215.n5.nabble.com/file/n2644363/AuthServiceFactory.java
> AuthServiceFactory.java
>
> her is my wsdl
> http://cxf.547215.n5.nabble.com/file/n2644363/authorizationService.wsdl
> authorizationService.wsdl
>
> timouts are defaulted to 60 sec always . please let me know if anything is
> wrong in the configurations deatils.
>
> i am using apache cxf 2.2.6 and tomcat for this
>
> Thanks
> Vijay.v

--
Daniel Kulp
[hidden email]
http://dankulp.com/blog
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

vijayvaleti
Hi Dan,

I have updated the client configuration file suggested by you, but still its not timing out to the value what i have specified in the conduit. it is always timesout to the default value only(i.e 60 secs).

please find the my updated client configuration file.

clientConfig.xml

please let me know if any thing is wrong with the configuration file.

Thanks
Vijay.V
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

vijayvaleti
In reply to this post by Daniel Kulp

I have updated the client configuration file suggested by you, but still its not timing out to the value what i have specified in the conduit. it is always timesout to the default value only(i.e 60 secs).

please find the my updated client configuration file.

clientConfig.xml

please let me know if any thing is wrong with the configuration file.

Thanks
Vijay.V
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

Daniel  Kulp
Administrator
In reply to this post by Daniel Kulp

That all looks fine to me.  May need a full sample to debug.

Dan


On Tuesday 24 August 2010 11:04:16 am vvvijayvaleti wrote:

> Hi Dan,
>
> I have updated the client configuration file suggested by you, but still
> its not timing out to the value what i have specified in the conduit. it
> is always timesout to the default value only(i.e 60 secs).
>
> please find the my updated client configuration file.
>
>
> please let me know if any thing is wrong with the configuration file.
>
> Thanks
> Vijay.V
>
> On Mon, Aug 23, 2010 at 7:23 PM, Daniel Kulp <[hidden email]> wrote:
> > Couple thoughts:
> >
> > 1) You aren't setting the wsdlLocation attribute on the JaxWsProxyFactory
> > thing so it may be looking for a different endpoint name.    I would
> > suggest
> > completely filling in the extra details there including the wsdlLocation
> > and
> > serviceName and endpointName.
> >
> > Alternatively:
> >
> > 2) Change the http:conduit name to be a wildcard URL:
> >
> > <http-conf:conduit name="http://localhost:8080/.*">
> >
> >                <http-conf:client ReceiveTimeout="3000"/>
> >
> > </http-conf:conduit>
> >
> >
> > which should catch it as well.
> >
> > Dan
> >
> > On Monday 23 August 2010 4:29:20 am vijayvaleti wrote:
> > > Hi,
> > >
> > > I am using the following client configuration file for setting the
> >
> > receive
> >
> > > timeout options on the http-conduit object using a configurations file.
> > >
> > > http://cxf.547215.n5.nabble.com/file/n2644363/clientConfig.xml
> > > clientConfig.xml
> > >
> > > I am using the following client code.
> > > http://cxf.547215.n5.nabble.com/file/n2644363/AuthServiceFactory.java
> > > AuthServiceFactory.java
> > >
> > > her is my wsdl
> > > http://cxf.547215.n5.nabble.com/file/n2644363/authorizationService.wsdl
> > > authorizationService.wsdl
> > >
> > > timouts are defaulted to 60 sec always . please let me know if anything
> >
> > is
> >
> > > wrong in the configurations deatils.
> > >
> > > i am using apache cxf 2.2.6 and tomcat for this
> > >
> > > Thanks
> > > Vijay.v
> >
> > --
> > Daniel Kulp
> > [hidden email]
> > http://dankulp.com/blog

--
Daniel Kulp
[hidden email]
http://dankulp.com/blog
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

vijayvaleti
Hi Dan,

It is working for me after including following import statements in my client config file.
             <import resource="classpath:META-INF/cxf/cxf.xml" />
        <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
        <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

Could you please explain me why we need to add the above imports?

I also have a couple of queries regarding the Conduit.

1. is it possiable to define the conduit(Htttp-timeout) for diffrenet services which residing at same address?

example:

<http-conf:conduit name="{http://test.com/}AuthorizationServicePort.http-conduit">
        <http-conf:client ConnectionTimeout="5000" ReceiveTimeout="5000" />
</http-conf:conduit>

<http-conf:conduit name="{http://test.com/}SecuirtServicePort.http-conduit">
        <http-conf:client ConnectionTimeout="3000" ReceiveTimeout="3000" />
</http-conf:conduit>

2. is it possibale to set the timeout per operation basis?
3. whether the Http-Conduit what we define in config is threadsafe?

4. The connections(HTTP) what ever created while making a communication with endpoint is maintained in pool (http connection caching) if not there is any way to cache the connection using the config like number of connections ?
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

Daniel  Kulp
Administrator
On Wednesday 25 August 2010 7:05:01 am vijayvaleti wrote:
> Hi Dan,
>
> It is working for me after including following import statements in my
> client config file.
>              <import resource="classpath:META-INF/cxf/cxf.xml" />
> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
> Could you please explain me why we need to add the above imports?

When you don't use the imports, when a Bus is needed, it will create a default
bus which would be using it's own spring context.   When the Bus looks for
configuration, it would just look in that spring context since it wouldn't
know about your context.  I THINK if you use a jaxws:client thing instead of a
spring bean, it MAY wire the current context into the default bus.  Not really
sure though.   However, if you use normal spring beans, not much we can do
unless we create spring specific subclasses (which we could) that would be
Spring ApplicationContextAware to to wire things.   Would be more of a
documentation issue of "when to use JaxWsProxyFactoryBean or
SpringJaxWsProxyFactoryBean" and such.


> I also have a couple of queries regarding the Conduit.
>
> 1. is it possiable to define the conduit(Htttp-timeout) for diffrenet
> services which residing at same address?

Yea.   Exactly like you did.  However, you could also do it URL based:
<http-conf:conduit  name="http://localhost:8080/AuthService.*">...
<http-conf:conduit  name="http://localhost:8080/SecureService.*">...



> example:
>
> <http-conf:conduit
> name="{http://test.com/}AuthorizationServicePort.http-conduit">
> <http-conf:client ConnectionTimeout="5000" ReceiveTimeout="5000" />
> </http-conf:conduit>
>
> <http-conf:conduit
> name="{http://test.com/}SecuirtServicePort.http-conduit">
> <http-conf:client ConnectionTimeout="3000" ReceiveTimeout="3000" />
> </http-conf:conduit>
>
> 2. is it possibale to set the timeout per operation basis?

Not in config, no.   In code, before making the call, you can grab the
HttpConduit and modify settings right before the call.  

> 3. whether the Http-Conduit what we define in config is threadsafe?

Yes. The http:conduit element doesn't actually create anything.  It's actually
and abstract thing that is used to configure HttpConduit objects later.

> 4. The connections(HTTP) what ever created while making a communication
> with endpoint is maintained in pool (http connection caching) if not there
> is any way to cache the connection using the config like number of
> connections ?

The HttpURLConnection thing we use under the covers does maintain a pool of
connections.   There isn't much that can be done to configure it client side
though.


--
Daniel Kulp
[hidden email]
http://dankulp.com/blog
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

vijayvaleti
Hi Dan,

Thanks for your quick response . it is very helpfull.

In your prevous reply you mentioned that, There isn't much that can be done to configure it client side for the http connection pooling.

I Have read the Server HTTP Transport section of the CXF web site , but i couldnt able to find out there is a way for connection pooling on the server side.

could you please let me know how to configure the Http connection pool on the server side.

Thanks
Vijay.V
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

vijayvaleti

Hi,

Any one have idea on how to use connection pooling on CXF server side components.

Thanks
Vijay.V
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

Daniel  Kulp
Administrator
On Monday 06 September 2010 7:32:19 am vijayvaleti wrote:
> Hi,
>
> Any one have idea on how to use connection pooling on CXF server side
> components.

It should be automatic by default.   For a servlet based service, the
container you are running in may have some controls over the connection counts
and such.   For the internal jetty stuff, you may need to grab the internal
Jetty server thing and configure things with it via java code.   Not really
sure.

--
Daniel Kulp
[hidden email]
http://dankulp.com/blog
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

bcokee
In reply to this post by Daniel Kulp
Hi Dan,

 I'm also interested in knowing how to set a timeout per operation. At the moment I only
 know how to apply timeout per service.

Daniel Kulp wrote
>
> 2. is it possibale to set the timeout per operation basis?

Not in config, no.   In code, before making the call, you can grab the
HttpConduit and modify settings right before the call.  


--
Daniel Kulp
[hidden email]
http://dankulp.com/blog

Just to clarify my use case. Suppose we have a service like below:

public interface SomePortType
{

       public   SomeRS  operation1RQ( ... ) ;
       public   SomeRS  operation2RQ( ... ) ;
       public   SomeRS  operation3RQ( ... ) ;    
   
}
 
  I want to set different receive timeouts for each operation ( e.g. 5 sec, 10 sec. , 15 sec. respectively)
  Could you please give more hints as to how  this can be achieved?
  What settings of the conduit should be modified ?
  Is one HttpConduit enough or  one conduit per operation ?

 Regards,
 Berns
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

Daniel  Kulp
Administrator
On Tuesday 05 April 2011 7:27:02 AM bcokee wrote:
> Hi Dan,
>
>  I'm also interested in knowing how to set a timeout per operation. At the
> moment I only
>  know how to apply timeout per service.

The only way to do it is by modifying the HTTPConduit prior to the individual
call to the operation on the client (and realizing that that would not be
thread safe) or installing an interceptor early in the out chain that would
grab the operation and do something similar.   The interceptor could just do
something like:

msg.getExchange().getBindingOperationInfo()

to get the operation.  Then look up the timeouts you need for that, and then
do:

msg.put(Message.CONNECTION_TIMEOUT, ..)
msg.put(Message.RECEIVE_TIMEOUT, ..)


Dan



>
> Daniel  Kulp wrote:
> >> 2. is it possibale to set the timeout per operation basis?
> >
> > Not in config, no.   In code, before making the call, you can grab the
> > HttpConduit and modify settings right before the call.
>
> Just to clarify my use case. Suppose we have a service like below:
>
> public interface SomePortType
> {
>
>        public   SomeRS  operation1RQ( ... ) ;
>        public   SomeRS  operation2RQ( ... ) ;
>        public   SomeRS  operation3RQ( ... ) ;
>
> }
>
>   I want to set different receive timeouts for each operation ( e.g. 5 sec,
> 10 sec. , 15 sec. respectively)
>   Could you please give more hints as to how  this can be achieved?
>   What settings of the conduit should be modified ?
>   Is one HttpConduit enough or  one conduit per operation ?
>
>  Regards,
>  Berns
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Setting-Http-conduit-using-spring-configur
> ation-file-tp2644363p4283714.html Sent from the cxf-user mailing list
> archive at Nabble.com.

--
Daniel Kulp
[hidden email]
http://dankulp.com/blog
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

bcokee
Hi Dan,

 I tried the interceptor like you said and it seems to work. Just have the ff. concerns:

1. Is HttpConduit shared by all clients ? Like if I set a timeout like below, will it overwrite the timeout setting of other clients accessing same endpoint ?

   HTTPClientPolicy httpPolicy = createHttpPolicy();
   HTTPConduit conduit = getHTTPConduit(client);
   conduit.setClient(httpPolicy);
   conduit.getClient().setReceiveTimeout(receiveTimeoutInMillis);


2. Using the interceptor, if I apply a timeout using msg.put(Message.RECEIVE_TIMEOUT, ..)  on one operation, will it overwrite the timeout for other operations of the service ? Is this approach thread safe?

I want each operation to have separate timeout values.

Thanks,
Berns
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

Daniel  Kulp
Administrator
On Thursday 07 April 2011 12:09:47 AM bcokee wrote:

> Hi Dan,
>
>  I tried the interceptor like you said and it seems to work. Just have the
> ff. concerns:
>
> 1. Is HttpConduit shared by all clients ? Like if I set a timeout like
> below, will it overwrite the timeout setting of other clients accessing
> same endpoint ?
>
>    HTTPClientPolicy httpPolicy = createHttpPolicy();
>    HTTPConduit conduit = getHTTPConduit(client);
>    conduit.setClient(httpPolicy);
>    conduit.getClient().setReceiveTimeout(receiveTimeoutInMillis);

No.  The conduit is per client proxy.   If you share a single client proxy on
multi-threads, that will be an issue.  But for a single proxy, that is fine.

>
>
> 2. Using the interceptor, if I apply a timeout using
> msg.put(Message.RECEIVE_TIMEOUT, ..)  on one operation, will it overwrite
> the timeout for other operations of the service ? Is this approach thread
> safe?

The msg is per request.   Anything set there doesn't affect anything else.

Dan

 

> I want each operation to have separate timeout values.
>
> Thanks,
> Berns
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Setting-Http-conduit-using-spring-configur
> ation-file-tp2644363p4287702.html Sent from the cxf-user mailing list
> archive at Nabble.com.

--
Daniel Kulp
[hidden email]
http://dankulp.com/blog
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

mtuli
In reply to this post by bcokee
Which interceptor i have to write for this ?
Reply | Threaded
Open this post in threaded view
|

Re: Setting Http-conduit using spring configuration file

namhoa
In reply to this post by Daniel Kulp
Thanks. It is the answer me looking.