发送到客户端时 PHP 和 SOAP 数据丢失

发布于 2024-12-20 05:42:00 字数 3267 浏览 2 评论 0原文

我有一组数据想要发送到 SOAP 客户端。 一切正常,但有一条数据未传输,如 __getLastRequest() 所示。

这是我的代码

<?php

  $test_array = array(
    "request"   =>  array(
      "dateTime"          =>  "2011-12-05T11:37:06.0000000+00:00",
      "brandId"           =>  2,
      "extSysId"          =>  11,
      "extSysPassword"    =>  "xxxxx",
      "customer"          =>  array(
        "title" => "Mr",
        "firstName" =>  "Dec",
        "lastName" => "Test-Two",
        "address" => array(
          "type" => "Residential",
          "pafValidated" => TRUE,
          "houseNumber" => "xx",
          "houseName" => "",
          "line1" => "xx xx",
          "line2" => "",
          "line3" => "xx",
          "line4" => "",
          "line5" => "",
          "postcode" => "xxx xxx"
        ),
        "phones" => array(
          0 => array(
            "type" => "Home",
            "_" => "xxx xxxxxx"
          ),
          1 => array(
            "type" => "Work",
            "preferred" => TRUE,
            "_" => ""
          ),
          2 => array(
            "type" => "Mobile",
            "preferred" => TRUE,
            "_" => ""
          )
        ),
        "email" => "[email protected]"
      ),
      "nextPurchase"  => array(
        "date" => "2014-05-01"
      ),
      "dataProtection" => array(
        "group" => FALSE,
        "thirdParty" => FALSE
      ),
      "futureContactChannels" => array(
        0 => array(
          "type" => "Whitemail",
          "option" => FALSE
        ),
        1 => array(
          "type" => "Email",
          "option" => FALSE
        ),
        2 => array(
          "type" => "Phone",
          "option" => FALSE
        ),
        3 => array(
          "type" => "SMS",
          "option" => FALSE
        )
      ),
      "vehicleRequests" => array(
        0 => array(
          "derivativeCode" => "xxxxx",
          "type" => "T"
        )
      ),
      "Retailer" => array(
        0 => array (
          "dealerCode" => "00082"
        )
      ),
      "company" => array(
        "companyName" => "",
        "jobTitle" => ""
      ),
      "campaign" => array(
        "code" => "xxxxxxxxx",
        "source" => 69
      ),
      "notes" => "blah balh: ."
    )
  );

$client = new SoapClient("/xxx/xxxx/xxxxxx/xxxxx.wsdl", array(
  "login" => "xxx", 
  "password" => "xxx",
  "location" => "http://xxx.xxx.xxx.xxx/xxxxxx/Some.asmx",
  "uri" => "urn:xmethods-delayed-quotes",
  'trace' => 1,
  'exceptions' => 1,
  'soap_version' => 'SOAP_1_1',
  'encoding' => 'UTF-8',
  'features' => 'SOAP_USE_XSI_ARRAY_TYPE'
));


$client->CallComeFunction($test_array);

echo "REQUEST:\n" . $client->__getLastRequest() . "\n";

echo "*************************************************\n";

echo "Response:\n" . $client->__getLastResponse() . "\n";

Retailed[0]['dealerCode'] 是发送的 XML 中唯一省略的信息。

有什么想法吗?

非常感谢。

I have an array of data that I want to send to a SOAP client.
It all works, but one piece of data isn't transmitted, as revealed by __getLastRequest().

Here's my code

<?php

  $test_array = array(
    "request"   =>  array(
      "dateTime"          =>  "2011-12-05T11:37:06.0000000+00:00",
      "brandId"           =>  2,
      "extSysId"          =>  11,
      "extSysPassword"    =>  "xxxxx",
      "customer"          =>  array(
        "title" => "Mr",
        "firstName" =>  "Dec",
        "lastName" => "Test-Two",
        "address" => array(
          "type" => "Residential",
          "pafValidated" => TRUE,
          "houseNumber" => "xx",
          "houseName" => "",
          "line1" => "xx xx",
          "line2" => "",
          "line3" => "xx",
          "line4" => "",
          "line5" => "",
          "postcode" => "xxx xxx"
        ),
        "phones" => array(
          0 => array(
            "type" => "Home",
            "_" => "xxx xxxxxx"
          ),
          1 => array(
            "type" => "Work",
            "preferred" => TRUE,
            "_" => ""
          ),
          2 => array(
            "type" => "Mobile",
            "preferred" => TRUE,
            "_" => ""
          )
        ),
        "email" => "[email protected]"
      ),
      "nextPurchase"  => array(
        "date" => "2014-05-01"
      ),
      "dataProtection" => array(
        "group" => FALSE,
        "thirdParty" => FALSE
      ),
      "futureContactChannels" => array(
        0 => array(
          "type" => "Whitemail",
          "option" => FALSE
        ),
        1 => array(
          "type" => "Email",
          "option" => FALSE
        ),
        2 => array(
          "type" => "Phone",
          "option" => FALSE
        ),
        3 => array(
          "type" => "SMS",
          "option" => FALSE
        )
      ),
      "vehicleRequests" => array(
        0 => array(
          "derivativeCode" => "xxxxx",
          "type" => "T"
        )
      ),
      "Retailer" => array(
        0 => array (
          "dealerCode" => "00082"
        )
      ),
      "company" => array(
        "companyName" => "",
        "jobTitle" => ""
      ),
      "campaign" => array(
        "code" => "xxxxxxxxx",
        "source" => 69
      ),
      "notes" => "blah balh: ."
    )
  );

$client = new SoapClient("/xxx/xxxx/xxxxxx/xxxxx.wsdl", array(
  "login" => "xxx", 
  "password" => "xxx",
  "location" => "http://xxx.xxx.xxx.xxx/xxxxxx/Some.asmx",
  "uri" => "urn:xmethods-delayed-quotes",
  'trace' => 1,
  'exceptions' => 1,
  'soap_version' => 'SOAP_1_1',
  'encoding' => 'UTF-8',
  'features' => 'SOAP_USE_XSI_ARRAY_TYPE'
));


$client->CallComeFunction($test_array);

echo "REQUEST:\n" . $client->__getLastRequest() . "\n";

echo "*************************************************\n";

echo "Response:\n" . $client->__getLastResponse() . "\n";

The Retailed[0]['dealerCode'] is the only piece of info that is omitted from the sent XML.

Any ideas?

Many thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

兔小萌 2024-12-27 05:42:01

正如 mac 所说,格式化代码会很好,但我注意到的一件事是“零售商”字段是唯一大写的字段。不确定 WSDL 是否对客户端发送的内容有任何影响,但有可能。

仔细检查 WSDL 并查看该字段是否应该改为“零售商”。顺便说一句,您有机会分享 WSDL 吗?

编辑
查看 WSDL 后,“零售商”是正确的选择:

<s:element minOccurs="0" maxOccurs="1" name="retailer" type="tns:Retailer"/>

有效负载的格式也应该不同,应该

"retailer" => array(
    "dealerCode" => "00082"
)

符合 WSDL

<s:complexType name="Retailer">      
    <s:attribute name="dealerCode" type="s:string"/>        
</s:complexType>

As mac says, formatting the code would be nice, but one thing I notice is the 'Retailer' field is the only one that's capitalized. Not sure if the WSDL has any influence on what is sent by the client but it might.

Double check the WSDL and see if the field should be 'retailer' instead. Any chance you can share the WSDL, btw?

EDIT
After reviewing the WSDL, 'retailer' is the way to go:

<s:element minOccurs="0" maxOccurs="1" name="retailer" type="tns:Retailer"/>

The payload should be formatted differently as well, it should be

"retailer" => array(
    "dealerCode" => "00082"
)

per the WSDL

<s:complexType name="Retailer">      
    <s:attribute name="dealerCode" type="s:string"/>        
</s:complexType>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文