GithubHelp home page GithubHelp logo

milg0 / onvif-java-lib Goto Github PK

View Code? Open in Web Editor NEW
208.0 30.0 130.0 12.51 MB

ONVIF (Open Network Video Interface Forum) is a community to standardize communication between IP-based security products (like cameras). I developed a Java library for the ONVIF spezification. It helps you with the basics (you don't need to learn SOAP e.g.) but you may need to learn a few basics about the ONVIF spezification. As far as I know, this is the first public Java project for the ONVIF spezification.

Home Page: http://www.milgo.de/onvif/java-library

License: Apache License 2.0

Java 100.00%

onvif-java-lib's Introduction

onvif-java-lib

ONVIF (Open Network Video Interface Forum) is a community to standardize communication between IP-based security products (like cameras).

I developed a Java library for the ONVIF spezification. It helps you with the basics (you don't need to learn SOAP e.g.) but you may need to learn a few basics about the ONVIF spezification. As far as I know, this is the first public Java project for the ONVIF spezification.

The project is still in development, so if you need features or know better solutions than mine, let me know.

This project is not officially supported by ONVIF! It has been created in a academic project from Hochschule Trier in Germany.

onvif-java-lib's People

Contributors

milg0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onvif-java-lib's Issues

Axis cameras' replay attack protection thwarts initialization

> What steps will reproduce the problem?
1. Instantiate an OnvifDevice against an Axis camera (M5014). Fails due to 
authorization failure calling getCapabilities() in init().

> What is the expected output? What do you see instead?
Expected initialization to succeed.

> What version of the product are you using? On what operating system?
Latest source from SVN running from Eclipse on Windows


> Please provide any additional information below.

The initialization fails because Axis cameras check the created date in the 
SOAP message, and compare it against its internal clock to prevent replay 
attacks. (This protection can be disabled in the camera's configuration, but i 
would like to make connectivity work with minimal effort from the user.) 
Initialization should include a call to GetSystemDateAndTime, and then use the 
difference between the local clock and the camera's clock in the creation of 
the Created time for authentication purposes.

Original issue reported on code.google.com by [email protected] on 5 Nov 2014 at 3:16

Get Ip camera rtsp stream uri failed

I try to get my Network Ip Camera RTSP uri through onvif, but failed due to SOAPException Exception handle, i try to handle exception using External javax.xml.soap.jar but android studio fail to build.

There is my code
try{
OnvifDevice nvt = new OnvifDevice(cameraIpAddr,cameraUsername,cameraPassword);
List profiles=nvt.getDevices().getProfiles();
String profileToken=profiles.get(0).getToken();
String rtmpUrl= nvt.getMedia().getRTSPStreamUri(profileToken);
}catch (ConnectException ex){
ex.printStackTrace();
}
catch (SOAPException ex){
ex.printStackTrace();
}

Android Studio fail Log:

Error:trouble processing "javax/xml/soap/SOAPException.class":
Error:Ill-advised or mistaken usage of a core class (java.* or javax.*)
Error:when not building a core library.
Error:This is often due to inadvertently including a core library file
Error:in your application's project, when using an IDE (such as
Error:Eclipse). If you are sure you're not intentionally defining a
Error:core class, then this is the most likely explanation of what's
Error:going on.
Error:However, you might actually be trying to define a class in a core
Error:namespace, the source of which you may have taken, for example,
Error:from a non-Android virtual machine project. This will most
Error:assuredly not work. At a minimum, it jeopardizes the
Error:compatibility of your app with future versions of the platform.
Error:It is also often of questionable legality.
Error:If you really intend to build a core library -- which is only
Error:appropriate as part of creating a full virtual machine
Error:distribution, as opposed to compiling an application -- then use
Error:the "--core-library" option to suppress this error message.
Error:If you go ahead and use "--core-library" but are in fact
Error:building an application, then be forewarned that your application
Error:will still fail to build or run, at some point. Please be
Error:prepared for angry customers who find, for example, that your
Error:application ceases to function once they upgrade their operating
Error:system. You will be to blame for this problem.
Error:If you are legitimately using some code that happens to be in a
Error:core package, then the easiest safe alternative you have is to
Error:repackage that code. That is, move the classes in question into
Error:your own package namespace. This means that they will never be in
Error:conflict with core system classes. JarJar is a tool that may help
Error:you in this endeavor. If you find that you cannot do this, then
Error:that is an indication that the path you are on will ultimately
Error:lead to pain, suffering, grief, and lamentation.

How to control only zoom of my Camera (No pan and tilt)

I have an IP camera(NVT) whose name is Z3Cam-HD. I can watch live video stream via VLC player according to instructions on the camera's datasheet. Camera does not has pan and tilt hardwares, but has optical zoom hardware. It supports Onvif Profile S according to the datasheet.
I succesfully ran your "Create a connection" example code.
I faced with a problem during run of your "Get a snapshot URI" example code. The reason might be that my camera does not support getting a snapshot URI as you mentioned. But apart of System.out.println("Snapshot URI: "+nvt.getMedia().getSnapshotUri(profileToken)); , the rest of the "Create a connection" code run without any error. I omitted that line, passed through your "Basic PTZ operations" example code without any errors in "Create a connection" code.
The problem that I would like to ask is below.
Because my camera which supports Onvif (Because I can connect it with your java code) has only optical zoom hardware, I have no idea how to send a command in order to set only zoom. Although there are funtions to set PTZ (for example absoluteMove(...)), there are no functions to set only zoom. I tried setting pan and tilt to ordinary values but that caused exceptions. Therefore my question is How can I set zoom?
By the way according to isPtzOperationsSupported(...) function, PTZ operations are NOT supported.

POM declaration

Hello,
Firstly, thank you for this library.
I have tried to add it to my project with my local repository maven, but when I try to use it in my project, but impossible to import all classes like OnvifDevice, etc.
prob1

However, the library is well present in the m2/repositoty/de/onvif/onfif/1.0/onvif.jar.
prob3

And I have declared it in my pom.xml
prob2

Do you have an idea?

Thank you for your support

Error calling setVideoEncoderConfiguration media.wsdl

Hi,
I have added a method to MediaDevices.java in order to set video encoder 
configuration. This is my implementation:


/*******************************************************************************
******************************/
    public boolean setVideoEncoderConfiguration(VideoEncoderConfiguration videoEncoderConfiguration) {
        SetVideoEncoderConfiguration request = new SetVideoEncoderConfiguration();
        SetVideoEncoderConfigurationResponse response = new SetVideoEncoderConfigurationResponse();

        request.setConfiguration(videoEncoderConfiguration);
        request.setForcePersistence(true);

        try {
            response = (SetVideoEncoderConfigurationResponse) soap.createSOAPMediaRequest(request, response, true);
        }
        catch (SOAPException | ConnectException e) {
            e.printStackTrace();
            return false;
        }

        if (response == null) {
            return false;
        }

        return true;
    }
/*******************************************************************************
******************************/

When I call to this method using as parameter what I have got from calling to 
getVideoEncoderConfigurations (a VideoEncoderConfiguration object),
I got an error in SOAP.java (createSOAPRequest method).

Oct 03, 2014 1:44:02 PM 
com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPPart1_2Impl 
createEnvelopeFromSource
SEVERE: SAAJ0415: InputStream does not represent a valid SOAP 1.2 Message
javax.xml.soap.SOAPException: InputStream does not represent a valid SOAP 1.2 
Message
    at com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPPart1_2Impl.createEnvelopeFromSource(SOAPPart1_2Impl.java:72)
    at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:128)
    at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.getSOAPBody(MessageImpl.java:1351)
    at de.onvif.soap.SOAP.createSOAPRequest(SOAP.java:96)
    at de.onvif.soap.SOAP.createSOAPMediaRequest(SOAP.java:48)
    at de.onvif.soap.devices.MediaDevices.setVideoEncoderConfiguration(MediaDevices.java:180)
    at Main.main(Main.java:67)
Unhandled exception: InputStream does not represent a valid SOAP 1.2 Message



I seems that I'm receiving a SOAP 1.1 message but a SOAP 1.2 message is 
expected.

Using wireshark I have got the network traffic of failing SOAP command:

POST /onvif/services HTTP/1.1
Accept: application/soap+xml, text/html, image/gif, image/jpeg, *; q=.2, */*; 
q=.2
Content-Type: application/soap+xml; charset=utf-8
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.7.0_67
Host: 192.168.3.204
Connection: keep-alive
Content-Length: 2051

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
    xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <env:Header>
        <wsse:Security>
            <wsse:UsernameToken>
                <wsse:Username>onvif</wsse:Username>
                <wsse:Password
                    Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">WMA1PQro4b/ifF46z8cyT4Qcr1U=</wsse:Password>
                <wsse:Nonce
                    EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">MTgxMjEzMjA2NQ==</wsse:Nonce>
                <wsu:Created>2014-10-3T11:45:59Z</wsu:Created>
            </wsse:UsernameToken>
        </wsse:Security>
    </env:Header>
    <env:Body>
        <ns2:SetVideoEncoderConfiguration
            xmlns:ns10="http://www.onvif.org/ver10/schema" xmlns:ns2="http://www.onvif.org/ver10/media/wsdl"
            xmlns:ns3="http://www.w3.org/2005/08/addressing" xmlns:ns4="http://docs.oasis-open.org/wsn/b-2"
            xmlns:ns5="http://docs.oasis-open.org/wsrf/bf-2" xmlns:ns6="http://docs.oasis-open.org/wsn/t-1"
            xmlns:ns7="http://www.w3.org/2004/08/xop/include" xmlns:ns9="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
            <ns2:Configuration token="0">
                <ns10:Name>user0</ns10:Name>
                <ns10:UseCount>0</ns10:UseCount>
                <ns10:Encoding>JPEG</ns10:Encoding>
                <ns10:Resolution>
                    <ns10:Width>1024</ns10:Width>
                    <ns10:Height>768</ns10:Height>
                </ns10:Resolution>
                <ns10:Quality>80.0</ns10:Quality>
                <ns10:RateControl>
                    <ns10:FrameRateLimit>25</ns10:FrameRateLimit>
                    <ns10:EncodingInterval>0</ns10:EncodingInterval>
                    <ns10:BitrateLimit>0</ns10:BitrateLimit>
                </ns10:RateControl>
                <ns10:Multicast>
                    <ns10:Address>
                        <ns10:Type>IPv4</ns10:Type>
                        <ns10:IPv4Address>0.0.0.0</ns10:IPv4Address>
                    </ns10:Address>
                    <ns10:Port>0</ns10:Port>
                    <ns10:TTL>5</ns10:TTL>
                    <ns10:AutoStart>false</ns10:AutoStart>
                </ns10:Multicast>
                <ns10:SessionTimeout>PT60S</ns10:SessionTimeout>
            </ns2:Configuration>
            <ns2:ForcePersistence>true</ns2:ForcePersistence>
        </ns2:SetVideoEncoderConfiguration>
    </env:Body>
</env:Envelope>


HTTP/1.1 200 OK
Server: gSOAP/2.7
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 2126
Connection: close

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#"
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
    xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
    xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
    xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime="http://tempuri.org/xmime.xsd"
    xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2"
    xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tt="http://www.onvif.org/ver10/schema"
    xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:aa="http://www.axis.com/vapix/ws/action1"
    xmlns:aev="http://www.axis.com/vapix/ws/event1" xmlns:tan1="http://www.onvif.org/ver20/analytics/wsdl/RuleEngineBinding"
    xmlns:tan2="http://www.onvif.org/ver20/analytics/wsdl/AnalyticsEngineBinding"
    xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl"
    xmlns:tev1="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding"
    xmlns:tev2="http://www.onvif.org/ver10/events/wsdl/EventBinding"
    xmlns:tev3="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding"
    xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
    xmlns:tev4="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding"
    xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl"
    xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"
    xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics"
    xmlns:tnsaxis="http://www.axis.com/2009/event/topics">
    <SOAP-ENV:Header></SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <trt:SetVideoEncoderConfigurationResponse></trt:SetVideoEncoderConfigurationResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>



I realize that reponse to this method is SOAP 1.1(<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/") while request is 
SOAP 1.2 (<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope")

The method seems to work, but I got an error processing SOAP response.

Any ideas?

Thanks,

Paco






Original issue reported on code.google.com by [email protected] on 3 Oct 2014 at 11:51

getRTSPStreamUri() returns two ports in the string :80:554

I may have found a bug.

Code used is...
onvifCamera = new OnvifDevice("192.168.1.50:80", "user", "password");
some lines of code removed...
rtspUri = onvifCamera.getMedia().getRTSPStreamUri(profileToken);

This returns the following:

rtsp://192.168.1.50:80:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif

Note the double port numbers which my guess is because I specified a port when creating the onvifdevice.

If I remove the extra port the url does work ie

rtsp://192.168.1.50:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif

Using this version Jar

https://github.com/milg0/onvif-java-lib/blob/master/release/onvif-2016-03-16.jar

Get Axis camera rtsp stream uri failed

I try to get AXIS M3006 Network Camera RTSP uri through onvif, but failed with error message "Unhandled exception: InputStream does not represent a valid SOAP 1.2 Message".

There is my code

OnvifDevice onvifDevice = new OnvifDevice(cameraAddress, username, password);
onvifDevice.getSoap().setLogging(true);
String profileToken = onvifDevice.getDevices().getProfiles().get(0).getToken();
String url = onvifDevice.getMedia().getRTSPStreamUri(profileToken);

and SOAP response from log is

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
        xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#"
        xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
        xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
        xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
        xmlns:wsa5="http://www.w3.org/2005/08/addressing"
        xmlns:xmime="http://tempuri.org/xmime.xsd"
        xmlns:xop="http://www.w3.org/2004/08/xop/include"
        xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2"
        xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"
        xmlns:tt="http://www.onvif.org/ver10/schema"
        xmlns:acert="http://www.axis.com/vapix/ws/cert"
        xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2"
        xmlns:aa="http://www.axis.com/vapix/ws/action1"
        xmlns:acertificates="http://www.axis.com/vapix/ws/certificates"
        xmlns:aentry="http://www.axis.com/vapix/ws/entry"
        xmlns:aev="http://www.axis.com/vapix/ws/event1"
        xmlns:aeva="http://www.axis.com/vapix/ws/embeddedvideoanalytics1"
        xmlns:ali1="http://www.axis.com/vapix/ws/light/CommonBinding"
        xmlns:ali2="http://www.axis.com/vapix/ws/light/IntensityBinding"
        xmlns:ali3="http://www.axis.com/vapix/ws/light/AngleOfIlluminationBinding"
        xmlns:ali4="http://www.axis.com/vapix/ws/light/DayNightSynchronizeBinding"
        xmlns:ali="http://www.axis.com/vapix/ws/light"
        xmlns:apc="http://www.axis.com/vapix/ws/panopsiscalibration1"
        xmlns:arth="http://www.axis.com/vapix/ws/recordedtour1"
        xmlns:ascm="http://www.axis.com/vapix/ws/siblingcameramonitor1"
        xmlns:asd="http://www.axis.com/vapix/ws/shockdetection"
        xmlns:aweb="http://www.axis.com/vapix/ws/webserver"
        xmlns:tan1="http://www.onvif.org/ver20/analytics/wsdl/RuleEngineBinding"
        xmlns:tan2="http://www.onvif.org/ver20/analytics/wsdl/AnalyticsEngineBinding"
        xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl"
        xmlns:tds="http://www.onvif.org/ver10/device/wsdl"
        xmlns:tev1="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding"
        xmlns:tev2="http://www.onvif.org/ver10/events/wsdl/EventBinding"
        xmlns:tev3="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding"
        xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
        xmlns:tev4="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding"
        xmlns:tev="http://www.onvif.org/ver10/events/wsdl"
        xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl"
        xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"
        xmlns:trt="http://www.onvif.org/ver10/media/wsdl"
        xmlns:ter="http://www.onvif.org/ver10/error"
        xmlns:tns1="http://www.onvif.org/ver10/topics"
        xmlns:tnsaxis="http://www.axis.com/2009/event/topics">
    <SOAP-ENV:Header></SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <trt:GetStreamUriResponse>
            <trt:MediaUri>
                <tt:Uri>
                    rtsp://192.168.1.90/onvif-media/media.amp?profile=profile_1_h264&amp;sessiontimeout=60&amp;streamtype=unicast
                </tt:Uri>
                <tt:InvalidAfterConnect>false</tt:InvalidAfterConnect>
                <tt:InvalidAfterReboot>false</tt:InvalidAfterReboot>
                <tt:Timeout>PT0S</tt:Timeout>
            </trt:MediaUri>
        </trt:GetStreamUriResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

According to envelop namespace uri

xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

This response is SOAP 1.1, but SAAJ expect response as SOAP 1.2. The SOAPPart1_2Impl.java class throw exception when soapResponse(SOAPMessage) call getBody function. After catch SOAPException, getStreamUri function receive null response and return uri string as null.

Unmarshaller unmarshaller = JAXBContext.newInstance(soapResponseElem.getClass()).createUnmarshaller();
try {
    soapResponseElem = unmarshaller.unmarshal(soapResponse.getSOAPBody().extractContentAsDocument());
}
...
catch (SOAPException e) {
  onvifDevice.getLogger().error("Unhandled exception: "+e.getMessage());
  e.printStackTrace();
  return null;
}

how to stream video

hi
I download and run this library code
I try to get stream uri's
cam.getMedia().getHTTPStreamUri(p.getToken());
cam.getMedia().getTCPStreamUri(p.getToken());
cam.getMedia().getUDPStreamUri(p.getToken())
and get this output

http://172.22.150.32:80/profile1/media.smp
rtsp://172.22.150.32:554/onvif/profile1/media.smp
rtsp://172.22.150.32:554/onvif/profile1/media.smp

now I don't know how to get video stream from camera (I want Save or Transfer)
I googled java rtsp client but cant find any useful code or library
can you help me

About getNode And getNodes Methods Problems!

I'm using the PtzDevices.GetNode(token) method to return "Optional Action Not Implemented".

Request SOAP Message (GetNode): <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><env:Header><wsse:Security><wsse:UsernameToken><wsse:Username>admin</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">q2VNsPaprF9if/tHlB5BsyX1R48=</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">LTM4MTE5MDky</wsse:Nonce><wsu:Created>2019-11-6T08:09:50Z</wsu:Created></wsse:UsernameToken></wsse:Security></env:Header><env:Body><GetNode xmlns="http://www.onvif.org/ver20/ptz/wsdl"><NodeToken>PTZNODETOKEN</NodeToken></GetNode></env:Body></env:Envelope>
Response SOAP Message (GetNodeResponse): <?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tst="http://www.onvif.org/ver10/storage/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12" xmlns:http="http://schemas.xmlsoap.org/wsdl/http" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:wsadis="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2" xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tnshik="http://www.hikvision.com/2011/event/topics" xmlns:hikwsd="http://www.onvifext.com/onvif/ext/ver10/wsdl" xmlns:hikxsd="http://www.onvifext.com/onvif/ext/ver10/schema" xmlns:tas="http://www.onvif.org/ver10/advancedsecurity/wsdl"><env:Body><env:Fault><env:Code><env:Value>env:Receiver</env:Value>
<env:Subcode><env:Value>ter:ActionNotSupported</env:Value>
<env:Subcode><env:Value>ter:InvalidOperation</env:Value>
</env:Subcode>
</env:Subcode>
</env:Code>
<env:Reason><env:Text xml:lang="en">Optional Action Not Implemented</env:Text>
</env:Reason>
</env:Fault>
</env:Body>
</env:Envelope>

The debug found that the request in the getNode method requested the /onvif/device_service url.
In PtzDevices.java line 112 .

response = (GetNodeResponse) soap.createSOAPDeviceRequest(request, response, true);

I modified the code and executed without errors:

response = (GetNodeResponse) soap.createSOAPPtzRequest(request, response, true);

Please excuse my poor English !!!!

Exception in test code

An exception has occured when I tried to run test code below:

import java.net.ConnectException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.xml.soap.SOAPException;

import de.onvif.soap.OnvifDevice;

public class OnvifTest {
   public static void main(String[] args) {
      try {
         OnvifDevice nvt = new OnvifDevice("192.168.66.59");
         Date nvtDate = nvt.getDevices().getDate();
         System.out.println(new SimpleDateFormat().format(nvtDate));
      }
      catch (ConnectException e) {
         System.err.println("Could not connect to NVT.");
      }
      catch (SOAPException e) {
         e.printStackTrace();
      }
   }
}

My camera does definitely works, because I watched IP stream via VLC player according to datasheet of camera. I think the reason of the problem is related to file tree of my Java project. I searched for solutions on Google a lot. Unfortunately there are not enough solutions working for me and I am a newbie to SOAP. How can I handle this problem? Thanks in advance.
Console output can be seen below:

Request SOAP Message (GetCapabilities): <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Header/><env:Body><GetCapabilities xmlns="http://www.onvif.org/ver10/device/wsdl"/></env:Body></env:Envelope>
Oca 04, 2018 10:21:42 AM com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection post
SEVERE: SAAJ0008: Bad Response; Method Not Allowed
Unexpected response. Response should be from class class org.onvif.ver10.device.wsdl.GetCapabilitiesResponse, but response is: null
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (405Method Not Allowed
	at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
	at de.onvif.soap.SOAP.createSOAPRequest(SOAP.java:89)
	at de.onvif.soap.devices.InitialDevices.getCapabilities(InitialDevices.java:141)
	at de.onvif.soap.OnvifDevice.init(OnvifDevice.java:148)
	at de.onvif.soap.OnvifDevice.<init>(OnvifDevice.java:89)
	at de.onvif.soap.OnvifDevice.<init>(OnvifDevice.java:105)
	at OnvifTest.main(OnvifTest.java:12)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (405Method Not Allowed
	at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
	... 7 more

CAUSE:

com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (405Method Not Allowed
	at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
	at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
	at de.onvif.soap.SOAP.createSOAPRequest(SOAP.java:89)
	at de.onvif.soap.devices.InitialDevices.getCapabilities(InitialDevices.java:141)
	at de.onvif.soap.OnvifDevice.init(OnvifDevice.java:148)
	at de.onvif.soap.OnvifDevice.<init>(OnvifDevice.java:89)
	at de.onvif.soap.OnvifDevice.<init>(OnvifDevice.java:105)
	at OnvifTest.main(OnvifTest.java:12)

CAUSE:

com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (405Method Not Allowed
	at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
	at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
	at de.onvif.soap.SOAP.createSOAPRequest(SOAP.java:89)
	at de.onvif.soap.devices.InitialDevices.getCapabilities(InitialDevices.java:141)
	at de.onvif.soap.OnvifDevice.init(OnvifDevice.java:148)
	at de.onvif.soap.OnvifDevice.<init>(OnvifDevice.java:89)
	at de.onvif.soap.OnvifDevice.<init>(OnvifDevice.java:105)
	at OnvifTest.main(OnvifTest.java:12)

Instructions for running in java 11+?

Anyone have a solution for running this on java 11+ that has depreciated a lot of the soap and ee calls?
Sure wish onvif was a json based protocol! I hate having things break due to a compile time class not found.

Currently getting:

javax.xml.ws.WebServiceException: org.apache.cxf.binding.soap.SoapFault: Problem writing SAAJ model to stream: Unable to create message factory for SOAP: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found
	at org.apache.cxf.jaxws.JaxWsClientProxy.mapException(JaxWsClientProxy.java:193)
	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145)
	at com.sun.proxy.$Proxy80.getCapabilities(Unknown Source)
	at de.onvif.soap.OnvifDevice.init(OnvifDevice.java:139)
	at de.onvif.soap.OnvifDevice.<init>(OnvifDevice.java:88)
	at de.onvif.soap.OnvifDevice.<init>(OnvifDevice.java:103)
	at com.nuspectra.siteproxy.cam.onvif.OnvifCommander.<init>(OnvifCommander.java:371)

ipv6

Thanks for the author's work, does the project support ipv6?

How to handle zoom and focus in axis p5635 ptz camera?

When zoom function is called from ONVIF library. focus control is responding instead of zoom control. Is there way to control both zoom and focus control of axis camera(model no : P5635) from ONVIF. In other words, focus is additional parameter in this camera. How to integrate this parameter in ONVIF so that we operations on zoom as well as focus. Could you please guide me regarding this issue?

Axis P5635 for reference

Unusually long time taken to provide required information ("No connection to camera, please try again.") if device unavailable

There is a method named isOnline in class de.onvif.soap.OnvifDevice.
private boolean isOnline() {
// without port
if (!HOST_IP.contains(":")) {
System.out.println("Without Port");
try {
InetAddress.getByName(HOST_IP).isReachable(7500);
}
catch (IOException e) {
return false;
}
}

There needs to be a return statement here only because IOException is not thrown here and the method returns true even if the onvif device is unavailable

A way to rectify would be to add a return keyword before the line like
return InetAddress.getByName(HOST_IP).isReachable(7500);

Now it works fine

Mavenize this project

would it be possible to make this project into maven one? It would greatly improve this lib-s usability

Bad response Exception

I download and run this library but when I type command 'url' or 'profiles' get below exception
`SEVERE: SAAJ0008: Bad Response; Bad Request
Unexpected response. Response should be from class class org.onvif.ver10.media.wsdl.GetProfilesResponse, but response is: null
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (400Bad Request
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
at de.onvif.soap.SOAP.createSOAPRequest(SOAP.java:89)
at de.onvif.soap.SOAP.createSOAPMediaRequest(SOAP.java:49)
at de.onvif.soap.devices.InitialDevices.getProfiles(InitialDevices.java:159)
at de.onvif.Main.main(Main.java:69)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (400Bad Request
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
... 5 more

CAUSE:

com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (400Bad Request
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
at de.onvif.soap.SOAP.createSOAPRequest(SOAP.java:89)
at de.onvif.soap.SOAP.createSOAPMediaRequest(SOAP.java:49)
at de.onvif.soap.devices.InitialDevices.getProfiles(InitialDevices.java:159)
at de.onvif.Main.main(Main.java:69)

CAUSE:

com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (400Bad Request
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
at de.onvif.soap.SOAP.createSOAPRequest(SOAP.java:89)
at de.onvif.soap.SOAP.createSOAPMediaRequest(SOAP.java:49)
at de.onvif.soap.devices.InitialDevices.getProfiles(InitialDevices.java:159)
at de.onvif.Main.main(Main.java:69)
Exception in thread "main" java.lang.NullPointerException
at de.onvif.Main.main(Main.java:70)`

can help me why this exception occures

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.