• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1238
  • Last Modified:

How to call web service from php

Hello,

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?

Thanks.
You can see that the
server.wsdl.txt
works.xml.txt
client.php
0
DavRent
Asked:
DavRent
  • 2
1 Solution
 
double_helixCommented:
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.
0
 
double_helixCommented:
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.

Regards,
James.
0
 
DavRentAuthor Commented:
Ok,

I have the solution:

<?php
/*
 * 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,
                              'customerId'=>$customerId,
                              'productKey'=>$productKey,
                              'productName'=>$productName,
                              'productVersion'=>$productVersion,
                              'requestLicenseType'=>$requestLicenseType);
            $this->in1 = $temp;
       }                   

}

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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now