PHP 5 soap and XML custom soap header

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew  Harvey

    PHP 5 soap and XML custom soap header

    Hello,
    I am having a problem getting a custom soap header to work with PHP5.
    What I require is something like this:
    <SOAP-ENV:Header>
    <USER>myusernam e</USER>
    <PASSWORD>mypas sword</PASSWORD>
    </SOAP-ENV:Header>

    What I get is :
    <SOAP-ENV:Header>
    <ns2:auth>
    <USER>myusernam e</USER>
    <PASSWORD>mypas sword</PASSWORD>
    </ns2:auth>
    </SOAP-ENV:Header>

    I would like to remove the namespace tags.
    The code I use to get this is:
    class Authstuff {
    public $USER;
    public $PASSWORD;
    public function __construct($us er, $pass) {
    $this->USER = $user;
    $this->PASSWORD = $pass;
    }
    }

    $auth = new Authstuff('myus ername', 'mypassword');
    $param = array('Authstuf f' => $auth);
    $authvalues = new SoapVar($auth,S OAP_ENC_OBJECT) ;
    $header = new
    SoapHeader('htt p://soapinterop.org/echoheader/',auth,$authval ues);


    I have tried several other ways to do this but to no avail, using a
    "null" in the namespace field returns an error.
    Any help on how to do this would be great. Also could anyone recommend
    a programmer for hire to help out on these problems as I will be having
    quite a few in the comming weeks, not on a full time basis but to help
    out with this type of question(s).

    Cheers,
    Harv

  • Darkstar 3D

    #2
    Re: PHP 5 soap and XML custom soap header

    Did you modify the envelope? Your reference to the namespace brings up
    a page (with tons of popups) and not your namespace.

    Did you try

    new SoapClient(null ,

    or

    new SoapClient("nul l",

    The first one is the correct one.

    Comment

    • Darkstar 3D

      #3
      Re: PHP 5 soap and XML custom soap header

      That should have been "Your reference to the envelope" :)

      Comment

      • Matthew  Harvey

        #4
        Re: PHP 5 soap and XML custom soap header

        I thank you for your reply, Sorry about the popup page, not sure how
        that got in there.
        I am currently using the following:
        $param = array('Authstuf f' => $auth);
        $auth = new authstuff('myus er','mypassword ');
        $authvalues=new SoapVar($auth,S OAP_ENC_OBJECT) ;
        $header = new
        SoapHeader("htt p://schemas.xmlsoap .org/soap/envelope/",notneeded,$au thvalues);

        $client = new SoapClient(null ,
        array(
        "location" => "http://localhost:8181/devserv",
        "uri" => "",
        "style" => SOAP_RPC,
        "use" => SOAP_ENCODED
        ));
        and getting:
        <SOAP-ENV:Header>
        <SOAP-ENV:notneeded>
        <USER>myuser</USER>
        <PASSWORD> mypassword</PASSWORD>
        </SOAP-ENV:notneeded>
        </SOAP-ENV:Header>

        Any idea how to get rid of the ":notneeded " parts, if I put them as
        null I get:
        Fatal error: SoapHeader::__c onstruct(): Invalid parameters. Invalid
        header name.

        any help appreciated

        Comment

        • Darkstar 3D

          #5
          Re: PHP 5 soap and XML custom soap header

          hmmm, null has worked for me in the past. My current host doesn't have
          soap so.....

          Maybe the following will work

          SoapHeader("htt p://schemas.xmlsoap .org/soap/envelope/", ,$authvalues)

          Comment

          Working...