I need to create a SOAP header that looks like this: <ns:Security> <ns:UsernameToken> <ns:Username>MYUSERNAME</ns:Username> <ns:Password>MYPASSWORD</ns:Password> </ns:UsernameToken> </ns:Security> (ns: is the Oasis WS-Security namespace, http://schemas.xmlsoap.org/ws/2003/06/secext.) Looks pretty straightforward, turned out to be harder than I thought... I tried 2 approaches: PHP::SOAP (5.0.4 on Fedora Core 4) and PEAR::SOAP (0.9.3) 1. PHP::SOAP //WSDL_URL is my WSDL file //WSSE_URL is http://schemas.xmlsoap.org/ws/2003/06/secext $kaeSoapClient_WsdlUrl = WSDL_URL; $kaeSoapClient_Options = array('trace' => 1, 'exceptions' => 0); $kaeSoapClient = new SoapClient($kaeSoapClient_WsdlUrl, $kaeSoapClient_Options); $kaeUsername = new SoapVar('MYUSERNAME', XSD_STRING, 'Username', WSSE_URL); $kaePassword = new SoapVar('MYPASSWORD', XSD_STRING, 'Password', WSSE_URL); $kaeHdr = new SoapVar(array('Username' => $kaeUsername, 'Password' => $kaePassword), SOAP_ENC_OBJECT); $kaeSoapHeader_NameSpace = WSSE_URL; $kaeSoapHeader_Name = "Security"; $kaeSoapHeader_Data = $kaeHdr; $kaeSoapHeader_MustUnderstand = true; $kaeSoapHeader = new SoapHeader($kaeSoapHeader_NameSpace, $kaeSoapHeader_Name, $kaeSoapHeader_Data, $kaeSoapHeader_MustUnderstand); There are 2 problems here and I cannot figure out how to fix them: - Add the UsernameToken tags - Add the correct namespace to (all) the tags 2. PEAR::SOAP $kaeSoapClient = new SOAP_Client(WSDL_URL, true); $kaeSoapClient->setOpt('trace', 1); //TO GET STUFF IN $wire $kaeUsername = new SOAP_Value("Username", "string", 'MYUSERNAME'); $kaeUsername->namespace = WSSE_URL; $kaePassword = new SOAP_Value("Password", "string", 'MYPASSWORD'); $kaePassword->namespace = WSSE_URL; $kaeHdrData = new SOAP_Value("UsernameToken", "object", array("Username" => $kaeUsername, "Password" => $kaePassword)); $kaeHdrData->namespace = WSSE_URL; $kaeSoapHeader_Name = "Security"; $kaeSoapHeader_Type = "object"; $kaeSoapHeader_Value = $kaeHdrData; $kaeSoapHeader_MustUnderstand = 1; $kaeSoapHeader_Attr = NULL; $kaeSoapHeader = new SOAP_Header($kaeSoapHeader_Name, $kaeSoapHeader_Type, $kaeSoapHeader_Value, $kaeSoapHeader_MustUnderstand, $kaeSoapHeader_Attr); $kaeSoapHeader->namespace = WSSE_URL; $kaeSoapClient->addHeader($kaeSoapHeader); This creates the header (incl. UsernameToken tag and namespace settings) almost like I want it BUT... PEAR::SOAP adds the 'actor' attribute to the 'Security' tag without being told (not a parameter obviously as in PHP::SOAP). The SOAP server I'm talking to does not understand the attribute and refuses to authenticate. (Probably a version thing but it's outside my control.) The only way I can get it working is by modifying the PEAR module (/usr/share/pear/SOAP/Value.php, class SOAP_Header) but that doesn't seem the way to go about. Suggestions (for PHP::SOAP as wel as PEAR::SOAP) are very welcome, Peter. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- PHP Soap Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php