Hi Sachin, > 1. For all these models, can I just create 1 instance of Service or Client > and reuse it across multiple threads.
Generally speaking client proxies are not thread-safe accordingly to JAX-WS spec. In CXF they are mostly thread safe, excepting using of request context, settings in Conduit, sessions and WS-security tokens. If you don't need these features, you can use single client proxy for multiple threads. See details in http://cxf.apache.org/faq.html#FAQ-AreJAXWSclientproxiesthreadsafe%3F > 2. Is there an underlying pool of HttpConnections? If so how can I control > the parameters of this Connection Pool? By default CXF uses java.net HttpURLConnection to perform HTTP requests. You control the pool using JVM property "http.maxConnections" (default 5). Details are available here : http://java.sun.com/javase/6/docs/technotes/guides/net/http-keepalive.html Additionally CXF supports asynchronous client HTTP transport (available from CXF 2.7.0): http://cxf.apache.org/docs/asynchronous-client-http-transport.html. It is based on Apache HTTP Components HttpAsyncClient, uses non-blocking IO model and has own settings for connection management: org.apache.cxf.transport.http.async.MAX_CONNECTIONS, org.apache.cxf.transport.http.async.MAX_PER_HOST_CONNECTIONS. Regards, Andrei. From: Sachin Nikam [mailto:[email protected]] Sent: Mittwoch, 7. August 2013 21:09 To: Andrei Shakirin Cc: [email protected] Subject: Re: Need help with JAX-WS client "Could not send Message error" Andrei, Sorry for the delayed response and thanks for your help. It worked. I had a follow up question. 1. For all these models, can I just create 1 instance of Service or Client and reuse it across multiple threads. 2. Is there an underlying pool of HttpConnections? If so how can I control the parameters of this Connection Pool? Regards Sachin On Mon, Jul 29, 2013 at 12:48 AM, Andrei Shakirin <[email protected]> wrote: Hi, It depends on method how you create the client: a) If you use spring you can add “address” attribute to jaxws:client: <jaxws:client id="customerService" serviceName="customer:CustomerServiceService" endpointName="CustomerServicePort" address="http://localhost:9090/CustomerServicePort" serviceClass="com.example.customerservice.CustomerService"> b) If you use Service model – set endpointAddress to service by adding Port: Service service = Service.create(SERVICE_NAME); // Endpoint Address String endpointAddress = "http://localhost:9000/helloWorld"; // Add a port to the Service service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress); c) If you use JaxWSproxyFactoryBean – set Address property: JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setAddress("http://localhost:9000/helloWorld"); HelloWorld client = factory.create(HelloWorld.class); Regards, Andrei. From: Sachin Nikam [mailto:[email protected]] Sent: Montag, 29. Juli 2013 08:29 To: Andrei Shakirin Cc: [email protected] Subject: Re: Need help with JAX-WS client "Could not send Message error" Hi Andrei, You are right the WSDL does not contain the address in the port element. How do I set the endpoint address for the service? Regards Sachin On Sun, Jul 28, 2013 at 5:35 AM, Andrei Shakirin <[email protected]> wrote: Hi, I guess the problem is that your WSDL doesn't contain address in port element and address is not explicitly configured in the service as well. CXF doesn't know address to send the message. Regards, Andrei. > -----Original Message----- > From: Sachin Nikam [mailto:[email protected]] > Sent: Freitag, 26. Juli 2013 18:10 > To: [email protected] > Subject: Re: Need help with JAX-WS client "Could not send Message error" > > Here is the stack trace > ########################################## > > org.apache.cxf.interceptor.Fault: Could not send Message. > at > org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(Mes > sageSenderInterceptor.java:48) > at > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptor > Chain.java:271) > at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319) > at > org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96) > at > org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:133) > at $Proxy79.retrieveOrder(Unknown Source) > at > com.expedia.om.odr.retrieve.OrderServiceClient.process(OrderServiceClien > t.java:45) > at > com.expedia.om.odr.retrieve.RetrieveOrderProcessor.process(RetrieveOrd > erProcessor.java:70) > at > com.expedia.om.odr.retrieve.RetrieveService.retrieveOrder(RetrieveServic > e.java:44) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j > ava:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces > sorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractI > nvoker.java:180) > at > org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java: > 96) > at > org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWS > MethodInvoker.java:178) > at > org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.j > ava:68) > at > org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java: > 75) > at > org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerI > nterceptor.java:58) > at > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) > at > java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) > at java.util.concurrent.FutureTask.run(FutureTask.java:166) > at > org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExec > utor.java:37) > at > org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(Servic > eInvokerInterceptor.java:107) > at > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptor > Chain.java:271) > at > org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiation > Observer.java:121) > at > org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTP > Destination.java:239) > at > org.apache.cxf.transport.servlet.ServletController.invokeDestination(Servlet > Controller.java:223) > at > org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.j > ava:203) > at > org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.j > ava:137) > at > org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpring > Servlet.java:158) > at > org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Abstra > ctHTTPServlet.java:243) > at > org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPS > ervlet.java:163) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:755) > at > org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPS > ervlet.java:219) > at > org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:681) > at > org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:452) > at > org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java: > 138) > at > org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:540) > at > org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.ja > va:213) > at > org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.j > ava:1083) > at > org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:379) > at > org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.jav > a:175) > at > org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.ja > va:1017) > at > org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java: > 136) > at > org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHa > ndlerCollection.java:258) > at > org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection. > java:109) > at > org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.ja > va:97) > at > org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.jav > a:317) > at > org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.ja > va:97) > at org.eclipse.jetty.server.Server.handle(Server.java:445) > at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:260) > at > org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:225) > at > org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnectio > n.java:358) > at > org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.j > ava:596) > at > org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.ja > va:527) > at java.lang.Thread.run(Thread.java:722) > Caused by: java.io.IOException: java.net.URISyntaxException: Invalid > address. Endpoint address cannot be null. at index > 0: <null> > at > org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:460) > at > org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(Mes > sageSenderInterceptor.java:46) > ... 59 more > Caused by: java.net.URISyntaxException: Invalid address. Endpoint address > cannot be null. at index 0: <null> > at > org.apache.cxf.transport.http.HTTPConduit.getURI(HTTPConduit.java:710) > at > org.apache.cxf.transport.http.HTTPConduit.getURI(HTTPConduit.java:693) > at > org.apache.cxf.transport.http.HTTPConduit.setupURI(HTTPConduit.java:649) > at > org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:458) > ... 60 more > 213019 [qtp1803965313-63] WARN > org.apache.cxf.phase.PhaseInterceptorChain > - Application {urn:expedia:om:order:v1}Order > Service#{urn:expedia:om:order:v1}retrieveOrder has thrown exception, > unwinding now > org.apache.cxf.interceptor.Fault: Could not send Message. > at > org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker. > java:162) > at > org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJA > XWSMethodInvoker.java:213) > at > org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java: > 128) > at > org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWS > MethodInvoker.java:178) > at > org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.j > ava:68) > at > org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java: > 75) > at > org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerI > nterceptor.java:58) > at > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) > at > java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) > at java.util.concurrent.FutureTask.run(FutureTask.java:166) > at > org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExec > utor.java:37) > at > org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(Servic > eInvokerInterceptor.java:107) > at > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptor > Chain.java:271) > at > org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiation > Observer.java:121) > at > org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTP > Destination.java:239) > at > org.apache.cxf.transport.servlet.ServletController.invokeDestination(Servlet > Controller.java:223) > at > org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.j > ava:203) > at > org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.j > ava:137) > at > org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpring > Servlet.java:158) > at > org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Abstra > ctHTTPServlet.java:243) > at > org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPS > ervlet.java:163) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:755) > at > org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPS > ervlet.java:219) > at > org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:681) > at > org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:452) > at > org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java: > 138) > at > org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:540) > at > org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.ja > va:213) > at > org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.j > ava:1083) > at > org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:379) > at > org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.jav > a:175) > at > org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.ja > va:1017) > at > org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java: > 136) > at > org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHa > ndlerCollection.java:258) > at > org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection. > java:109) > at > org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.ja > va:97) > at > org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.jav > a:317) > at > org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.ja > va:97) > at org.eclipse.jetty.server.Server.handle(Server.java:445) > at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:260) > at > org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:225) > at > org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnectio > n.java:358) > at > org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.j > ava:596) > at > org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.ja > va:527) > at java.lang.Thread.run(Thread.java:722) > Caused by: javax.xml.ws.WebServiceException: Could not send Message. > at > org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:144) > at $Proxy79.retrieveOrder(Unknown Source) > at > com.expedia.om.odr.retrieve.OrderServiceClient.process(OrderServiceClien > t.java:45) > at > com.expedia.om.odr.retrieve.RetrieveOrderProcessor.process(RetrieveOrd > erProcessor.java:70) > at > com.expedia.om.odr.retrieve.RetrieveService.retrieveOrder(RetrieveServic > e.java:44) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j > ava:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces > sorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractI > nvoker.java:180) > at > org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java: > 96) > ... 42 more > Caused by: java.io.IOException: java.net.URISyntaxException: Invalid > address. Endpoint address cannot be null. at index > 0: <null> > at > org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:460) > at > org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(Mes > sageSenderInterceptor.java:46) > at > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptor > Chain.java:271) > at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319) > at > org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96) > at > org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:133) > ... 52 more > Caused by: java.net.URISyntaxException: Invalid address. Endpoint address > cannot be null. at index 0: <null> > at > org.apache.cxf.transport.http.HTTPConduit.getURI(HTTPConduit.java:710) > at > org.apache.cxf.transport.http.HTTPConduit.getURI(HTTPConduit.java:693) > at > org.apache.cxf.transport.http.HTTPConduit.setupURI(HTTPConduit.java:649) > at > org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:458) > ... 60 more > > > On Fri, Jul 26, 2013 at 8:51 AM, Sachin Nikam <[email protected]> wrote: > > > Here are the details. Thanks for your help. > > private static final QName SERVICE_NAME = new > > QName("DeployedServiceNS", "DeployedService"); > > ######################################## > > <?xml version="1.0" ?> > > <wsdl:definitions targetNamespace="DeployedServiceNS" > > xmlns:messages="DeployedServiceNS2" > > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" > > xmlns:tns="DeployedServiceNS" > > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" > > xmlns:xs="http://www.w3.org/2001/XMLSchema" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xsi:schemaLocation="http://schemas.xmlsoap.org/wsdl/ > > http://schemas.xmlsoap.org/wsdl/"> > > <wsdl:types> > > > > <xs:schema attributeFormDefault="unqualified" > > elementFormDefault="unqualified" > targetNamespace="DeployedServiceNS" > > version="1.0.0" xmlns:messages="DeployedServiceNS2" xmlns:soap=" > > http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="DeployedService" > > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs=" > > http://www.w3.org/2001/XMLSchema" xmlns:xsd=" > > http://www.w3.org/2001/XMLSchema" xmlns:xsi=" > > http://www.w3.org/2001/XMLSchema-instance"> > > <xs:import namespace="DeployedServiceNS2" > > schemaLocation="DeployedServiceNS2.xsd"/> > > </xs:schema> > > > > </wsdl:types> > > <wsdl:message name="RetrieveRequest"> > > <wsdl:part element="messages:RetrieveRequest" > name="RetrieveRequest"> > > </wsdl:part> > > </wsdl:message> > > <wsdl:message name="RetrieveResponse"> > > <wsdl:part element="messages:RetrieveResponse" > name="RetrieveResponse"> > > </wsdl:part> > > </wsdl:message> > > <wsdl:portType name="SVC"> > > <wsdl:operation name="retrieve"> > > <wsdl:input message="tns:RetrieveRequest"> > > </wsdl:input> > > <wsdl:output message="tns:RetrieveResponse"> > > </wsdl:output> > > </wsdl:operation> > > </wsdl:portType> > > <wsdl:binding name="DeployedServiceSOAP" type="tns:SVC"> > > <soap:binding style="document" transport=" > > http://schemas.xmlsoap.org/soap/http"></soap:binding> > > <wsdl:operation name="retrieveXXX"> > > <soap:operation > > soapAction="DeployedServiceNS/retrieveXXX"></soap:operation> > > <wsdl:input> > > <soap:body parts="RetrieveRequest" use="literal"></soap:body> > > </wsdl:input> > > <wsdl:output> > > <soap:body parts="RetrieveResponse" use="literal"></soap:body> > > </wsdl:output> > > </wsdl:operation> > > </wsdl:binding> > > <wsdl:service name="DeployedService"> > > <wsdl:port binding="tns:DeployedServiceSOAP" > name="DeployedService"> > > </wsdl:port> > > </wsdl:service> > > </wsdl:definitions> > > > > > > On Fri, Jul 26, 2013 at 12:36 AM, Freeman Fang > <[email protected]>wrote: > > > >> Hi, > >> > >> What's your wsdl looks like, and what's the SERVICE_NAME you > >> specified here? > >> ------------- > >> Freeman(Yue) Fang > >> > >> Red Hat, Inc. > >> FuseSource is now part of Red Hat > >> Web: http://fusesource.com | http://www.redhat.com/ > >> Twitter: freemanfang > >> Blog: http://freemanfang.blogspot.com > >> http://blog.sina.com.cn/u/1473905042 > >> weibo: @Freeman小屋 > >> > >> > >> > >> On 2013-7-26, at 下午2:41, Sachin Nikam wrote: > >> > >> > I am new to apache-cxf 2.7.5 and using wsdl2java tool to generate > >> client > >> > code based on a wsdl. > >> > > >> > Here is a snippet of my code > >> > > >> > URL wsdlURL = new URL("DeployedServiceURL"); > >> > DeployedService ss = new DeployedService(wsdlURL, > SERVICE_NAME); > >> > SVC port = ss.getDeployedService(); > >> > RetrieveResponse retrieve _return = > >> port.retrieve(retrieveRequest); > >> > > >> > When I invoke the method on the port, I get the following exception > >> > ################ > >> > java.io.IOException: java.net.URISyntaxException: Invalid address. > >> Endpoint > >> > address cannot be null. at index 0: <null> ############### > >> > > >> > This error is similar to the one mentioned here > >> > > >> http://stackoverflow.com/questions/3007793/cxf-client-webservice-ping > >> -has-thrown-exception-could-not-send-message-invalid?rq=1 > >> > > >> > but the solution here is not relevant for me. > >> > Can anybody point me to the right direction? > >> > >> > >
