du9537 2013-11-21 10:49
浏览 76

如何在php中使用soap调用Web服务

The following is a sample SOAP 1.1 request and response.:
POST /atservices/1.5/atws.asmx HTTP/1.1
Host: webservices2.autotask.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://autotask.net/ATWS/v1_5/getZoneInfo"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
 xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
  <getZoneInfo xmlns="http://autotask.net/ATWS/v1_5/">
  <UserName>string</UserName>
  </getZoneInfo>
 </soap:Body>
</soap:Envelope>

we want to call web services of autotask using soap in php.can we get example for it how we should call soap client.

Its output should be like this :

HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    

xmlns:xsd="http://www.w3.org/2001/XMLSchema"    
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
 <getZoneInfoResponse xmlns="http://autotask.net/ATWS/v1_5/">
  <getZoneInfoResult>
    <URL>string</URL>
    <ErrorCode>int</ErrorCode>
    <DataBaseType>string</DataBaseType>
    <CI>int</CI>
  </getZoneInfoResult>
 </getZoneInfoResponse>
 </soap:Body>
 </soap:Envelope>
  • 写回答

2条回答 默认 最新

  • doujiu1447 2013-11-21 11:01
    关注

    Use the PHP native SoapClient along with the service WSDL, like so:

    $atservices_wsdl = "https://www.autotask.net/atservices/1.5/atws.wsdl";
    $atservices_client = new SoapClient($atservices_wsdl);
    
    $zone_info = $atservices_client->getZoneInfo("SomeUserName");
    
    print_r($zone_info); // review the returned object converted from SOAP response.
    
    echo $zone_info->DataBaseType; // this might work if it's not behind a Response object.
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿