There is an axis2.xml distributed in the axis2-kernel jar, used by the
client.
You can choose the axis2.xml file used by the client programmatically, as
shown below:
// create repository dir before running client
ConfigurationContext configContext =
ConfigurationContextFactory.createConfigurationContextFromFileSystem("/home/client/repo
sitory","/home/client/axis2.xml");
ServiceClient sender = new ServiceClient(configContext,null);
With logging enabled, I am seeing this locally and I confirmed that only
httpclient4 jars are on my local classpath:
[java] DEBUG_FRAME =
org.apache.axis2.transport.http.impl.httpclient4.HTTPSenderImpl.executeMethod(HTTPSenderImpl.java:873)
[java] DEBUG_FRAME =
org.apache.axis2.transport.http.impl.httpclient4.HTTPSenderImpl.sendViaPost(HTTPSenderImpl.java:238)
Regards,
Robert
On Mon, Dec 7, 2020 at 9:42 AM Frid, Michael <[email protected]> wrote:
> Hi Robert,
>
>
>
> Thank you for your answer.
>
> Our code (using old commons-httpclient) is working fine when a request is
> sent by a client and answered by our axis2 server.
>
>
>
> The problem happens when a request is sent by a Java side. As you may see
> we are using stubs generated by axis2 from a WSDL.
>
> I may be wrong, but I don’t think axis2.xml is relevant since Java request
> is not sent in the axis2 WAR context.
>
> We have no idea why the sending code decided to use
> httpclient3.HTTPSenderImpl, as we don’t even have httpclient 3.x in the
> classpatch.
>
> Is there possibility to instruct sender to use
> org.apache.axis2.transport.http.CommonsHTTPTransportSender ?
>
>
>
> Thank you
>
>
>
> *From:* robertlazarski [mailto:[email protected]]
> *Sent:* Monday, December 7, 2020 8:33 PM
> *To:* [email protected]
> *Cc:* Frid, Michael <[email protected]>
> *Subject:* Re: java.lang.ClassCastException:
> org.apache.commons.httpclient.Header cannot be cast to
> org.apache.axis2.context.NamedValue
>
>
>
> I suggest upgrading your httpclient libs to the latest, and updating your
> axis2.xml as shown below.
>
>
>
> You can see how this error was resolved for another user in this Jira
> issue.
>
>
>
> https://issues.apache.org/jira/browse/AXIS2-5740
>
>
>
> The upcoming Axis2 release will only support the latest httpclient libs.
> Remove the httpclient 3.x libs and replace as shown below.
>
>
>
> <dependency>
> <groupId>org.apache.httpcomponents</groupId>
> <artifactId>httpclient</artifactId>
> <version>4.5.13</version>
> </dependency>
> <dependency>
> <groupId>org.apache.httpcomponents</groupId>
> <artifactId>httpcore</artifactId>
> <version>4.4.13</version>
> </dependency>
>
>
>
> axis2.xml:
>
>
>
> <transportSender name="http"
>
>
>
> class="org.apache.axis2.transport.http.impl.httpclient4.HTTPClient4TransportSender">
> <parameter name="PROTOCOL">HTTP/1.1</parameter>
> <parameter name="Transfer-Encoding">chunked</parameter>
>
> <!-- If following is set to 'true', optional action part of the
> Content-Type will not be added to the SOAP 1.2 messages -->
> <!-- <parameter name="OmitSOAP12Action">true</parameter> -->
> </transportSender>
>
> <transportSender name="https"
>
>
> class="org.apache.axis2.transport.http.impl.httpclient4.HTTPClient4TransportSender">
> <parameter name="PROTOCOL">HTTP/1.1</parameter>
> <parameter name="Transfer-Encoding">chunked</parameter>
>
> </transportSender>
>
>
>
> Regards,
>
> Robert
>
>
>
> On Sat, Dec 5, 2020 at 11:34 PM Levi, Yogev <[email protected]> wrote:
>
>
>
> Frid, Michael ++
>
>
>
>
>
> BR,
>
> *Yogev Levi*
>
> Senior Software Engineer
>
> *TEOCO Ltd.*
>
> c:
>
> +972 52 4455 708
>
> p:
>
> +972 3 9269752
>
> *E-mail: [email protected] <[email protected]>*
>
> www.teoco.com
>
>
>
>
>
> *From:* Levi, Yogev
> *Sent:* Sunday, December 6, 2020 11:32 AM
> *To:* [email protected]
> *Subject:* java.lang.ClassCastException:
> org.apache.commons.httpclient.Header cannot be cast to
> org.apache.axis2.context.NamedValue
>
>
>
>
>
> server-to-server SOAP call doesn’t work, because for some reason by
> default axis2 tries to use httpClient transport (instead of
> commons-httpClient) for sending and fails.
>
>
>
> Any idea why and how to fix it?
>
> I attached the axis2.xml
>
>
>
> Caused by: java.lang.ClassCastException:
> org.apache.commons.httpclient.Header cannot be cast to
> org.apache.axis2.context.NamedValue
>
> at
> org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.addCustomHeaders(HTTPSenderImpl.java:884)
>
> at
> org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.executeMethod(HTTPSenderImpl.java:845)
>
> at
> org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.sendViaPost(HTTPSenderImpl.java:212)
>
> at
> org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:121)
>
> at
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:403)
>
> at
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:234)
>
> at
> org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:431)
>
> at
> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:399)
>
> at
> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
>
> at
> org.apache.axis2.client.OperationClient.execute(OperationClient.java:150)
>
> at
> tti.jcore.soa.service.JCoreServiceStub.getLoggedInUserApplicationRoleActions(JCoreServiceStub.java:2207)
>
> at
> tti.jcore.soa.service.JCoreServiceImpl.getLoggedInUserApplicationRoleActions(JCoreServiceImpl.java:916)
>
> ... 43 more
>
>
>
>
>
>
>
> BR,
>
> *Yogev Levi*
>
> Senior Software Engineer
>
> *TEOCO Ltd.*
>
> c:
>
> +972 52 4455 708
>
> p:
>
> +972 3 9269752
>
> *E-mail: [email protected] <[email protected]>*
>
> www.teoco.com
>
>
>
>
>
>
> ------------------------------
>
>
> PRIVILEGED AND CONFIDENTIAL
> PLEASE NOTE: The information contained in this message is privileged and
> confidential, and is intended only for the use of the individual to whom it
> is addressed and others who have been specifically authorized to receive
> it. If you are not the intended recipient, you are hereby notified that any
> dissemination, distribution or copying of this communication is strictly
> prohibited. If you have received this communication in error, or if any
> problems occur with transmission, please contact sender. Thank you.
>
>
> ------------------------------
>
> PRIVILEGED AND CONFIDENTIAL
> PLEASE NOTE: The information contained in this message is privileged and
> confidential, and is intended only for the use of the individual to whom it
> is addressed and others who have been specifically authorized to receive
> it. If you are not the intended recipient, you are hereby notified that any
> dissemination, distribution or copying of this communication is strictly
> prohibited. If you have received this communication in error, or if any
> problems occur with transmission, please contact sender. Thank you.
>