Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
688 views
in Technique[技术] by (71.8m points)

php - Why does the webservice return data even if the IP address in the wsdl is wrong?

There is a PHP file acting as a webservice , and there is the wsdl file in which there is these lines :

<service name="ClientService">
    <documentation></documentation>
    <!-- partie 8 : Port -->
        <port name="ClientPort" binding="typens:ClientBinding">
            <soap:address location="http://192.168.1.12/imfmobile/webservice/InterfaceTransfererClient.php"/>
        </port>
</service>

The problem is that the IP address of the computer where the webservice and the wsdl reside is 192.168.1.123 , and I get data when calling a function from the PHP webservice ! So is the <soap:address tag not necessary ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Short answer: The address is just an indication (for developers or tools that generate code and configuration) of where the service might be accessible and what kind of URL to expect.

Long answer: If you look at the WSDL schema, you will see that the port element is defined as containing only a name and binding attribute, so that will be enough. Your service element migh look like this and it will be technically correct:

<service name="ClientService">
   <port name="ClientPort" binding="typens:ClientBinding" />
</service>

But port is also defined as an extensible element which allows elements from other namespaces to be added to it (like <soap:address>).

Normally (yes!) the <soap:address> should state where the real service is exposed, but unfortunately it doesn't always happen like that because of different factors like:

  • some server addresses were changed and people forgot to update the WSDL file (for contract first created WSDLs);
  • the WSDL is automatically generated by a framework (contract last) and the framework has no way of knowing at what external address the web service is exposed so it adds some default address with something it knows (like the local IP or the machine name);
  • you have a central WSDL that describes 3 identical deployed services (one in DEV, one in UAT and one in PROD) and you can't add an address for all 3 of them;
  • etc etc

WSDLs are mainly used to generate client code. Once that's done you don't need the WSDL anymore, you just need an URL where to connect to the deployed web service. The address is there as a hint for tools to add some default configuration, which you later replace with the REAL address for the calls.

Ideally what's in the WSDL should be equal to the real address, but that's some info that usually falls through maintenance tasks and things end up getting outdated. You should specify one as a hint, even if its just <soap:address location="http://localhost/imfmobile/webservice/InterfaceTransfererClient.php"/>.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...