Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Connect to AXIS camera through SOAP (ONVIF standart)

    Hi, guys!

    I have a task:
    I need to connect to the Axis Camera through SOAP. Camera support ONVIF 1.02 standart. I'm need to use PHP.

    I think: I need to prepare right SOAP headers for accept authorization. After that I should call methods GetWsdlUrl or GetCapabilities.

    Maybe anybody had same task?
    We can talk about money.

    Example of code that do not work:

    Code:
    try {
        $HeaderSecurity = array(
        "UsernameToken" => array(
            "Username" => 'username',
            "Password" => 'password',
            'Nonce'    => '',
            'Created'  => '',
        ),
        );
    
        $headers = array();
        //$headers[] = new SoapHeader("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security", $HeaderSecurity, true);
    
        $location = 'http://<IP_ADDRESS>:<PORT>/onvif/services';
    
        $client = new SoapClient(null, array(
        'location' => $location,
        'uri'      => $location,
        'soap_version'   => SOAP_1_2,
        //'style'    => SOAP_DOCUMENT,
        //'use'      => SOAP_ENCODED,
        'encoding' => 'UTF-8',
        'trace'    => 1,
        ));
    
        $client->__setSoapHeaders($headers);
    
        $result = $client->__soapCall(
        'GetWsdlUrl',
        array()
        );
    
        var_dump($result);
    } catch (Exception $e) {
        echo '<pre>';
        var_dump($e);
        var_dump($client->__getLastRequestHeaders());
        var_dump($client->__getLastRequest());
        var_dump($client->__getLastResponse());
    }
    Example of right XML request:
    Code:
    <?xml version="1.0" ?>
    <s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
      <s:Header>
        <a:Action s:mustUnderstand="1">
          http://docs.oasis-open.org/wsn/bw-2/...bscribeRequest
        </a:Action>
        <a:MessageID>
          urn:uuid:4f39e045-dd8f-4174-bd19-062b31e98cc5
        </a:MessageID>
        <a:ReplyTo>
          <a:Address>
            http://www.w3.org/2005/08/addressing/anonymous
          </a:Address>
        </a:ReplyTo>
        <Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
          <UsernameToken>
            <Username>
              user
            </Username>
            <Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">
              zAD2ZmZBLi5Dt6cgEgZphHT2kzg=
            </Password>
            <Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
              leJ8YlvIbk+WSiGSZhE8twcAAAAAAAAAwY7fOQQAAAA=
            </Nonce>
            <Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
              2012-02-14T13:14:41.960Z
            </Created>
          </UsernameToken>
        </Security>
        <a:To s:mustUnderstand="1">
          http://46.175.145.129/onvif/services
        </a:To>
      </s:Header>
      <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Subscribe xmlns="http://docs.oasis-open.org/wsn/b-2">
          <ConsumerReference>
            <a:Address>
              http://192.168.10.50:8445/subscription-1
            </a:Address>
          </ConsumerReference>
          <InitialTerminationTime>
            PT60S
          </InitialTerminationTime>
        </Subscribe>
      </s:Body>
    </s:Envelope>
    And our XML:
    Code:
    <?xml version="1.0" ?>
    <env:Envelope xmlns:enc="http://www.w3.org/2003/05/soap-encoding" xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://46.175.145.129:8444/onvif/services" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <env:Header/>
      <env:Body>
        <ns1:GetWsdlUrl env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"/>
      </env:Body>
    </env:Envelope>
    Links:
    Onvif Specification v. 1.02 http://www.videosec.com/IP-1080p/ONVIF-Ver1.02-3.pdf
    Onvif http://onvif.org/

    Best regards.

  • #2
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Task were done. Topic can be closed.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •