agborges1986 / onvif-java-lib

Automatically exported from code.google.com/p/onvif-java-lib
0 stars 0 forks source link

Error calling setVideoEncoderConfiguration media.wsdl #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 fjcabe...@visual-tools.com on 3 Oct 2014 at 11:51

GoogleCodeExporter commented 9 years ago
Namespace "ns2" is defined in an element which uses ns2 as its namespace. This 
is the main cause of this error.
It seemed to me that this is a common defect in methods which uses complex type 
as a element in another complex type using the same namespace(e.g. getMediaUri).

Best regards,
Yichi Zhang

Original comment by yic...@gmail.com on 23 Jan 2015 at 9:37

GoogleCodeExporter commented 9 years ago
A possible work-around for this issue is to add the same namespace declaration 
to the SOAP body or envelope manually.
Not good programming practice, but worked for me.

Best Regards,
Yichi Zhang

Original comment by yic...@gmail.com on 23 Jan 2015 at 10:07