无法将stdClass类的对象转换为SOAP请求的字符串

纽伯特

当我运行以下脚本时,我在行收到“无法将stdClass类的对象转换为SOAP请求的字符串”错误,$client->LatLonListZipCode($args)并且我不知道为什么。有任何想法吗?

<?php
$contextOptions = array(
            'ssl' => array(
                'verify_peer'   => false,
                'verify_peer_name' => false,
                'allow_self_signed' => true
            ),
            'http' => array(
                'timeout' => 5 //seconds
            )
 );

//create stream context
$stream_context = stream_context_create($contextOptions);

//create client instance (over HTTPS)
$client = new SoapClient('http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl', array(
            'cache_wsdl'  => WSDL_CACHE_NONE,
            'exceptions' => 1,
            'trace' => 1,
            'stream_context' => $stream_context,
            'soap_version'=> SOAP_1_2,
            'connection_timeout' => 5 //seconds
));//SoapClient

$args = new stdClass();
$args->zipCodeList = '10001';

$z = $client->LatLonListZipCode($args);
PawełTomkiel

异常原因

首先,此服务使用的是SOAP 1.1, 而不是 SOAP 1.2将您的$client规范更改为:

$client = new SoapClient('http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl', array(
            'cache_wsdl'  => WSDL_CACHE_NONE,
            'exceptions' => 1,
            'trace' => 1,
            'stream_context' => $stream_context,
            'soap_version'=> SOAP_1_1,//<-- note change here
            'connection_timeout' => 5 //seconds
));//SoapClient

服务定义

WSDL服务规范中所述,您可以发现该LatLonListZipCode函数定义为:

<operation name="LatLonListZipCode">
    <documentation>Returns a list of latitude and longitude pairs with each pair corresponding to an input zip code.</documentation>
    <input  message="tns:LatLonListZipCodeRequest"/>
    <output message="tns:LatLonListZipCodeResponse"/>
</operation>

和预期参数定义为:

<xsd:simpleType name="zipCodeListType">
    <xsd:restriction base='xsd:string'>
        <xsd:pattern value="\d{5}(\-\d{4})?( \d{5}(\-\d{4})?)*" />
    </xsd:restriction>
</xsd:simpleType>

正确的通话

因此我们知道,服务器仅需要一个string名为的参数zipCodeList现在我们可以推断出您的代码应如下所示:

$args = array("zipCodeList"=>'10001');
try {
$z = $client->LatLonListZipCode($args);
} catch (SoapFault $e) {
    echo $e->faultcode;
}

请注意,我正在捕获SoapFault异常。它将帮助您了解服务器端错误。PHP文档中阅读有关它的更多信息

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

无法将stdClass类的对象转换为SOAP请求的字符串

来自分类Dev

无法将类stdClass的对象转换为字符串

来自分类Dev

类stdClass的对象无法转换为字符串-Laravel

来自分类Dev

“类stdClass的对象无法转换为字符串”php

来自分类Dev

URL转换无法将类stdClass的对象转换为字符串错误

来自分类Dev

无法将类stdClass的对象转换为字符串,并且分页无法正常工作

来自分类Dev

无法将类stdClass的PHP对象转换为字符串

来自分类Dev

错误:无法将类stdClass的对象转换为字符串

来自分类Dev

污染Web服务时,无法将类stdclass的对象转换为php中的字符串

来自分类Dev

无法将类stdClass的PHP对象转换为字符串

来自分类Dev

污染Web服务时,无法将类stdclass的对象转换为php中的字符串

来自分类Dev

无法将类stdClass的对象转换为字符串Laravel 5

来自分类Dev

php对象数组无法获取对象属性(类stdClass的对象无法转换为字符串)

来自分类Dev

无法将Generator类的对象转换为字符串

来自分类Dev

Doctrine:无法将类的对象转换为字符串

来自分类Dev

在PHP中循环遍历数组,返回的类stdClass的对象无法转换为字符串

来自分类Dev

Laravel-如何解决类stdClass的对象无法转换为字符串错误

来自分类Dev

Laravel 4 Fluent Query Builder-类stdClass的对象无法转换为字符串

来自分类Dev

在PHP中循环遍历数组,返回的类stdClass的对象无法转换为字符串

来自分类Dev

如何解决类stdClass的对象无法转换为字符串PHP

来自分类Dev

类 stdClass 的对象无法在 Laravel 中转换为字符串?

来自分类Dev

使用集合差异函数时如何修复“类 stdClass 的对象无法转换为字符串”

来自分类Dev

得到一个错误:当使用 maatwebsite 导出到 excel 时,类 stdClass 的对象无法转换为字符串

来自分类Dev

wpdb类的对象无法转换为字符串

来自分类Dev

原则:类User的对象无法转换为字符串

来自分类Dev

php类DateInterval的对象无法转换为字符串

来自分类Dev

无法将对象类转换为字符串错误

来自分类Dev

php类Closure的对象无法转换为字符串

来自分类Dev

ZipArchive类的对象无法转换为字符串

Related 相关文章

  1. 1

    无法将stdClass类的对象转换为SOAP请求的字符串

  2. 2

    无法将类stdClass的对象转换为字符串

  3. 3

    类stdClass的对象无法转换为字符串-Laravel

  4. 4

    “类stdClass的对象无法转换为字符串”php

  5. 5

    URL转换无法将类stdClass的对象转换为字符串错误

  6. 6

    无法将类stdClass的对象转换为字符串,并且分页无法正常工作

  7. 7

    无法将类stdClass的PHP对象转换为字符串

  8. 8

    错误:无法将类stdClass的对象转换为字符串

  9. 9

    污染Web服务时,无法将类stdclass的对象转换为php中的字符串

  10. 10

    无法将类stdClass的PHP对象转换为字符串

  11. 11

    污染Web服务时,无法将类stdclass的对象转换为php中的字符串

  12. 12

    无法将类stdClass的对象转换为字符串Laravel 5

  13. 13

    php对象数组无法获取对象属性(类stdClass的对象无法转换为字符串)

  14. 14

    无法将Generator类的对象转换为字符串

  15. 15

    Doctrine:无法将类的对象转换为字符串

  16. 16

    在PHP中循环遍历数组,返回的类stdClass的对象无法转换为字符串

  17. 17

    Laravel-如何解决类stdClass的对象无法转换为字符串错误

  18. 18

    Laravel 4 Fluent Query Builder-类stdClass的对象无法转换为字符串

  19. 19

    在PHP中循环遍历数组,返回的类stdClass的对象无法转换为字符串

  20. 20

    如何解决类stdClass的对象无法转换为字符串PHP

  21. 21

    类 stdClass 的对象无法在 Laravel 中转换为字符串?

  22. 22

    使用集合差异函数时如何修复“类 stdClass 的对象无法转换为字符串”

  23. 23

    得到一个错误:当使用 maatwebsite 导出到 excel 时,类 stdClass 的对象无法转换为字符串

  24. 24

    wpdb类的对象无法转换为字符串

  25. 25

    原则:类User的对象无法转换为字符串

  26. 26

    php类DateInterval的对象无法转换为字符串

  27. 27

    无法将对象类转换为字符串错误

  28. 28

    php类Closure的对象无法转换为字符串

  29. 29

    ZipArchive类的对象无法转换为字符串

热门标签

归档