Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

HELP! SOAP Header using nuSOAP

Help
walterd
2004-10-13
2013-06-06
  • walterd
    walterd
    2004-10-13

    Hi

    I have developed a .NET Web Service that require a Username and Password be sent in the SOAP Header. The SOAP Header is a class in the Web Service called "AuthenticationHeader".
    The problem occurs when a PHP Client using nuSOAP wants to call the Web Service, the user is not authenticated. I am not a PHP fundi, but the code that PHP developer sent me don't seem to send the credentials at the right time. I might be wrong, that's why I ask for help. Here's he's code:

    require_once("lib/nusoap.php");
    $wsdl=("http://SERVICE_ADDRESS?wsdl");
    $client= new soapclient($wsdl,'wsdl', true);
    $param7='getClass';
    $userName='me';
    $passWord='pass';
    $client->username = $userName;
    $client->password = $passWord;
    $client->setCredentials($userName,$passWord);
    $client->debug_flag=1;
    $var= $client->call($param7);
    $err = $client->getError();

    This is urgent, your help will be highly appreciated.

    Regards
    walterd

     
    • arcadecowboy
      arcadecowboy
      2004-10-18

      Hola
      I got the same Problem. Using a specific WebService it is reqired to send a <ServiceAuthHeader> within the SOAP:HEADER

      I solved the Problem like this (PHP), setting  requestHeaders(), because setCredentials didn't work (I think setCredentials is for basic HTTP Authetication)::
      <pre>
      $client->$requestHeaders = "&lt;ServiceAuthHeader xmlns=\&quot;http://www.interhome.com/services\&quot;>&lt;Username>".$soap_user."&lt;/Username>&lt;Password>".$soap_pass."&lt;/Password>&lt;/ServiceAuthHeader>";