Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 856621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:15:48+00:00 2026-05-15T08:15:48+00:00

I’m trying to call a webservice with Soap in PHP5, for this, I need

  • 0

I’m trying to call a webservice with Soap in PHP5, for this, I need to use WS-Security 1.1.

(In java and .NET this is all generated automatically.)

Are there any frameworks available to generate the security headers easily in PHP? Or do I have to add the entire header myself ?

Specifications of WS-Security 1.1: http://oasis-open.org/committees/download.php/16790/wss-1.1-spec-os-SOAPMessageSecurity.pdf

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T08:15:49+00:00Added an answer on May 15, 2026 at 8:15 am

    On PHP Classes, Roger Veciana i Rovira submitted this (I just reformatted the code):

    class WSSoapClient extends SoapClient {
    
        private $username;
        private $password;
        /*Generates de WSSecurity header*/
        private function wssecurity_header() {
    
            /* The timestamp. The computer must be on time or the server you are
             * connecting may reject the password digest for security.
             */
            $timestamp = gmdate('Y-m-d\TH:i:s\Z');
            /* A random word. The use of rand() may repeat the word if the server is
             * very loaded.
             */
            $nonce = mt_rand();
            /* This is the right way to create the password digest. Using the
             * password directly may work also, but it's not secure to transmit it
             * without encryption. And anyway, at least with axis+wss4j, the nonce
             * and timestamp are mandatory anyway.
             */
            $passdigest = base64_encode(
                    pack('H*',
                            sha1(
                                    pack('H*', $nonce) . pack('a*',$timestamp).
                                    pack('a*',$this->password))));
    
            $auth = '
    <wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.'.
    'org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <wsse:UsernameToken>
        <wsse:Username>'.$this->username.'</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-'.
    'wss-username-token-profile-1.0#PasswordDigest">'.$passdigest.'</wsse:Password>
        <wsse:Nonce>'.base64_encode(pack('H*', $nonce)).'</wsse:Nonce>
        <wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-'.
    '200401-wss-wssecurity-utility-1.0.xsd">'.$timestamp.'</wsu:Created>
       </wsse:UsernameToken>
    </wsse:Security>
    ';
    
            /* XSD_ANYXML (or 147) is the code to add xml directly into a SoapVar.
             * Using other codes such as SOAP_ENC, it's really difficult to set the
             * correct namespace for the variables, so the axis server rejects the
             * xml.
             */
            $authvalues = new SoapVar($auth,XSD_ANYXML);
            $header = new SoapHeader("http://docs.oasis-open.org/wss/2004/01/oasis-".
                "200401-wss-wssecurity-secext-1.0.xsd", "Security", $authvalues,
                    true);
    
            return $header;
        }
    
        /* It's necessary to call it if you want to set a different user and
         * password
         */
        public function __setUsernameToken($username, $password) {
            $this->username = $username;
            $this->password = $password;
        }
    
    
        /* Overwrites the original method adding the security header. As you can
         * see, if you want to add more headers, the method needs to be modifyed
         */
        public function __soapCall($function_name, $arguments, $options=null,
                $input_headers=null, $output_headers=null) {
    
            $result = parent::__soapCall($function_name, $arguments, $options,
                    $this->wssecurity_header());
    
            return $result;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.