SOAP PHP中的属性

时间:2018-09-28 14:44:58

标签: php soap

我试图在 PHP SOAP 再现XML , 并且当我尝试设置属性时会卡住。

示例:

  • what I want to reproduce
  • 我的代码如下:

    $ headerToken = new \ SoapHeader($ asxm,'fueloauth',$ auth ['accessToken']);

    $ headerContentType = new \ SoapHeader($ asxm,'Content-Type','text / xml');

    $ headerSAOPAction = new \ SoapHeader($ asxm,'SOAPAction','Retrieve');

    $soapClient = new \SoapClient(
        $wsdl,
        array(
            'trace'      => true,
            'location'   => $asxm,
            'soapaction' => 'retrieve',
            'exceptions ' => true,
        )
    );
    
    $soapClient->__setSoapHeaders(array($headerToken,$headerContentType,$headerSAOPAction));
    
    $RetrieveRequest = new \stdClass();
    
    $properties = array();
    $properties[] =  new SoapVar('email', XSD_STRING);
    $properties[] =  new SoapVar('lastclick', XSD_STRING);
    
    
    $filterClass = new \stdClass();
    $filterClass->Property = 'created_at';
    $filterClass->SimpleOperator = 'greaterThanOrEqual';
    $filterClass->Value = '08/28/2018 00:00:00 AM ';
    
    $params = array();
    $params['ObjectType'] = new SoapVar('DataExtensionObject[foo]', XSD_STRING, null, null, 'ObjectType' );
    $params['Properties'] = $properties;
    $params['Filter'] = new SoapVar($filterClass, SOAP_ENC_OBJECT);
    
    
    $RetrieveRequest->RetrieveRequest = $params;
    
  • What I get with that code

如您所见,它错过了filter的属性:

    <Filter xsi:type="SimpleFilterPart">

有人知道我如何在PHP SOAP中做到这一点吗?

我已经尝试过类似的方法,但是它不起作用。

array("foo" => array("_" => "cheese", "bar"=>"moo"));

谢谢!

1 个答案:

答案 0 :(得分:0)

构造请求而又不知道如何构造的最简单方法,则应该使用WSDL to PHP生成器,例如PackageGenerator项目。使用它会为您生成需要发送的每个参数(包括标题)的关联类。这样,处理响应也将变得更加容易。