Question

I am trying to create a SOAP request in PHP using NUSOAP,

    require_once('lib/nusoap.php');
   $client = new nusoap_client('wsdl_link', true);

The structure of the request i want to generate is:

 <rootlevel att1="abc" att2="def" >
  <Start>

 </Start>
</rootlevel >

The parameters are as follows:

$params=array('att1'=>'abc',
  'att2'=>'def',
  'start'=>array(/*array defined here*/));

$result = $client->call('function_name', array('rootlevel' => $params));

But with the request generated is as follows:

<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns4439="http://tempuri.org">
  <SOAP-ENV:Body>
    <rootlevel xmlns="http://site/01">
      <start>

    </start>
  </rootlevel>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Kindly tel me why my attributes are getting replaced by xmlns..

Edit: I was going through my wsdl: In the wsdl, the tag rootlevel is defined as ref="tns:rootlevel" and attributes are defined under name=rootlevel which is somewhere else in the wsdl.

For some of the attributes the request is coming proper(here the tag is defined as name and the attributes are under this tag.). but some are being replaced by xmlns.. Please let me know where im going wrong.

Was it helpful?

Solution

I solved my problem using the "send" function of NUSOAP.. Here u dont have to create an array and all.. The request can be sent in the XML format itself as follows:

$params="<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns4439="http://tempuri.org">
  <SOAP-ENV:Body>
    <rootlevel xmlns="http://site/01">
      <start>

    </start>
  </rootlevel>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>";

$result = $client->send($params, 'wsdl_url/function',0,$timeout);

Hope this Helps You.. :)

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