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

Re: Is there a way to test, what's the output of PHP SOAP request?



On 4 February 2011 08:31, Mariaxx <sannamari28@gmail.com> wrote:
>
> Ok, it seems, that I was looking for simple __getLastRequest() function.
>
> However, I have nested array:
>
> $form = Âarray('some' => array(
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â'Info' => array('Product' => 1,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â'Insurance' => 0,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â'MaritalStatus' => 'married',
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â'Salary' => 300000
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â),
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â'Borrower' => array('Number' => '1231231234',
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â'Firstname' => 'xxxx',
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â'LastName' => 'xxxxxxxx',
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â'Email' => 'xx@xx.com'
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â),
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â'Personal' => array('bor' => '281051006U',
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â'Borrower' => 'yyyyy',
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â'Salaryr' => 300000
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â),
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â'Living' => array('Fee' => 250,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â'Rent' => 0.00
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â)
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â)
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â);
>
> I need to send
>
> <some>
> <Info>
> <Product>1</Product>
> <Insurance>0</Insurance>
> <MaritalStatus>married</MaritalStatus>
> <Salary>3000</Salary>
> </Info>
> <Borrower>
> <Number>2312132</Number>
> <Firstname>xxxxx</Firstname>
> </Borrower>
> etc.
> </some>
>
> But my arrays are printed out as
>
> <ns1:some>
> <item><key>Info</key><value>
> <item><key>Product</key><value>1</value></item>
> <item><key>Insurance</key><value>0</value></item>
> <item><key>MaritalStatus</key><value>married</value></item> etc.
>
> Apparently there's a catch, how to use arrays with SOAP? How to get rid of
> the extra tags?
>
> Maria
>
>
>
> RQuadling wrote:
>>
>> On 3 February 2011 15:14, Mariaxx <sannamari28@gmail.com> wrote:
>>>
>>> Fatal error: Class 'Tidy' not found in
>>> /home/admin/public_html/uusi/testi.php
>>> on line 142
>>>
>>> Am I missing out some files? I have two files: WAPI.php and the other
>>> with
>>> my credentials.
>>>
>>>
>>> RQuadling wrote:
>>>>
>>>> On 2 February 2011 14:01, Mariaxx <sannamari28@gmail.com> wrote:
>>>>>
>>>>> Is there a way to figure out the form of data I'm sending in an SOAP
>>>>> XML
>>>>> request.
>>>>> I need to be sure, that when I'm calling the service, that my arrays
>>>>> are
>>>>> "printed out" correctly and doesn't contain any extra (nested)
>>>>> parameters.
>>>>>
>>>>> Maria
>>>>> --
>>>>> View this message in context:
>>>>> http://old.nabble.com/Is-there-a-way-to-test%2C-what%27s-the-output-of-PHP-SOAP-request--tp30826222p30826222.html
>>>>> Sent from the Php - Soap mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> --
>>>>> PHP Soap Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>
>>>>>
>>>>
>>>> Take a look at the code here [1]. I created this to help a previous
>>>> question on this list [2].
>>>>
>>>> Whilst I only show the trace (headers sent/received for
>>>> request/response) during an exception, you can just cut'n'paste that
>>>> code to the main body.
>>>>
>>>> If you've got any concrete examples of the work you are trying to do,
>>>> then maybe I can help you some more.
>>>>
>>>> Regards,
>>>>
>>>> Richard.
>>>>
>>>> [1] http://pastebin.com/f8CBcLHc
>>>> [2] http://news.php.net/php.soap/3245
>>>>
>>>> --
>>>> Richard Quadling
>>>> Twitter : EE : Zend
>>>> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
>>>>
>>>> --
>>>> PHP Soap Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Is-there-a-way-to-test%2C-what%27s-the-output-of-PHP-SOAP-request--tp30826222p30836410.html
>>> Sent from the Php - Soap mailing list archive at Nabble.com.
>>>
>>>
>>> --
>>> PHP Soap Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> http://uk3.php.net/manual/en/book.tidy.php
>>
>> If you cannot enable Tidy, then you'll have to adjust the code. All it
>> is used for it pretty printing of the XML request/response. It isn't
>> used for any data processing purposes.
>>
>> --
>> Richard Quadling
>> Twitter : EE : Zend
>> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
>>
>> --
>> PHP Soap Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Is-there-a-way-to-test%2C-what%27s-the-output-of-PHP-SOAP-request--tp30826222p30842458.html
> Sent from the Php - Soap mailing list archive at Nabble.com.
>
>
> --
> PHP Soap Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

The way I work out how to use a SOAP service ...

1 - Use wsdl2php to convert the WSDL file to a set of PHP classes.
2 - I create an empty shell of my simple framework (tidy and the
try/catch/exception).
3 - I create an instance of the service.
4 - I look at the type of parameter required for the function I want to call.
5 - I create an instance of that class and populate it.
6 - If the parameter has additional complex types, I create instances
of them and populate them.
7 - I repeat steps 6 until all the parameters are populated.
8 - I pass the parameters to the function.
9 - I process the results.
10 - Some services do not provide complex types for their responses.
In these instances, I convert the returned XML into a simple object
using SimpleXML. That way, I'm still in the OOP world and not the XML
world.

In all of this, I never read/write XML directly. All the code is OOP.

Richard.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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




[PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux