dongxuying7583 2014-02-20 14:44
浏览 24

PHP SOAP不起作用,但wget有效

I have to make a request to a SOAP webservice and I was using the following code with success.

$client = new SoapClient('http://myhost.foo/ws/ws.asmx?WSDL', 
    array('cache_wsdl' => false,
          'trace' => false,
          'exceptions'=>false,
          'soap_version' => SOAP_1_2));

$params['method']['param'] = $somedata;
$params['method']['clientIP'] = $_SERVER['REMOTE_ADDR'];

$result = $client->__soapCall('method', $params);

I started to receive the following error these days, at the first line of code:

PHP Fatal error:  SOAP-ERROR: Parsing WSDL: Couldn't load 
from 'http://myhost.foo/ws/ws.asmx?WSDL' : Start tag expected, 
'<' not found

Trying to debug the problem, I tested the webservice with wget and the response is correct.

wget http://myhost.foo/ws/ws.asmx?WSDL --post-file=post.xml 
--header="Content-Type: text/xml" -O response.xml

I'd like to know what I am doing wrong on this line: $client = new SoapClient('http://myhost.foo/ws/ws.asmx?WSDL', array('cache_wsdl' => false, 'trace' => false, 'exceptions'=>false, 'soap_version' => SOAP_1_2));

EDIT:

If I get the WSDL content and put on a xml file and use it locally, everything works.

$client = new SoapClient('wsdl.xml', array(
    'location'=> 'http://myhost.foo/ws/ws.asmx', 
    'uri'=> 'http://tempuri.org/', 
    'soap_version' => SOAP_1_2, 
    'trace' => true, 
    'cache_wsdl' => WSDL_CACHE_NONE, 
    'keep_alive' => false));
  • 写回答

1条回答 默认 最新

  • douman9420 2014-02-20 18:38
    关注

    If the issue just started, it suggests something has changed on the datasource side.

    I'd suggest making sure that there wasn't a change of SSL Certificate or data format. wget would still work in this case, whereas SOAP would not.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题