Re: PHP SoapClient cannot generate valid soap request

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Apr 19, 2014, at 11:00, Adam Tong <adam.tongu@xxxxxxxxx> wrote:

> Below you will find my PHP script and a valid request generated by a soap
> software.

It would be helpful if you could also show us the output from your var_dump() calls.

> I cannot figure out what I am doing wrong in the php script. Maybe it is
> the array of elements that is wrong. Please help.

I think you may be missing a couple of wrapper arrays; try this:

$args =  array(
   ‘request’   => array(
      'OriginZip' => 18106,
      'DestinationZip'  => 91752,
      'ShipmentDetails' => array(
         'ShipmentDetail'  => array(
            'ActualClass'  => 50,
            'Weight' => 1200,
         ),
      ),
      'OriginType'   => 'O',
      'PaymentType'  => 'P',
      'COD' => array(
         'Prepaid'   => true,
         'CODAmount' => 1200.00,
      ),
   ),
);

You might also need to put the value of Prepaid into quotes (i.e., make it the string “true” instead of a boolean), depending on what the service is expecting.

If that doesn’t work, send us the var_dump() output, especially from the __getLastRequest() call, as it’s much easier to see where things are going wrong when you can see exactly what’s currently being passed and compare it against the known-correct XML from the SOAP utility.

As a tip, calling the service methods directly, instead of via __soapCall(), may be easier to read:

$results = $soapClient->RateQuote(...);

Also, I will often create a new class that extends SoapClient, then use @method phpDocumentor tags to document the service methods I’ll be using. Doing this enables the IDE to support features like code completion, among other benefits.


--
Bob Williams
SVP, Software Development
Newtek Business Services, Inc.
“The Small Business Authority”
http://www.thesba.com/


Notice: This communication, including attachments, may contain information that is confidential. It constitutes non-public information intended to be conveyed only to the designated recipient(s). If the reader or recipient of this communication is not the intended recipient, an employee or agent of the intended recipient who is responsible for delivering it to the intended recipient, or if you believe that you have received this communication in error, please notify the sender immediately by return e-mail and promptly delete this e-mail, including attachments without reading or saving them in any manner. The unauthorized use, dissemination, distribution, or reproduction of this e-mail, including attachments, is prohibited and may be unlawful. If you have received this email in error, please notify us immediately by e-mail or telephone and delete the e-mail and the attachments (if any).

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux