Question

I'm using Php default SoapClient for communication. I have to send data that looks something like this.

 <payloadPublication d2p1:type="GenericPublication" >
     ...
 </payloadPublication>

the only problem is how to add complexType "GenericPublication" in following code, everything else is working.

 $payloadPublication = array('payloadPublication'=> "subtags/data");
Was it helpful?

Solution 2

You could try the other answers but I solved my problem by sending XML directly and that worked for me.

$myxml = " all the xml that you want to send in the Soap request Body";

$xmlvar = new SoapVar($myxml,XSD_ANYXML);

$params->xmlDocument = (object)$xmlvar;

$save_result = $client->yourFunctionName($xmlvar);

OTHER TIPS

I'm just guessing here based on the example you provided (more info about the service would be helpful), but basically you would just do something like this:

class MYGenericPublication {
  public $subtags;
  public $name;
}

$new_pub = new MYGenericPublication;
$new_pub->subtags = array('tagA', 'tagB');
$new_pub->name = 'HiThere';

$client = new SoapClient('foo?wsdl', classmap=array('GenericPublication' => 'MYGenericPublication'));
$client->doSomethingWithPublication(array('payloadPublication' => $new_pub));

$my_pub = $client->findPublication(array('name' => 'HiThere'));
echo $my_pub->subtags[0]; // tagA
echo $my_pub->name; // HiThere
echo get_class($my_pub); // MYGenericPublication

See my answer here: Passing user-defined types in PHP SOAP for more details

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top