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.
質問
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?
解決
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.
他のヒント
Another way is to override the location of our web service from client side, for example:
$soapClient->__setLocation('http://www.example.com/soapservice');