Using dynamic IP address for service provider in WSDL file

We are running a soap server using PHP and currently the IP is hardcoded in the WSDL file to allow for operations etc. However, there are plans for the server to be on larger networks where it might not be able to dictate its own IP address and therefore needs to be allowed a dynamic address.

Here are some examples of places with this static IP address.

<wsdl:definitions name="itl_ukmachines" targetNamespace="" xmlns:soap="" xmlns:tns="" xmlns:wsdl="" xmlns:xsd="">



<wsdl:operation name="MachineHostPowerUpRegistration">

    soapAction="" />

        <soap:body use="literal" />

        <soap:body use="literal" />


Is there a way for the php server to replace these IPs with its current IP on startup, or just a special value that might get there for this to work?


source to share

2 answers

If you want clients to be able to use your service without any configuration on their side, you will have to dynamically generate the WSDL whenever it is requested.

Many platforms allow this behavior. For example, take Axis: if you have a service in http://Url/MyService

, you will also have a WSDL for the service available in http://Url/MyService?wsdl

. WSDL is generated every time.

I don't know what tools you have at your disposal, but you can easily achieve the same behavior even with simple PHP. First, replace the IP addresses with a lighter placeholder string (like BaseURL

), then when the wsdl is requested, just read the WSDL file from the filesystem, dynamically replace the whole line BaseURL

with the current actual url and return it.

Depending on what you are using as a library / framework, there may be a ready-made way to do the same with just configuration, so investigate first.

Good luck!



Another clean solution is to override the location of our webservice from the client side, e.g .:





All Articles