Jump to content

PHP5 SOAP complex data types


mmlr38

Recommended Posts

I am having problems passing complex data types from a SOAP server constructed using the built-in PHP5 SOAP extension to a SOAP client using nusoap.php or PEAR::SOAP.

 

This is what the WSDL file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.example.com/services/EorthoContent" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://www.example.com/services/EorthoContent" xmlns:intf="http://www.example.com/services/EorthoContent" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <wsdl:types>
    <schema targetNamespace="http://www.example.com/services/EorthoContent" xmlns="http://www.w3.org/2001/XMLSchema">
    <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
    <complexType name="ArrayOfArrayOf_xsd_string">
      <complexContent>
        <restriction base="soapenc:Array">
          <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[][]"/>
        </restriction>
      </complexContent>
    </complexType>
    <complexType name="ArrayOf_xsd_string">
      <complexContent>
        <restriction base="soapenc:Array">
          <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
        </restriction>
      </complexContent>
    </complexType>
    </schema>
  </wsdl:types>
....
and the rest of the functions

 

The complex type that isn't getting processed correctly is the "ArrayOfArrayOf_xsd_string" or xsd:string[][]

 

Here's an example of what the data should look like when I do a var_dump() on the returned data from a function call:

array(6) {
  [0]=>
  array(3) {
    [0]=>
    string(32) "775ab1f814d5190fb55685dbe1c6f7bd"
    [1]=>
    string(11) "Kyphoplasty"
    [2]=>
    string(115) "http://www.example.com/Booklet?ClinicID=6beb792d81342ab4b7b7bed7d91a7d79&TopicID=775ab1f814d5190fb55685dbe1c6f7bd"
  }
  [1]=>
  array(3) {
    [0]=>
    string(32) "4cdc554cbf052d95d0c6218dca340a98"
    [1]=>
    string(21) "Scheuermann's Disease"
    [2]=>
    string(115) "http://www.example.com/Booklet?ClinicID=6beb792d81342ab4b7b7bed7d91a7d79&TopicID=4cdc554cbf052d95d0c6218dca340a98"
  }
  [2]=>
  array(3) {
    [0]=>
    string(32) "012d86ee608acac7457ac979ae7d550d"
    [1]=>
    string(28) "Spinal Compression Fractures"
    [2]=>
    string(115) "http://www.example.com/Booklet?ClinicID=6beb792d81342ab4b7b7bed7d91a7d79&TopicID=012d86ee608acac7457ac979ae7d550d"
  }
  [3]=>
  array(3) {
    [0]=>
    string(32) "e2017d1a959a7159fc3514414c705aa3"
    [1]=>
    string(24) "Thoracic Disc Herniation"
    [2]=>
    string(115) "http://www.example.com/Booklet?ClinicID=6beb792d81342ab4b7b7bed7d91a7d79&TopicID=e2017d1a959a7159fc3514414c705aa3"
  }
  [4]=>
  array(3) {
    [0]=>
    string(32) "4c75b421ca09b5cb875c90e13c68d969"
    [1]=>
    string(22) "Thoracic Spine Anatomy"
    [2]=>
    string(115) "http://www.example.com/Booklet?ClinicID=6beb792d81342ab4b7b7bed7d91a7d79&TopicID=4c75b421ca09b5cb875c90e13c68d969"
  }
  [5]=>
  array(3) {
    [0]=>
    string(32) "cd057911c3a4cd05b8a79cd5d8e3a05a"
    [1]=>
    string(14) "Vertebroplasty"
    [2]=>
    string(115) "http://www.example.com/Booklet?ClinicID=6beb792d81342ab4b7b7bed7d91a7d79&TopicID=cd057911c3a4cd05b8a79cd5d8e3a05a"
  }
}

 

But here's what I am getting:

array(1) {
  ["item"]=>
  array( {
    [0]=>
    string(32) "775ab1f814d5190fb55685dbe1c6f7bd"
    [1]=>
    string(11) "Kyphoplasty"
    [2]=>
    string(115) "http://www.example.com/Booklet?ClinicID=6beb792d81342ab4b7b7bed7d91a7d79&TopicID=775ab1f814d5190fb55685dbe1c6f7bd"
    [3]=>
    array(3) {
      [0]=>
      string(32) "4cdc554cbf052d95d0c6218dca340a98"
      [1]=>
      string(21) "Scheuermann's Disease"
      [2]=>
      string(115) "http://www.example.com/Booklet?ClinicID=6beb792d81342ab4b7b7bed7d91a7d79&TopicID=4cdc554cbf052d95d0c6218dca340a98"
    }
    [4]=>
    array(3) {
      [0]=>
      string(32) "012d86ee608acac7457ac979ae7d550d"
      [1]=>
      string(28) "Spinal Compression Fractures"
      [2]=>
      string(115) "http://www.example.com/Booklet?ClinicID=6beb792d81342ab4b7b7bed7d91a7d79&TopicID=012d86ee608acac7457ac979ae7d550d"
    }
    [5]=>
    array(3) {
      [0]=>
      string(32) "e2017d1a959a7159fc3514414c705aa3"
      [1]=>
      string(24) "Thoracic Disc Herniation"
      [2]=>
      string(115) "http://www.example.com/Booklet?ClinicID=6beb792d81342ab4b7b7bed7d91a7d79&TopicID=e2017d1a959a7159fc3514414c705aa3"
    }
    [6]=>
    array(3) {
      [0]=>
      string(32) "4c75b421ca09b5cb875c90e13c68d969"
      [1]=>
      string(22) "Thoracic Spine Anatomy"
      [2]=>
      string(115) "http://www.example.com/Booklet?ClinicID=6beb792d81342ab4b7b7bed7d91a7d79&TopicID=4c75b421ca09b5cb875c90e13c68d969"
    }
    [7]=>
    array(3) {
      [0]=>
      string(32) "cd057911c3a4cd05b8a79cd5d8e3a05a"
      [1]=>
      string(14) "Vertebroplasty"
      [2]=>
      string(115) "http://www.example.com/Booklet?ClinicID=6beb792d81342ab4b7b7bed7d91a7d79&TopicID=cd057911c3a4cd05b8a79cd5d8e3a05a"
    }
  }
}

 

Any idea why it changes the structure putting that "item" as the first element in the array and then putting everything else in the array inside it?

 

I am just returning an array with a structure like so"

$ret[0][0] = "some string here";

$ret[0][1] = "some string here";

$ret[1][0] = "some string here";

$ret[1][1] = "some string here";

...

 

return $ret;

 

I have tried creating a SoapVar like this:

$ret_final = new SoapVar($ret, SOAP_ENC_OBJECT, "ArrayOfArray_xsd_string", "http://www.example.com/services/EorthoContent");

 

return $ret_final;

 

But I still get the same incorrect data structure.

 

Suggestions?

Link to comment
Share on other sites

  • 1 year later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.