Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Array of Type #48

Open
raziel057 opened this issue Sep 2, 2014 · 0 comments
Open

Problem with Array of Type #48

raziel057 opened this issue Sep 2, 2014 · 0 comments

Comments

@raziel057
Copy link

It's easily to show the problem when you set a Client and Server with the same transfer object model.

For example, I have an entity used by Client (classMap) and Server:

use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;

/**
 * @Soap\Alias("MeetingDetail")
 */
class MeetingDetail
{
    /**
     * @Soap\ComplexType("int", nillable=false)
     */
    private $id;

    /**
     * @Soap\ComplexType("string")
     */
    private $name;

    /**
     * @Soap\ComplexType("PTC\NoventoBundle\TO\ParticipantTypeDetail[]")
     */
    private $participantTypeList;

    public function getId()
    {
        return $this->id;
    }

    public function setId($id)
    {
        $this->id = $id;
    }

    public function getName()
    {
        return $this->name;
    }

    public function setName($name)
    {
        $this->name = $name;
    }

    public function getParticipantTypeList()
    {
        return $this->participantTypeList;
    }

    public function setParticipantTypeList($participantTypeList)
    {
        $this->participantTypeList = $participantTypeList;
    }
}

Service is defined on server side as:

class MobileController extends Controller
{
    /**
     * Get all usefull data related to a meeting
     *
     * @Soap\Method("getMeetingDetails")
     * @Soap\Param("userId", phpType = "int")
     * @Soap\Param("meetingId", phpType = "int")
     * @Soap\Result(phpType = "PTC\NoventoBundle\TO\MeetingDetail")
     */
    public function getMeetingDetailsAction($userId, $meetingId)
    {
        ...
        $this->get('logger')->info('--------- Meeting object Server Side ---------');
        $this->get('logger')->info(print_r($meetingDetail, true));

       return $meetingDetail;
     }

The call is made from client side as:

public function viewMeetingAction($id)
{
    $mobileApi = $this->get('besimple.soap.client.mobileapi');
    $meetingDetails = $mobileApi->getMeetingDetails($user->getId(), $id);

    $this->get('logger')->info('--------- Meeting object Client Side ---------');
    $this->get('logger')->info(print_r($meetingDetail, true));
}

Config on client side:

be_simple_soap:
    clients:
        MobileApi:
            wsdl: %ws_location%
            classmap:
                MeetingDetail: PTC\NoventoMobileBundle\TO\MeetingDetail
                ParticipantTypeDetail: PTC\NoventoMobileBundle\TO\ParticipantTypeDetail

Log of meetingDetail on server side, just before sending response:

[2014-09-02 08:47:45] app.INFO: --------- Meeting object Server Side ---------
[2014-09-02 08:47:45] app.INFO: PTC\NoventoBundle\TO\MeetingDetail Object
(
    [id:PTC\NoventoBundle\TO\MeetingDetail:private] => 1
    [name:PTC\NoventoBundle\TO\MeetingDetail:private] => Symposium annuel des osthéopathes d'Europe
    [participantTypeList:PTC\NoventoBundle\TO\MeetingDetail:private] => Array
        (
            [0] => PTC\NoventoBundle\TO\ParticipantTypeDetail Object
                (
                    [id:PTC\NoventoBundle\TO\ParticipantTypeDetail:private] => 2
                    [name:PTC\NoventoBundle\TO\ParticipantTypeDetail:private] => Delegation
                    [count:PTC\NoventoBundle\TO\ParticipantTypeDetail:private] => 4
                )

            [1] => PTC\NoventoBundle\TO\ParticipantTypeDetail Object
                (
                    [id:PTC\NoventoBundle\TO\ParticipantTypeDetail:private] => 3
                    [name:PTC\NoventoBundle\TO\ParticipantTypeDetail:private] => Media
                    [count:PTC\NoventoBundle\TO\ParticipantTypeDetail:private] => 1
                )
        )
)

Log of meetingDetail on client side when calling service:

[2014-09-02 08:47:45] app.INFO: --------- Meeting object Client Side ---------
[2014-09-02 08:47:45] app.INFO: PTC\NoventoMobileBundle\TO\MeetingDetail Object
(
    [id:PTC\NoventoMobileBundle\TO\MeetingDetail:private] => 1
    [name:PTC\NoventoMobileBundle\TO\MeetingDetail:private] => Symposium annuel des osthéopathes d'Europe
    [participantTypeList:PTC\NoventoMobileBundle\TO\MeetingDetail:private] => stdClass Object
        (
            [item] => Array
                (
                    [0] => PTC\NoventoMobileBundle\TO\ParticipantTypeDetail Object
                        (
                            [id:PTC\NoventoMobileBundle\TO\ParticipantTypeDetail:private] => 2
                            [name:PTC\NoventoMobileBundle\TO\ParticipantTypeDetail:private] => Delegation
                            [count:PTC\NoventoMobileBundle\TO\ParticipantTypeDetail:private] => 4
                        )

                    [1] => PTC\NoventoMobileBundle\TO\ParticipantTypeDetail Object
                        (
                            [id:PTC\NoventoMobileBundle\TO\ParticipantTypeDetail:private] => 3
                            [name:PTC\NoventoMobileBundle\TO\ParticipantTypeDetail:private] => Media
                            [count:PTC\NoventoMobileBundle\TO\ParticipantTypeDetail:private] => 1
                        )
                )
        )
)

As you can see an item node is added in the object.

Currently, the structure of the corresponding complexType in WSDL is:

<xsd:complexType name="ArrayOfParticipantTypeDetail">
    <xsd:sequence>
        <xsd:element name="item" type="tns:ParticipantTypeDetail" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
</xsd:complexType>
<xsd:complexType name="MeetingDetail">
    <xsd:all>
        <xsd:element name="id" type="xsd:int"/>
        <xsd:element name="name" type="xsd:string"/>
        <xsd:element name="participantTypeList" type="tns:ArrayOfParticipantTypeDetail"/>
    </xsd:all>
</xsd:complexType>

But I think we should have (like with EJB3):

<xsd:complexType name="MeetingDetail">
    <xsd:all>
        <xsd:element name="id" type="xsd:int"/>
        <xsd:element name="name" type="xsd:string"/>
        <xsd:element name="participantTypeList" type="tns:ParticipantTypeDetail" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:all>
</xsd:complexType>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant