Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the autogenerated soap:address from a JAX-WS webservice WSDL deployed with Spring

I have a webservice implementation generated using wsimport from a WSDL. This service is deployed in a Tomcat server in a Spring webapp. The spring configuration file (only the webservice part) is like this

<wss:binding url="/fooService">
    <wss:service>
        <ws:service bean="#fooService">
    </wss:service>
</wss:binding>

When I deploy this webapp in tomcat, I can get the WSDL if I go to

http://localhost:8080/foo/fooService?wsdl 

and the wsdl soap:address property is like this:

<service name="FooService">
    <port name="FooService" binding="tns:FooServiceBinding">
        <soap:address location="http://localhost:8080/foo/fooService"/>
    </port>
</service>

And for now, it's all ok.

The problem is that in production, we have an Apache web server and this server redirects the requests to Tomcat. It works too, but when we get the WSDL, the soap:address is still localhost:8080 and we need this to be the public url to the webservice.

Any ideas?

Thank you very much.

like image 398
drublik Avatar asked Nov 27 '12 15:11

drublik


People also ask

How to create SOAP web service client in java?

To implement simple SOAP clients in Java, you can use the SAAJ framework (it is shipped with JSE 1.6 and above, but removed again in Java 11): SOAP with Attachments API for Java (SAAJ) is mainly used for dealing directly with SOAP Request/Response messages which happens behind the scenes in any Web Service API.

What is SOAP address location in the WSDL?

"soap:address" - Location of Service. This section describes 'soap:address', a SOAP extension element that specifies an address where Web service is located. Notes on the "soap:address" element: location="uri" - Provides an address where the Web service can be accessed.


1 Answers

Well, I've found one solution:

It seems that JAX-WS generates this property automatically. I've found that other webservice frameworks implementations, allow the user to change this by hardcoding the url in a property, but it seems that JAX-WS doesn't. Somebody knows if there is some way?

Anyway, I've found a workaround: Using proxyName and proxyPort properties in tomcat Connector configuration, you can tell Tomcat that is behind a proxy (in our case, Apache server) and that the "real" port for the clients is 80.

Doing this change, the autogenerated soap:address contains the correct value.

References:

  • http://metro.java.net/2.1.1/guide/HTTP_address_in_soap_address_and_import_locations.html
like image 112
drublik Avatar answered Sep 29 '22 18:09

drublik