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

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

报告相同问题?

悬赏问题

  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能