doucai1901 2012-04-03 12:02
浏览 363
已采纳

为什么即使wsdl中的IP地址错误,web服务也会返回数据?

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 ?

  • 写回答

1条回答 默认 最新

  • dragonpeng200811111 2012-04-04 20:46
    关注

    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"/>.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大