In my project, I have the following project structure:
I have a module that creates a war file and can be deployed inside the Tomcat application server. This module has dependencies on the Axis2 libraries:
<dependency> <groupId>org.apache.axis2</groupId> <artifactId>axis2</artifactId> </dependency> <dependency> <groupId>org.apache.axis2</groupId> <artifactId>axis2-transport-http</artifactId> </dependency> <dependency> <groupId>org.apache.axis2</groupId> <artifactId>axis2-webapp</artifactId> <type>war</type> </dependency>
And this class contains the axis2.xml file in the conf folder in the WEB-INF section.
Now this module has a dependency on a single module, which has the jar package type.
Now in my web module, in the code for my stub, I have the following code:
GazelleObjectValidator.getInstance () validateObject () ;.
XcpdValidationService is a class in the jar module (dependency), and this method calls an external web service via SSL and uses a proxy.
This web service client is created by JAX WS RI
BUT this class does not use the axis2.xml configuration from the parent module and uses its own axis configuration, by default, where my proxy is not configured ...
@WebEndpoint(name = "GazelleObjectValidatorPort") public GazelleObjectValidator getGazelleObjectValidatorPort() { return super.getPort(new QName("http://ws.validator.sch.gazelle.ihe.net/", "GazelleObjectValidatorPort"), GazelleObjectValidator.class); }
The method itself is as follows:
@WebMethod @WebResult(name = "validationResult", targetNamespace = "") @RequestWrapper(localName = "validateObject", targetNamespace = "http://ws.validator.sch.gazelle.ihe.net/", className = "net.ihe.gazelle.schematron.ValidateObject") @ResponseWrapper(localName = "validateObjectResponse", targetNamespace = "http://ws.validator.sch.gazelle.ihe.net/", className = "net.ihe.gazelle.schematron.ValidateObjectResponse") public String validateObject( @WebParam(name = "base64ObjectToValidate", targetNamespace = "") String base64ObjectToValidate, @WebParam(name = "xmlReferencedStandard", targetNamespace = "") String xmlReferencedStandard, @WebParam(name = "xmlMetadata", targetNamespace = "") String xmlMetadata) throws SOAPException_Exception ;
My GazelleObjectValidatorService is created by the following plugin:
<plugin> <groupId>org.apache.axis2</groupId> <artifactId>axis2-aar-maven-plugin</artifactId> <version>${axis2.version}</version> <extensions>true</extensions> <executions> <execution> <id>package-aar</id> <phase>prepare-package</phase> <goals> <goal>aar</goal> </goals> </execution> </executions> <configuration> <fileSets> <fileSet> <directory>${project.basedir}/src/main/resources/wsdl</directory> <outputDirectory>META-INF</outputDirectory> <includes> <include>**/*.xsd</include> </includes> </fileSet> </fileSets> <servicesXmlFile>${project.build.outputDirectory}/axis2/services.xml</servicesXmlFile> <wsdlFile>${project.build.outputDirectory}/wsdl/ClientConnectorService.wsdl</wsdlFile> </configuration> </plugin>
I tried to override transportSender in my axis2.xml configuration using my own MyCommonsHttpTransportSender:
<transportSender name="http" class="eu.epsos.pt.cc.MyCommonsHTTPTransportSender"> <parameter name="PROTOCOL">HTTP/1.1</parameter> <parameter name="Transfer-Encoding">chunked</parameter>
and
<transportSender name="https" class="eu.epsos.pt.cc.MyCommonsHTTPTransportSender"> <parameter name="PROTOCOL">HTTP/1.1</parameter> <parameter name="Transfer-Encoding">chunked</parameter> </transportSender>
who knows about proxies.
but unfortunately, since the web service client is inside the bank, which is war-dependent, it does not seem to use my axis2.xml configuration, but uses its own axis configuration, which does not know about the proxy.
This leads to the following error when you clearly see that it uses CommonsHTTPTransportSender by default and therefore throws an error:
Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:140) at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:130) at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707) at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:621) at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193) at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:404) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231) at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:578) at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.doInvoke(AxisInvocationController.java:127) at org.apache.axis2.jaxws.core.controller.impl.InvocationControllerImpl.invoke(InvocationControllerImpl.java:93) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:373) ... 40 common frames omitted
Is there a way for the WS client in the child bank to use the same configuration parent2 of the parent module (which is a deployed war and has dependencies on the 2 axis?)
UPDATE:
My WAR file has an axis2 configuration, from the source code of this war the service generated by wsimport is called, which is in the JAR, which is a dependency of the parent WAR. This service calls an external WebService, and this happens in Axis (although it does not use the axis2.xml configuration file, since this file is located in the WEB-INF JAR folder. Wouldn't it be possible to make an external WebService call in a JAR without Axis and use only JAXWS? It will solve my problems ...