Help save net neutrality! Learn more.
Close

NuSoap missing SoapHeader class

Help
Richard
2010-01-14
2013-06-06
  • Richard

    Richard - 2010-01-14

    Hello,

    I am new to NuSoap and am trying to implement it with using a purolator module (oh what fun..)
    I am getting the following error: Fatal error: Class 'SoapHeader' not found in  …

    require_once('nusoap/lib/nusoap.php');
    //Define the Production (or development) Key and Password
    define("PRODUCTION_KEY", "XX");
    define("PRODUCTION_PASS", XX");
    //Define the Billing account and the account that is registered with PWS
    define("BILLING_ACCOUNT", "XX");
    define("REGISTERED_ACCOUNT", "XX");
    function createEWSSOAPClient()
    {
      /** Purpose : Creates a SOAP Client in Non-WSDL mode with the appropriate authentication and 
        *           header information
      **/
      //Set the parameters for the Non-WSDL mode SOAP communication with your Development/Production credentials
      $client = new SoapClient( "./wsdl/shippingservice.wsdl", 
                                array   (
                                        'trace' =>  true,
                                        //Development (dev)
                                        'location'=>"https://devwebservices.purolator.com/PWS/V1/Shipping/ShippingService.asmx",
                                        //Production 
                                        //'location'    =>  "https://webservices.purolator.com/PWS/V1/Shipping/ShippingService.asmx",
                                        'uri'=> "http://purolator.com/pws/datatypes/v1",
                                        'login' =>  PRODUCTION_KEY,
                                        'password'  =>  PRODUCTION_PASS
                                      )
    
                              );print $client;
      //Define the SOAP Envelope Headers
      # '<soap:Header xmlns="http://purolator.com/pws/datatypes/v1><RequestContext><Version>1.0</Version><Language>en</Language><GroupID>xxx</GroupID><RequestReference>Rating Sample</RequestReference></RequestContext></soap:Header>'; 
     $headers[] = new SoapHeader("http://purolator.com/pws/datatypes/v1", 
                                    'RequestContext', 
                                    array (
                                            'Version'           =>  '1.0',
                                            'Language'          =>  'en',
                                            'GroupID'           =>  'xxx',
                                            'RequestReference'  =>  'Rating Example'
                                          )
                                  ); 
      //Apply the SOAP Header to your client                            
      $client->__setSoapHeaders($headers);
      return $client;
    }
    

    I downloaded the NuSoap package from SourceForge.
    I read through all the NuSoap provided php file for the class 'soapheader' (not case sens.) but couldn't find it.
    Can someone guide me or help me into the right direction please?

    Thanks!

     
  • sandeep

    sandeep - 2010-01-27

    me too facing similar issue
    Fatal error: Class 'SoapVar' not found
    Fatal error: Class 'SoapHeader' not found
    My code is as below
    <?php

    require_once('nusoap.php');

    $auth = array('User_id'=>'ravi','Password'=>'r2','ExternalPartyName'=>'');

    $authvar = new SoapVar($auth, SOAP_ENC_OBJECT);
    $header = new SoapHeader('http://subscribe/IntegrationService', 'MQUserNameToken xmlns="http://subscribe/IntegrationService"', $authvar, false);

    $wsdl="http://psatish/integrationservice.asmx?WSDL";

    $client=new soapclient($wsdl, 'wsdl');

    $client->__setSoapHeaders(array($header));

    $param=array('ReferenceId'=>'98');
    echo $client->call('GetItems', $param)."\n";

    echo '<h2>Request</h2>';
      echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
      echo '<h2>Response</h2>';
      echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
    ?>

     
  • Scott Nichol

    Scott Nichol - 2010-04-26

    NuSOAP does not have SoapVar or SoapHeader classes.  The code looks like it is for the SOAP library for PHP.  Some PHP installations do not have this library available.  That is one reason NuSOAP is popular: it is just PHP code, so it does not matter how the PHP engine you are using was built.

     

Log in to post a comment.