phpwsdlsoapserver

PHP SoapServer: Set port address location


I'm using PHP's builtin SoapServer class to implement a Web service. I need to set the location attribute in the following segment of the WSDL code:

<wsdl:service name="serviceName">
  <wsdl:port name="serviceNameSoap" binding="tns:serviceNameSoap">
    <soap:address location="MY_URL_HERE" />
  </wsdl:port>
  <wsdl:port name="serviceNameSoap12" binding="tns:serviceNameSoap12">
    <soap12:address location="MY_URL_HERE" />
  </wsdl:port>
</wsdl:service>

What is the best way to do this programmatically?


Solution

  • If the location can change then save it somewhere in a configuration file or database and do a

    str_replace('MY_URL_HERE', 'http://localhost/service') 
    

    on the WSDL file before you return it.