Mark Mark - 10 months ago 125
PHP Question

PHP soap xml vs SoapUI xml

I have a working SOAP UI xml, and I have my SOAP request XML and they are almost identical. SOAP UI works, mine gets a null response. Here's the SOAPUI XML first

<soapenv:Envelope xmlns:soapenv="" xmlns:get="">
<get:GetDetails xmlns:get="">

and here is my PHP code and the request.

$client=new SoapClient($wsdl,array('trace' => 1, 'exception' => 0));

$auth = array(
'CorpName' => $CorpName,
'UserId' => $username,
'Signature' => $Signature
$header = new SoapHeader('','AuthHeader',$auth,false);

$parm[] = new SoapVar($LOid, XSD_STRING, null, null, 'object_id' );

var_dump($client->GetDetails( new SoapVar($parm, SOAP_ENC_OBJECT) )); //output is NULL

//and the PHP request:

output is

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="" xmlns:ns1="">

I can't tell if I'm close to creating a good request, or miles off. I'm working to make the PHP request match SOAPUI's since it works and mine doesn't.

Answer Source

The contain the nearly same information. Namespace prefixes for element nodes are exchangeable and optional. So all these 3 variants are resolved to and element node with the local name Envelope in the namespace

  • <soapenv:Envelope xmlns:soapenv=""/>
  • <SOAP-ENV:Envelope xmlns:SOAP-ENV=""/>
  • <Envelope xmlns=""/>

You can read the element name as {}:Envelope.

The same goes for the get vs ns1 namespaces prefixes. They both resolve to the same actual namespace.

But the element object_id has no namespace you XML. The sixth argument of the SoapVar constructor is the node namespace so you might want to try:

$namespace = '';
$parm[] = new SoapVar($LOid, XSD_STRING, null, null, 'object_id', $namespace);