Merge conflicts

This commit is contained in:
yakovlevdmv
2018-04-10 03:01:17 +03:00
4 changed files with 421 additions and 11 deletions

View File

@@ -6,17 +6,17 @@ import (
"github.com/beevik/etree"
"github.com/yakovlevdmv/gosoap"
"strconv"
"net/http"
"io/ioutil"
"github.com/yakovlevdmv/WS-Discovery"
"github.com/yakovlevdmv/goonvif/networking"
"reflect"
"strings"
"github.com/yakovlevdmv/goonvif/Device"
"errors"
"net/http"
"io/ioutil"
"reflect"
"github.com/yakovlevdmv/goonvif/networking"
)
var xlmns = map[string]string {
var Xlmns = map[string]string {
"onvif":"http://www.onvif.org/ver10/schema",
"tds":"http://www.onvif.org/ver10/device/wsdl",
"trt":"http://www.onvif.org/ver10/media/wsdl",
@@ -197,6 +197,10 @@ func (dev *device) Authenticate(username, password string) {
dev.password = password
}
func (dev *device) GetEndpoint(name string) string {
return dev.endpoints[name]
}
func buildMethodSOAP(msg string) (gosoap.SoapMessage, error) {
doc := etree.NewDocument()
if err := doc.ReadFromString(msg); err != nil {
@@ -231,8 +235,6 @@ func (dev device) CallMethod(method interface{}) (*http.Response, error) {
case "PTZ": endpoint = dev.endpoints["PTZ"]
}
////fmt.Println("endpoint", endpoint)
//TODO: Get endpoint automatically
if dev.login != "" && dev.password != "" {
resp, err := dev.callAuthorizedMethod(endpoint, method)
@@ -273,7 +275,7 @@ func (dev device) callNonAuthorizedMethod(endpoint string, method interface{}) (
return nil, err
}
soap.AddRootNamespaces(xlmns)
soap.AddRootNamespaces(Xlmns)
/*
Sending request and returns the response
@@ -303,8 +305,9 @@ func (dev device) callAuthorizedMethod(endpoint string, method interface{}) (*ht
soap.AddWSSecurity(dev.login, dev.password)
/*
Sending request and returns the response
*/
return networking.SendSoap(endpoint, soap.String())
}
}