How to call web service from php


I need to call a web service from php.
Attached you'll find:

1. The wsdl file I'm using (server.wsdl).
2. The php file that calls the web service (client.php).
3. A soap request message string that works (works.xml.txt). I generated this using the test client "saopUI". It's an example of a message that doesn't create a soap fault.
4. The soap request generated by client.php (request.php.xml) - which causes this soap fault: "Not enough message parts were received for the operation.".

You can see that the format of the message that works (works.xml.txt) is different than the format of the message generated by client.php (item 4).

How do I use php soap to create the appropriate format that will work?

You can see that the
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

At first glance your code looks correct.
The file "request.php.xml" is missing from the attachments here, perhaps this could shed some light on the problem.
In addition to the above, it looks (from the WSDL) as though the "generateLicense" command only accepts one parameter, $params.
You should try dropping the $password parameter and only pass $params (password is included in the params anyway, which is expected by the "generateLicense" element sequence.

Hope this helps.

DavRentAuthor Commented:

I have the solution:

 * This is the soap conector, it points to the wsdl
 * The wsdl should be saved in the same directory
 * or the refrence should be updated
$soap = new SoapClient('wsdl/LicenseGeneratorService.wsdl.xml');

class getALicence {
       * Thats the class, all it has is a constractor.
        public function __construct($in0, $companyName, $customerId, $productKey, $productName, $productVersion, $requestLicenseType){
            $this->in0 = $in0;  
            $temp = array('companyName'=>$companyName,
            $this->in1 = $temp;


function getLicence($in0, $companyName, $customerId, $productKey, $productName, $productVersion, $requestLicenseType)
      global $soap;
      $serial = new getALicence($in0,$companyName, $customerId, $productKey, $productName, $productVersion, $requestLicenseType);
            $result = $soap->generateLicense($serial);
      catch (SoapFault $soapFault)
            throw $soapFault;
      return $result->out;      

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.