rvi / ONVIFCameraAndroid

Example on how to connect to an ONVIF camera on Android
MIT License
141 stars 67 forks source link

Getting Bad Request Error on GetStreamURI #5

Closed pankaj-sixwares closed 4 years ago

pankaj-sixwares commented 6 years ago

Hello,

Thanks for sharing an interesting article on Implementing OnVifCamera. We are using the code and facing a problem while accessing getstreamuri. We are able to get device information, media profiles but it is giving bad request error on getstreamuri.

Please help.

Thanks & Regards Pankaj

rvi commented 6 years ago

Hey thanks for your interest Pankaj,

What's the error? have you look at ONVIF documentation ? It's really useful, you might find the solution of your problem.

Also all cameras are differents, make sure it's up to date.

pankaj-sixwares commented 6 years ago

Hi Remy,

Thanks for your reply. I am getting bad request error here. I am able to get services, device information's and profiles. But not able to get streams. I will go through the documentation but i am new to this area and it will take time to understand it fully. I found your article very handy and easy to understand, so it would be great if you can help in this. Below is the response that i got in android console.

/BODY: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" ><soap:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><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"></wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
        </wsse:Nonce><wsu:Created>2018-10-08T09:14:000Z</wsu:Created></wsse:UsernameToken></wsse:Security></soap:Header><soap:Body><GetServices xmlns="http://www.onvif.org/ver10/device/wsdl"><IncludeCapability>false</IncludeCapability></GetServices></soap:Body></soap:Envelope>
D/RESPONSE: Response{protocol=http/1.1, code=200, message=OK, url=http://80.229.39.131:8899/onvif/device_service}
D/RESULT: true
D/ONVIF: service URIs retrieved
D/BODY: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" ><soap:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><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"></wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
        </wsse:Nonce><wsu:Created>2018-10-08T09:14:000Z</wsu:Created></wsse:UsernameToken></wsse:Security></soap:Header><soap:Body><GetDeviceInformation xmlns="http://www.onvif.org/ver10/device/wsdl"></GetDeviceInformation></soap:Body></soap:Envelope>
D/RESPONSE: Response{protocol=http/1.1, code=200, message=OK, url=http://80.229.39.131:8899/onvif/device_service}
D/RESULT: true
D/ONVIF: Device information:
         Manufacturer: H264
         Model: HI3516D_83H40
         FirmwareVersion: V4.02.R12.00014840.10010.132200..ONVIF 2.4
         SerialNumber: 20ca02e32c1fe804
D/BODY: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" ><soap:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><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"></wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
        </wsse:Nonce><wsu:Created>2018-10-08T09:14:000Z</wsu:Created></wsse:UsernameToken></wsse:Security></soap:Header><soap:Body><GetProfiles xmlns="http://www.onvif.org/ver10/media/wsdl"/></soap:Body></soap:Envelope>
D/RESPONSE: Response{protocol=http/1.1, code=200, message=OK, url=http://80.229.39.131:8899/onvif/device_service}
D/RESULT: true
D/ONVIF: 3 profiles retrieved.
D/BODY: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" ><soap:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><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"></wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
       </wsse:Nonce><wsu:Created>2018-10-08T09:14:000Z</wsu:Created></wsse:UsernameToken></wsse:Security></soap:Header><soap:Body><GetStreamUri xmlns="http://www.onvif.org/ver20/media/wsdl"><ProfileToken>000</ProfileToken><Protocol>RTSP</Protocol></GetStreamUri></soap:Body></soap:Envelope>
D/RESPONSE: Response{protocol=http/1.1, code=400, message=Bad Request, url=http://80.229.39.131:8899/onvif/device_service}
D/RESULT: false

Thanks & Regards Pankaj

DharmeshDha commented 5 years ago

same error i also fetching sir,

Pleasea help to us asap

DharmeshDha commented 5 years ago

Pankaj you got success with it ?

rvi commented 5 years ago

@pankaj-sixwares @DharmeshDha have you tried with all the media profiles available?

pankaj-sixwares commented 5 years ago

Hi Remy,

i have tried with all media profiles and i am getting the same error.

Thanks & Regards Pankaj

rahulkrsaurabh commented 5 years ago

Hi Remy,

same error I also fetching sir, and I have tried with all media profiles and I am getting the same error.

please help me

rvi commented 5 years ago

Are you sure your camera are up to date? It's hard for me to help you without access to the camera.

rvi commented 4 years ago

Closing this one, since I don't have any updates.

mnazarizadeh commented 4 years ago

Hi Remy Why you close all issues without any answer or any try to resolve the problem? I faced this problem too. I received "Response: 400 - Bad Request" and I think it is due to the body of the request. I don't have enough knowledge in this area but you might know how to change the request body to get a valid response. could you please try it?

ADK64 commented 3 years ago

Hi, It looks like a problem with request body XML namespace. I tested a request with body generated by the code here's body example:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" >
    <soap:Body>
        <GetStreamUri xmlns="http://www.onvif.org/ver20/media/wsdl">
            <ProfileToken>Profile_0</ProfileToken>
            <Protocol>RTSP</Protocol>
        </GetStreamUri>
    </soap:Body>
</soap:Envelope>

In my case it always return 400 - Bad Request Method 'GetStreamUri' not implemented: method name or namespace not recognized. But when I changed GetStreamUri XML namespace to xmlns="http://www.onvif.org/ver10/media/wsdl" everything looks fine.

hayukleung commented 2 years ago

Hi, It looks like a problem with request body XML namespace. I tested a request with body generated by the code here's body example:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" >
    <soap:Body>
        <GetStreamUri xmlns="http://www.onvif.org/ver20/media/wsdl">
            <ProfileToken>Profile_0</ProfileToken>
            <Protocol>RTSP</Protocol>
        </GetStreamUri>
    </soap:Body>
</soap:Envelope>

In my case it always return 400 - Bad Request Method 'GetStreamUri' not implemented: method name or namespace not recognized. But when I changed GetStreamUri XML namespace to xmlns="http://www.onvif.org/ver10/media/wsdl" everything looks fine.

thanks, i fixed it by doing what you said.

donny681 commented 2 years ago

How to get GetStreamUri form xmlns="http://www.onvif.org/ver20/media/wsdl".The only way to get stream url from "http://www.onvif.org/ver10/media/wsdl"?