• <legend id='uo3rD'><style id='uo3rD'><dir id='uo3rD'><q id='uo3rD'></q></dir></style></legend>

      <bdo id='uo3rD'></bdo><ul id='uo3rD'></ul>

      1. <i id='uo3rD'><tr id='uo3rD'><dt id='uo3rD'><q id='uo3rD'><span id='uo3rD'><b id='uo3rD'><form id='uo3rD'><ins id='uo3rD'></ins><ul id='uo3rD'></ul><sub id='uo3rD'></sub></form><legend id='uo3rD'></legend><bdo id='uo3rD'><pre id='uo3rD'><center id='uo3rD'></center></pre></bdo></b><th id='uo3rD'></th></span></q></dt></tr></i><div id='uo3rD'><tfoot id='uo3rD'></tfoot><dl id='uo3rD'><fieldset id='uo3rD'></fieldset></dl></div>
      2. <tfoot id='uo3rD'></tfoot>

        <small id='uo3rD'></small><noframes id='uo3rD'>

        如何在php中使用soap类(举例)?

        时间:2023-05-22
        • <legend id='ohlQg'><style id='ohlQg'><dir id='ohlQg'><q id='ohlQg'></q></dir></style></legend>
            • <tfoot id='ohlQg'></tfoot>

                <tbody id='ohlQg'></tbody>

              <small id='ohlQg'></small><noframes id='ohlQg'>

              <i id='ohlQg'><tr id='ohlQg'><dt id='ohlQg'><q id='ohlQg'><span id='ohlQg'><b id='ohlQg'><form id='ohlQg'><ins id='ohlQg'></ins><ul id='ohlQg'></ul><sub id='ohlQg'></sub></form><legend id='ohlQg'></legend><bdo id='ohlQg'><pre id='ohlQg'><center id='ohlQg'></center></pre></bdo></b><th id='ohlQg'></th></span></q></dt></tr></i><div id='ohlQg'><tfoot id='ohlQg'></tfoot><dl id='ohlQg'><fieldset id='ohlQg'></fieldset></dl></div>

                  <bdo id='ohlQg'></bdo><ul id='ohlQg'></ul>
                  本文介绍了如何在php中使用soap类(举例)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我想通过这个(weather)示例了解 SOAP 的基本用法.处理这些数据的价值如何?

                  I would like to learn the basic usage of SOAP through this (weather) example. How is it worthy to process this data?

                  请求:

                  POST /globalweather.asmx HTTP/1.1
                  Host: www.webservicex.net
                  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>
                      <GetWeather xmlns="http://www.webserviceX.NET">
                        <CityName>string</CityName>
                        <CountryName>string</CountryName>
                      </GetWeather>
                    </soap12:Body>
                  </soap12:Envelope>
                  HTTP/1.1 200 OK
                  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>
                      <GetWeatherResponse xmlns="http://www.webserviceX.NET">
                        <GetWeatherResult>string</GetWeatherResult>
                      </GetWeatherResponse>
                    </soap12:Body>
                  </soap12:Envelope>
                  

                  推荐答案

                  最简单的方法是:

                  $requestParams = array(
                      'CityName' => 'Berlin',
                      'CountryName' => 'Germany'
                  );
                  
                  $client = new SoapClient('http://www.webservicex.net/globalweather.asmx?WSDL');
                  $response = $client->GetWeather($requestParams);
                  
                  print_r($response);
                  

                  会输出

                  stdClass Object
                  (
                      [GetWeatherResult] => <?xml version="1.0" encoding="utf-16"?>
                  <CurrentWeather>
                    <Location>Berlin-Tegel, Germany (EDDT) 52-34N 013-19E 37M</Location>
                    <Time>Jan 26, 2012 - 07:50 AM EST / 2012.01.26 1250 UTC</Time>
                    <Wind> from the SE (130 degrees) at 14 MPH (12 KT):0</Wind>
                    <Visibility> greater than 7 mile(s):0</Visibility>
                    <SkyConditions> mostly clear</SkyConditions>
                    <Temperature> 33 F (1 C)</Temperature>
                    <Wind>Windchill: 23 F (-5 C):1</Wind>
                    <DewPoint> 21 F (-6 C)</DewPoint>
                    <RelativeHumidity> 59%</RelativeHumidity>
                    <Pressure> 30.27 in. Hg (1025 hPa)</Pressure>
                    <Status>Success</Status>
                  </CurrentWeather>
                  )
                  

                  其余的可以用 SimpleXML 或类似的东西解析.

                  The rest can then be parsed with SimpleXML or something similar.

                  请注意,响应类型特定于此 Web 服务.有更好的 Web 服务,它们不只是返回一个 xml 字符串,而是在 WSDL 中提供响应结构.

                  Note, that the kind of response is specific to this web service. There are better web services out there, which do not simply return an xml string, but rather provide the response structure within the WSDL.

                  编辑更结构化"网络服务的一个例子可能是同一站点上的 GeoIP 查找:

                  EDIT An example for a "more structured" webservice could be the GeoIP lookup on the same site:

                  $client = new SoapClient('http://www.webservicex.net/geoipservice.asmx?WSDL');
                  $result = $client->GetGeoIP(array('IPAddress' => '8.8.8.8'));
                  
                  print_r($result);
                  

                  这给你:

                  stdClass Object
                  (
                      [GetGeoIPResult] => stdClass Object
                          (
                              [ReturnCode] => 1
                              [IP] => 8.8.8.8
                              [ReturnCodeDetails] => Success
                              [CountryName] => United States
                              [CountryCode] => USA
                          )
                  
                  )
                  

                  现在您可以简单地通过调用来访问这些值

                  Now you can simply access the values by invoking

                  $country = $result->GetGeoIPResult->CountryName;
                  

                  这篇关于如何在php中使用soap类(举例)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Php SoapClient stream_context 选项 下一篇:如何转储 SoapClient 请求以进行调试?

                  相关文章

                  最新文章

                  <i id='kIQqf'><tr id='kIQqf'><dt id='kIQqf'><q id='kIQqf'><span id='kIQqf'><b id='kIQqf'><form id='kIQqf'><ins id='kIQqf'></ins><ul id='kIQqf'></ul><sub id='kIQqf'></sub></form><legend id='kIQqf'></legend><bdo id='kIQqf'><pre id='kIQqf'><center id='kIQqf'></center></pre></bdo></b><th id='kIQqf'></th></span></q></dt></tr></i><div id='kIQqf'><tfoot id='kIQqf'></tfoot><dl id='kIQqf'><fieldset id='kIQqf'></fieldset></dl></div>
                • <legend id='kIQqf'><style id='kIQqf'><dir id='kIQqf'><q id='kIQqf'></q></dir></style></legend>

                  <small id='kIQqf'></small><noframes id='kIQqf'>

                    • <bdo id='kIQqf'></bdo><ul id='kIQqf'></ul>

                    1. <tfoot id='kIQqf'></tfoot>