Re: [SOAP] SoapVar and Encoding
[email protected] (Samisa Abeysinghe)
| Newsgroups | php.soap |
|---|---|
| Message-ID | <[email protected]> |
I too have run into the "SOAP-ENC:STRUCT" problem when using the arrays.
This is why I showed you an alternative way of building the payload.
Unfortunately it looks like this form could not be supported with SOAP
ext, as far as I know. Anyway, I will investigate further and let you
know if I happen to find a solution.
Thanks,
Samisa...
Roine Edmundsson wrote:
> Thanks for the reply, it helps but dont quite solve the problem that I
> have. Though it was a reply to solve the precise layout I had written
> down. The scenario is a bit more complex though and I will do a better
> job to explain it this time.
>
> The XML snippet was a part of the message I am trying to pass and not
> the complete message.
>
> The complete part have a layout like this.
>
> -----
> <ns1:whatWeWannaDo>
> <baseOne>
> ... cut some stuff
> </baseOne>
>
> <baseTwo>
> <information>SomeInfo</information>
> <date>SomeDate</date>
> <time>SomeTime</time>
> <lineItem> -- 1 to n amount of lineItems
> <name>A</name>
> <type>B</type>
> <form>C</form>
> </lineItem>
> <lineItem>
> <name>A</name>
> <type>B</type>
> <form>C</form>
> </lineItem>
> <lineItem>
> <name>A</name>
> <type>B</type>
> <form>C</form>
> </lineItem>
> </baseTwo>
> </whatWeWannaDo>
>
> As you can see there can be 1 to n amount of lineItems and then I have
> created classes for this in the following fashion. Only writing down the
> variables with names and not the creating functions.
>
> class whatWeWannaDo
> {
> $baseOne
> $baseTwo
> }
>
> class baseOne
> {
> ... some stuff
> }
>
> class baseTwo
> {
> $information
> $date
> $time
> $lineItem = array();
> }
>
> class lineItem
> {
> $name
> $type
> $form
> }
>
> And when instantiating this I use
>
> $bOne = new baseOne();
> $bOne->setVals(... vals);
>
> $bTwo = new baseTwo();
> ...
>
> while(-- we have more lineItems -- )
> {
> $item = new lineItem()
> $item->setValues(A, B, C);
> bTwo->lineItem[] = new SoapVar($item, SOAP_ENC_OBJECT, '', '');
> }
>
>
> $bOne = new SoapVar($bOne, SOAP_ENC_OBJECT, '', '');
> $bTwo = new SoapVar($bTwo, SOAP_ENC_OBJECT, '', '');
>
> $whatWeWanna = new whatWeWannaDo($bOne, $bTwo)
> $whatWeWannaDo = new soapVar($whatWeWannaDo, SOAP_ENC_OBJECT,
> 'whatWeWannaDo', 'namespace');
>
> $soapClient->whatWeWannaDo($whatWeWannaDo);
>
> -----
> As you can see from the above snippet/stub there should be no
> specifically set namespace on the parts below <ns1:whatWeWannaDo>.
>
> And the problem I get with this is that instead of getting the layout as
> described above I get the following.
>
> -----
> <ns1:whatWeWannaDo>
> <baseOne>
> ... cut some stuff
> </baseOne>
>
> <baseTwo>
> <information>SomeInfo</information>
> <date>SomeDate</date>
> <time>SomeTime</time>
> <lineItem> -- 1 to n amount of lineItems
> <SOAP-ENC:STRUCT>
> <name>A</name>
> <type>B</type>
> <form>C</form>
> </SOAP-ENC:STRUCT>
> <SOAP-ENC:STRUCT>
> <name>A</name>
> <type>B</type>
> <form>C</form>
> </SOAP-ENC:STRUCT>
> <SOAP-ENC:STRUCT>
> <name>A</name>
> <type>B</type>
> <form>C</form>
> </SOAP-ENC:STRUCT>
> </lineItem>
> </baseTwo>
> </whatWeWannaDo>
> -----
>
> This do more detailed describe my problem. Where I do not know how to
> store the 1 to n amount of lineItems in another way then an array to get
> them all stored. And the array aint translated into lineItem parts but
> one part with SOAP-ENC:STRUCT parts below it.
>
> Any suggestions on how to solve this?
>
> And the WSDL that demands this format is out of my control and
> automagically generated by JBoss.
>
> All any any suggestions on how to solve this issue is appreciated. Did a
> try with nusoap aswell, which worked to the extent that it put the
> structure correct but lost the namespace instead.
>
> And since it was time to upgrade from php4 to php5 this looked like a
> good solution for it. Though having some kinx as you can see.
>
> /Roine Edmundsson
>
> On 30 January, 2008 - Samisa Abeysinghe wrote:
>
>
>> I am not sure of the exact code that you are using. However, it is
>> possible to produce the exact payload that you want using SoapVar and
>> SoapParam.
>> I have shown how to do this "using php5 and the built in soap
>> functionality" here -
>>
>>
>> Hope this helps.
>>
>> Samisa...
>>
>> Roine Edmundsson wrote:
>>
>>> Hello there, I was wondering if anyone have found a solution to this
>>> problem.
>>> I am currently experiencing the same behaviour and can't really find the
>>> solution to the problem.
>>>
>>> I have complex type sequence of the structure as follows.
>>>
>>> <base>
>>> <itemsLine>
>>> <name>A</name>
>>> <type>B</type>
>>> <form>C</form>
>>> <fluke>D</fluke>
>>> </itemsLine>
>>> <itemsLine>
>>> <name>A</name>
>>> <type>B</type>
>>> <form>C</form>
>>> <fluke>D</fluke>
>>> </itemsLine>
>>> <base>
>>>
>>> When building this the base is a class with an array itemsLine created in
>>> it. ANd the class itemsLine contains the variables name, type, form and
>>> fluke.
>>>
>>> The way I do it at the moment is to create and instance of the class,
>>> populate the variables, make a SOAP variable of it with SoapVar and then
>>> push it onto the array in the base class.
>>>
>>> Then before making the call I make a SoapVar from the base class.
>>>
>>> And then everything is created fine except the stuff in the array that is
>>> wrapped in a faulty manner. precisely as shown below.
>>>
>>> Anyone that know of a solution to this problem or it is just not meant to
>>> be?
>>>
>>> Would appreciate any help that can be given.
>>>
>>> Ohh, using php5 and the built in soap functionality.
>>>
>>>
>>> Jörg Werner wrote:
>>>
>>>
>>>> Hy,
>>>>
>>>> I have exactly the same problems with this xml-lists and SoapVar. I dont
>>>> find any solution. I need that the Response is in my special namespace.
>>>> And for that I need the Class SoapVar to set the namespace.
>>>>
>>>> Is there an other way to handle the namespace from the response?
>>>>
>>>> If I use the Class SoapVar my xml-lists was rewritten from:
>>>> -------------------------------------------------------------
>>>> ...
>>>> <ns2:DHDFee>
>>>> <ns2:FeeName>STANDARD</ns2:FeeName>
>>>> <ns2:PriceClass>PRIVATE</ns2:PriceClass>
>>>> <ns2:DurationDays>70</ns2:DurationDays>
>>>> <ns2:FeePrice>0.00</ns2:FeePrice>
>>>> </ns2:DHDFee>
>>>> <ns2:DHDFee>
>>>> <ns2:FeeName>STANDARD2</ns2:FeeName>
>>>> <ns2:PriceClass>PRIVATE2</ns2:PriceClass>
>>>> <ns2:DurationDays>35</ns2:DurationDays>
>>>> <ns2:FeePrice>1.00</ns2:FeePrice>
>>>> </ns2:DHDFee>
>>>> ...
>>>> -------------------------------------------------------------
>>>>
>>>> to the following Code:
>>>>
>>>> -------------------------------------------------------------
>>>> ...
>>>> <DHDFee>
>>>> <SOAP-ENC:Struct>
>>>> <FeeName>STANDARD</FeeName>
>>>> <PriceClass>PRIVATE</PriceClass>
>>>> <DurationDays>70</DurationDays>
>>>> <FeePrice>0.00</FeePrice>
>>>> </SOAP-ENC:Struct>
>>>> <SOAP-ENC:Struct>
>>>> <FeeName>STANDARD</FeeName>
>>>> <PriceClass>PRIVATE_PLUS</PriceClass>
>>>> <DurationDays>70</DurationDays>
>>>> <FeePrice>5.00</FeePrice>
>>>> </SOAP-ENC:Struct>
>>>> <DHDFee>
>>>> -------------------------------------------------------------
>>>>
>>>> the namespaces was removed too.
>>>>
>>>> What can I do?
>>>>
>>>> Thank for your help and best greetings,
>>>>
>>>> Jörg Werner
>>>>
>>>> --
>>>> PHP Soap Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>
>