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="http://10.10.8.89/InPrServerSys/sp/service.php" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://10.10.8.89/InPrServerSys/sp/service.php" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
and
<wsdl:operation name="MachineHostPowerUpRegistration">
<soap:operation
soapAction="http://10.10.8.89/InPrServerSys/sp/service.php/MachineHostPowerUpRegistration" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
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
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!
source to share