onvif discovery server开发:
利用onvif device test Tool (ONVIF Device Test Tool 17.01 rev. 1140)点击搜索可以搜索到设备,但是点击probe 弹出XML文件有错误的提示,提示如下
unexpected error occurred:XML 文档(2,1734)中有错误
从服务器返回的xml文件如下:
看来看去也没有看出什么问题出来,同样这个设备onvif device manager 也不能用,各位看官有什么好的看法
__wsdd__Probe函数实现如下:
SOAP_FMAC5 int SOAP_FMAC6 __wsdd__Probe(struct soap *psoap , struct wsdd__ProbeType *wsdd__Probe){printf("__wsdd__Probe\n");char _IPAddr[STR_SIZE_128];char _HwId[STR_SIZE_256];wsdd__ProbeMatchesType ProbeMatches;ProbeMatches.ProbeMatch = (struct wsdd__ProbeMatchType )soap_malloc(psoap,sizeof(struct wsdd__ProbeMatchType));ProbeMatches.ProbeMatch->XAddrs = (char )soap_malloc(psoap, sizeof(char) * STR_SIZE_128);ProbeMatches.ProbeMatch->Types = (char )soap_malloc(psoap, sizeof(char) * STR_SIZE_128);memset(ProbeMatches.ProbeMatch->Types,0,STR_SIZE_128);ProbeMatches.ProbeMatch->Types = (char )soap_malloc(psoap, sizeof(char) * STR_SIZE_128);ProbeMatches.ProbeMatch->Scopes = (struct wsdd__ScopesType)soap_malloc(psoap,sizeof(struct wsdd__ScopesType));ProbeMatches.ProbeMatch->wsa__EndpointReference.ReferenceProperties = (struct wsa__ReferencePropertiesType)soap_malloc(psoap,sizeof(struct wsa__ReferencePropertiesType));ProbeMatches.ProbeMatch->wsa__EndpointReference.ReferenceParameters = (struct wsa__ReferenceParametersType)soap_malloc(psoap,sizeof(struct wsa__ReferenceParametersType));ProbeMatches.ProbeMatch->wsa__EndpointReference.ServiceName = (struct wsa__ServiceNameType)soap_malloc(psoap,sizeof(struct wsa__ServiceNameType));ProbeMatches.ProbeMatch->wsa__EndpointReference.PortType = (char **)soap_malloc(psoap, sizeof(char *) * STR_SIZE_32);ProbeMatches.ProbeMatch->wsa__EndpointReference.__any = (char *)soap_malloc(psoap, sizeof(char) * STR_SIZE_32);ProbeMatches.ProbeMatch->wsa__EndpointReference.__anyAttribute = (char *)soap_malloc(psoap, sizeof(char) * STR_SIZE_32);ProbeMatches.ProbeMatch->wsa__EndpointReference.Address = (char )soap_malloc(psoap, sizeof(char) * STR_SIZE_128);strcpy(_HwId, endpoint_id);//macaddr[0]=0x01;macaddr[1]=0x01;macaddr[2]=0x01;macaddr[3]=0x01;macaddr[4]=0x01;macaddr[5]=0x01;//sprintf(_HwId,"urn:uuid:2419d68a-2dd2-21b2-a205-%02X%02X%02X%02X%02X%02X",macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]);unsigned int localIp = 0;netGetIp("eth0", &localIp);ProbeMatches.__sizeProbeMatch = 1;ProbeMatches.ProbeMatch->Scopes->__item =(char )soap_malloc(psoap, STR_SIZE_4096);memset(ProbeMatches.ProbeMatch->Scopes->__item,0,sizeof(ProbeMatches.ProbeMatch->Scopes->__item));//Scopes MUST BEstrcat(ProbeMatches.ProbeMatch->Scopes->__item, "onvif://www.onvif.org/type/NetworkVideoTransmitter ");strcat(ProbeMatches.ProbeMatch->Scopes->__item, "onvif://www.onvif.org/location/city/guangzhou ");ProbeMatches.ProbeMatch->Scopes->MatchBy = NULL;sprintf(_IPAddr, "http://%s/onvif/device_service", inet_ntoa(((struct in_addr )&localIp)));strcpy(ProbeMatches.ProbeMatch->XAddrs, _IPAddr);strcpy(ProbeMatches.ProbeMatch->Types, wsdd__Probe->Types);printf("wsdd__Probe->Types=%s _IPAddr=%s\n",wsdd__Probe->Types, _IPAddr);ProbeMatches.ProbeMatch->MetadataVersion = 1;//ws-discovery规定 为可选项ProbeMatches.ProbeMatch->wsa__EndpointReference.ReferenceProperties->__size = 0;ProbeMatches.ProbeMatch->wsa__EndpointReference.ReferenceProperties->__any = NULL;ProbeMatches.ProbeMatch->wsa__EndpointReference.ReferenceParameters->__size = 0;ProbeMatches.ProbeMatch->wsa__EndpointReference.ReferenceParameters->__any = NULL;ProbeMatches.ProbeMatch->wsa__EndpointReference.PortType[0] = (char )soap_malloc(psoap, sizeof(char) * STR_SIZE_32);//ws-discovery规定 为可选项strcpy(ProbeMatches.ProbeMatch->wsa__EndpointReference.PortType[0], "ttl_XXX");ProbeMatches.ProbeMatch->wsa__EndpointReference.ServiceName->__item = NULL;ProbeMatches.ProbeMatch->wsa__EndpointReference.ServiceName->PortName = NULL;ProbeMatches.ProbeMatch->wsa__EndpointReference.ServiceName->__anyAttribute = NULL;ProbeMatches.ProbeMatch->wsa__EndpointReference.__any[0] = (char )soap_malloc(psoap, sizeof(char) * STR_SIZE_32);strcpy(ProbeMatches.ProbeMatch->wsa__EndpointReference.__any[0], "Any");strcpy(ProbeMatches.ProbeMatch->wsa__EndpointReference.__anyAttribute, "Attribute");ProbeMatches.ProbeMatch->wsa__EndpointReference.__size = 0;strcpy(ProbeMatches.ProbeMatch->wsa__EndpointReference.Address, _HwId);/注释的部分为可选,注释掉onvif test也能发现ws-d///psoap->header->wsa__To = "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous";//psoap->header->wsa__Action = "http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches";psoap->header->wsa__RelatesTo = (struct wsa__Relationship)soap_malloc(psoap, sizeof(struct wsa__Relationship));//it's herepsoap->header->wsa__RelatesTo->__item = psoap->header->wsa__MessageID;psoap->header->wsa__RelatesTo->RelationshipType = NULL;psoap->header->wsa__RelatesTo->__anyAttribute = NULL;psoap->header->wsa__MessageID =(char )soap_malloc(psoap, sizeof(char) * STR_SIZE_128);strcpy(psoap->header->wsa__MessageID,_HwId+4); / send over current socket as HTTP OK response: //测试过,第二参数必须http,action随意/ soap_send___wsdd__ProbeMatches(psoap, "http://", NULL, &ProbeMatches);return SOAP_OK;}