首页 文章

ASP服务器上的SOAP Web服务通过PHP消耗

提问于
浏览
0

我正在尝试使用PHP和SOAP使用Web服务 . Web服务使用.NET构建并托管在ASP服务器上 . 我正在使用以下代码与API交互,但我一直在解析WSDL时遇到错误 . PHP UNIX服务器具有SSL证书,Web服务主机也具有SSL证书,我使用https来启动事务 .

此特定API调用请求成员资格编号的字符串:

$ wsdl ='https://domain.com/ws.asmx?wsdl'; $ client = new SOAPClient($ wsdl,array('exceptions'=> 0)); $结果= $客户机 - > IsMemberCurrent( '123456789');

错误:

Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'domain/ws.asmx?wsdl' : Start tag expected, '<' not found in index.php on line 4

我可以看到WSDL内容但是我通过PHP获得的错误消息表明它无法查看或无法处理WSDL文件?

SOAP 1.2 service description:POST /SubscriberAPI.asmx HTTP/1.1
Host: subdomain.domain.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <IsMemberCurrent xmlns="http://www.domain.com/">
      <MembershipNo>string</MembershipNo>
    </IsMemberCurrent>
  </soap12:Body>
</soap12:Envelope>

1 回答

  • 0

    您似乎无法访问WSDL文件 . 所以你需要诊断问题 .

    尝试

    echo htmlentities(file_get_contents($wsdl));

    它将使您更好地了解PHP作为响应的内容 .

    一旦您使SoapClient工作,您的下一行代码将无法按预期工作 .

    您需要将参数包装在关联数组中,否则Web服务将无法识别它 .

    此外,.NET Web服务返回的响应将是一个IsMemberCurrentResponse对象,其中包含IsMemberCurrentResult,因此您需要使用以下内容替换最后一行 .

    $params = array('MembershipNo'=>'1234567890');
    $response = $client->IsMemberCurrent($params);
    $result = $response->IsMemberCurrentResult;
    

相关问题