Nested input sequences with PHP5 SOAP

Imagine you have a WebService that defines in its WSDL file the following input structure:

           <xsd:element name="Z_CATSIF_UPDATE_HOURS>
                        <xsd:element name="DATA">
                                    <xsd:element name="item" type="ZCO_CATSIF_COMM" minOccurs="0" maxOccurs="unbounded" />
           <xsd:complexType name="ZCO_CATSIF_COMM">
                    <xsd:element name="ELEM1" minOccurs="0">
                            <xsd:restriction base="xsd:string">
                                <xsd:maxLength value="6" />
    <wsdl:message name="rfc.Z_CATSIF_UPDATE_HOURS.Input">
        <wsdl:part name="parameters" element="rfc:Z_CATSIF_UPDATE_HOURS" />
    <wsdl:message name="rfc.Z_CATSIF_UPDATE_HOURS.Output">
        <wsdl:part name="parameters" element="rfc:Z_CATSIF_UPDATE_HOURS.Response" />
    <wsdl:portType name="UpdateHours">
        <wsdl:operation name="UpdateHours">
            <wsdl:input message="p1:rfc.Z_CATSIF_UPDATE_HOURS.Input" />
            <wsdl:output message="p1:rfc.Z_CATSIF_UPDATE_HOURS.Output" />

This is a part of the WSDL definition of an SAP XI web service. As you can see, the WSDL expects the input data in the DATA element which is a folded „item“ sequence containing the complex type ZCO_CATSIF_COMM. So we have a folded structure… in order to have PHP5’s SOAP generate the correct XML code, we use the following:

$obj = new ZCO_CATSIF_COMM($data);

$var = new SoapVar(new item($obj), SOAP_ENC_OBJECT, 'ZCO_CATSIF_COMM', 'urn:sap-com:document:sap:rfc:functions');

$caller_array = array(

  'PROJECT_ID' => $project_id,

  'DATA' => $var


$response = $soap_client->UpdateHours($caller_array);


So you see that we have two classes which do nothing than creating the corresponding properties that are defined in the WSDL complex types:

    public $ELEM1;

    function ZCO_CATSIF_COMM($data) {
      $this->ELEM1 = $data['ELEM1'];

class item {
    var $item;

    function item($obj) {
        $this->item = $obj;

Right after that, PHP5’s SOAP generates the correct XML code: […]<DATA><item><ELEM1>elem1data</ELEM1></item></DATA>

Für neue Blogupdates anmelden:

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.