0

I develop an web application which works between different back ends (third party) as a Web Service Translator (I avoid using word Proxy-Server). In one side of this web application I want to communicate with a SOAP-Server (third party) via Proxy. The SOAP-Sever is located in a Zone that is accessible via proxy (e.g. examaple-proxy.com:80).

I have to clarify that the proxy should be set just for this part of the application and the other parts should be able to communicate to other back ends without ANY proxy. I found this question but after all comments there is no answer for my question. I really appreciate any Solution regarding this problem.


Edit

After more research and narrowing the question down I realized that for each SOAP-Service implementation there is a specific solution to set the Proxy setting. In my Case as this solution implies because I use the Apache CXF to implement the services of the SOAP Services I can do the following to set the Proxy:

import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.transport.http.HTTPConduit;

import from.my.wsdl.generated.schema.EventService;
import from.my.wsdl.generated.schema.EventPortType;


EventService es = new EventService();
EventPortType port = es.getEventPort();

Client client = ClientProxy.getClient(port);
HTTPConduit http = (HTTPConduit) client.getConduit();
http.getClient().setProxyServer("examaple-proxy.com");
http.getClient().setProxyServerPort(80);
http.getProxyAuthorization().setUserName("user proxy");
http.getProxyAuthorization().setPassword("password proxy");

Note

EventService and EventPortType are auto generated classes by wsdl. I have done this via Maven Plugin (cxf-codegen-plugin) as follows:

<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
    <execution>
        <id>generate-sources</id>
        <phase>generate-sources</phase>
        <configuration>
            <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
            <wsdlOptions>
                <wsdlOption>
                    <wsdl>${basedir}/src/main/resources/myService.wsdl</wsdl>
                </wsdlOption>
            </wsdlOptions>
        </configuration>
        <goals>
            <goal>wsdl2java</goal>
        </goals>
    </execution>
</executions>
</plugin>
Community
  • 1
  • 1
Mazy
  • 175
  • 1
  • 4
  • 9
  • 1
    Are you bound to a specific JAX-WS implementation? Here is an example of how to do it with CXF: http://stackoverflow.com/questions/17214984/ws-client-with-proxy-and-autentification – Marco A. Hernandez Sep 12 '16 at 15:47
  • @MarcoA.Hernandez I am using CXF and that works for me. Thank you. I am going to edit the question with the complete answer. – Mazy Sep 16 '16 at 05:41

0 Answers0