zoukankan      html  css  js  c++  java
  • php webservice 可能存在的坑

    场景:

    今天在生产机器上调用webservice失败 报 ...failed to load external entity...

     wget一下地址发现报500错误  把wsdl去掉再wget 发现就没有任何问题 ,一想估计是生成wsdl协议时出错了  于是找一下接口方看看,但没有发现任何问题。

    用soapUI加载失败

    WSDLException (at /SOAP-ENV:Envelope): faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'. 

    用浏览器打开接口地址发现一条信息(wget居然没给我显示出来)

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
    <SOAP-ENV:Fault>
    <faultcode>SOAP-ENV:Server</faultcode>
    <faultstring>WSDL generation is not supported yet</faultstring>
    </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    
    

    WSDL generation is not supported yet  看到这句话 我在想平时加上wsdl难道是虚假的没用的? 

    单写一个php测试soap代码

    $client = new SoapClient(null,array('location'=>'http://xxx.com/WebServerApi.php?wsdl','uri' =>'http://127.0.0.1/'));

    发现去掉wsdl  和加上wsdl  完全没有任何影响,都能调取数据

    再看看SoapClient方法解释

    Description
    
    public SoapClient::SoapClient ( mixed $wsdl [, array $options ] )
    This constructor creates SoapClient objects in WSDL or non-WSDL mode.
    
    Parameters
    
    wsdl
    URI of the WSDL file or NULL if working in non-WSDL mode.

    第一个参数是填的null  表示不需定义wsdl,用这种方式是无法跨语言访问服务,因为我们访问拿不到wsdl,php之间调用还是可以,果然代码里面的地址写成?wsdl是装逼用的。

    如果把null改为wsdl地址就会抛出异常

    SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://xxx.com/WebServerApi.php?wsdl' : failed to load external entity 

    ok 原因找到 结案!

  • 相关阅读:
    设计4个线程,其中两个线程每次对j增加1,另外两个线程对j每次减少1。写出程序。
    数组模拟栈(C语言)
    JDBC数据源连接池的配置和使用实例
    servlet 具体实现
    MySQL查询数据表中数据记录(包括多表查询)
    java开发中的23中设计模式
    eclipse使用和优化配置
    将博客搬至CSDN
    itext poi 学习之旅 (3)读取数据库信息并由excel展现出来
    itext poi 学习之旅 (2)创建excel
  • 原文地址:https://www.cnblogs.com/wangxusummer/p/5673584.html
Copyright © 2011-2022 走看看