php SOAP请求发送空白元素

时间:2015-02-26 16:12:17

标签: php web-services soap

我对SOAP请求和SoapClient类相对缺乏经验。我正在尝试调用Web服务的函数,但是当我查看正在发送的请求时,它显示了我提供了一组参数的空白元素。所以我不确定我是不是正确阅读了wsdl或者问题是什么。

这是我的php:

$ns = 'http://www.WSAPI.AMS360.com/v3.0';
$response = $client->__soapCall('Login',array($loginData)); 
$clientLoginToken = $client->__getLastResponse();

//token coming back as header in soap response; strip out xml and only use the Ticket element
$clientLoginToken = strip_tags($clientLoginToken);

//need to send auth header back on subsequent requests
$soapHeader = new SoapHeader($ns,'WSAPISession',array('Ticket'=>$clientLoginToken));

//test to simply retrieve a customer record..
$customerData = array('CustomerGetByNumberRequest'=>
                     array('CustomerNumber'=>'00006195')
                );

//call CustomerGetByNumber function
$customer = $client->__soapCall('CustomerGetByNumber',
                                array($customerData),
                                null,
                                array($soapHeader),
                                $output_headers);

这是我拨打$client->__getLastRequest()时的外发XML。正如您所见,CustomerGetByNumber元素为空,即使我正在向上面的__soapCall()提供参数。

<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.WSAPI.AMS360.com/v3.0">
  <SOAP-ENV:Header>
    <ns1:WSAPISession>
      <ns1:Ticket>
           tcyOHI65U2H1yKsuvpahvoWzViAQy+tsWRElraBgKJewSQQJFi8cgS/9bjge5TlXlzH2XkxszR5u/i42dGjUnd+0JHOlQ1bJYbY5/cLgctvn4iTqoD9NPL67S0MvG5Uq
      </ns1:Ticket>
    </ns1:WSAPISession>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns1:CustomerGetByNumber />
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

1 个答案:

答案 0 :(得分:0)

我想出了这个问题。 CustomerGetByNumberRequest密钥应该只是Request