为什么 SOAP 请求为空?

Why the SOAP request is empty?

我开发的系统是使用 SOAP 从客户端导出一些数据。我有一个 link 到他们的暂存 wsdl,并实现了某种 SOAP 客户端,但不幸的是我的 SOAP 请求是空的,响应是错误的。

Link 到 WSDL: https://rewardsservices.griris.net/mapi/OrderManagementServices.svc?wsdl

调用的操作: exportPendingOrder

我的 SOAP 客户端片段:

$soap = new \SoapClient('https://rewardsservices.griris.net/mapi/OrderManagementServices.svc?wsdl', [
    'soap_version' => SOAP_1_2,
    'cache_wsdl' => WSDL_CACHE_NONE,
    'trace' => 1,
    'exception' => 1,
]);
​
$headers = [
    new SoapHeader(
        'http://www.w3.org/2005/08/addressing',
        'Action',
        'http://tempuri.org/IOrderManagementServices/exportPendingOrder',
        true
    ),
     new SoapHeader(
         'http://www.w3.org/2005/08/addressing',
         'To',
         'https://rewardsservices.griris.net/mapi/OrderManagementServices.svc',
         true
     ),
];
​
$soap->__setSoapHeaders($headers);
​
try {
    $params = [
        'parameters' => [
            'merchantNetworkID' => "XXX",
            'merchantCode' => "XXX",
            'subProgramNetworkID' => "XXX",
            'countryISOCode' => "XXX",
            'grToken' => "XXX",
            'requestId' => (new \DateTime())->getTimestamp(),
        ],
    ];
​
    $result = $soap->exportPendingOrder($params);
​
    var_dump([
        'params' => $params,
        'result' => $result,
        'request' => $soap->__getLastRequest(),
        'response' => $soap->__getLastResponse(),
    ]);
} catch (\SoapFault $exception) {
    var_dump([
        'error_message' => $exception->getMessage(),
        'request' => $soap->__getLastRequest(),
        'response' => $soap->__getLastResponse(),
    ]);
}

日志信息(包括request/response):

array(4) {
  ["params"]=>
    array(1) {
      ["parameters"]=>
        array(6) {
          ["merchantNetworkID"]=>
          string(36) "XXX"
          ["merchantCode"]=>
          string(3) "XXX"
          ["subProgramNetworkID"]=>
          string(36) "XXX"
          ["countryISOCode"]=>
          string(2) "XXX"
          ["grToken"]=>
          string(110) "XXX"
          ["requestId"]=>
          int(1619772724)
        }
      }
    ["result"]=>
      object(stdClass)#185 (1) {
        ["exportPendingOrderResult"]=>
        string(121) "{"responseCode":"1002","description":"Required field value missing","result":{"requestID":null,"serializedDataset":null}}"
      }
    ["request"]=>
      string(496) "<?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/" xmlns:ns2="http://www.w3.org/2005/08/addressing"><env:Header><ns2:Action env:mustUnderstand="true">http://tempuri.org/IOrderManagementServices/exportPendingOrder</ns2:Action><ns2:To env:mustUnderstand="true">https://rewardsservices.griris.net/mapi/OrderManagementServices.svc</ns2:To></env:Header><env:Body><ns1:exportPendingOrder/></env:Body></env:Envelope>
    "
    ["response"]=>
      string(531) "<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://tempuri.org/IOrderManagementServices/exportPendingOrderResponse</a:Action></s:Header><s:Body><exportPendingOrderResponse xmlns="http://tempuri.org/"><exportPendingOrderResult>{"responseCode":"1002","description":"Required field value missing","result":{"requestID":null,"serializedDataset":null}}</exportPendingOrderResult></exportPendingOrderResponse></s:Body></s:Envelope>"
}

您能否根据提供的 wsdl 指出我做错了什么,以及为什么我的 SOAP 请求为空?感谢您的帮助!

提前致谢,

耶夫亨

我终于成功发送了非空请求。我已经使用 SoapUI tool 检查了合作伙伴的 wsdl,它向我显示了正确的请求格式。所以正确的请求必须是以下一个:

...
$params = [
    'JsonData' => json_encode([
        'merchantNetworkID' => "XXX",
        'merchantCode' => "XXX",
        'subProgramNetworkID' => "XXX",
        'countryISOCode' => "XXX",
        'grToken' => "XXX",
        'requestId' => (new \DateTime())->getTimestamp(),
    ]),
];
...