服务应该完成动作触发并在30秒内进行响应.如果一个动作的完成时间超过这个,应该提前返回并在完成时发送一个事件.如果服务在这段时间内失败,控制点应该怎么做由具体的应用程序决定. 响应消息的具体格式: 1)使用CONTENT-LENGTH头信息(HTTP/1.0或HTTP/1.1) HTTP/1.0 200 OK CONTENT-TYPE: text/xml; charset="utf-8" DATE: when response was generated SERVER: OS/version UPnP/2.0 product/version CONTENT-LENGTH: bytes in body <?xml version="1.0"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body> <u:actionNameResponse xmlns:u="urn:schemas-upnp-org:service:serviceType:v"> <argumentName>out arg value</argumentName> <!-- other out args and their values go here, if any --> </u:actionNameResponse> </s:Body> </s:Envelope> 2)使用分块编码的响应(仅HTTP/1.1) HTTP/1.1 200 OK TRANSFER-ENCODING: "chunked" CONTENT-TYPE: text/xml; charset="utf-8" DATE: when response was generated SERVER: OS/version UPnP/2.0 product/version Length of first chunk in hexadecimal notation <?xml version="1.0"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body> <u:actionNameResponse xmlns:u="urn:schemas-upnp-org:service:serviceType:v"> <argumentName>out arg value</argumentName> <!-- other out args and their values go here, if any --> </u:actionNameResponse> </s:Body> </s:Envelope> 0
UPnP动作Schema定义了动作请求和动作响应的消息体中的数据类型和结构. 它在UPnP服务模版中定义.
控制点和设备应该忽略掉接收到的所有其不识别的XML内容或者XML指令 XML名字空间前缀可以任意,只要遵循基本的XML名字空间机制. 对于不含值的XML标签,写成封闭形式. 对于值中含有保留的标签符号(e.g. &,<>)的,应该使用别名(& <)代替
处理SOAP消息过程会产生一个正常的输出响应,但也会产生一个SOAP Fault. 动作输出参数应该仅仅被用来发送数据而不能用于传递错误信息. 出错响应应该使用下面的格式被发送: 1)使用CONTENT_LENGTH的响应消息 HTTP/1.0 500 Internal Server Error CONTENT-TYPE: text/xml; charset="utf-8" DATE: when response was generated SERVER: OS/version UPnP/2.0 product/version CONTENT-LENGTH: bytes in body <?xml version="1.0"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body> <s:Fault> <faultcode>s:Client</faultcode> <faultstring>UPnPError</faultstring> <detail> <UPnPError xmlns="urn:schemas-upnp-org:control-1-0"> <errorCode>error code</errorCode> ##出错码 <errorDescription>error string</errorDescription> ##出错描述 </UPnPError> </detail> </s:Fault> </s:Body> </s:Envelope> 2)使用分块编码的错误响应(仅HTTP/1.1) HTTP/1.1 500 Internal Server Error TRANSFER-ENCODING: "chunked" CONTENT-TYPE: text/xml; charset="utf-8" DATE: when response was generated SERVER: OS/version UPnP/2.0 product/version Length of first chunk in hexadecimal notation <?xml version= " 1.0 " ?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body> <s:Fault> <faultcode>s:Client</faultcode> <faultstring>UPnPError</faultstring> <detail> <UPnPError xmlns="urn:schemas-upnp-org:control-1-0"> <errorCode>error code</errorCode> <errorDescription>error string</errorDescription> </UPnPError> </detail> </s:Fault> </s:Body> Length of second chunk in hexadecimal notation </s:Envelope> 0
UPnP出错Schema定义了出错响应消息中使用到的数据结构和类型. 与设备Schema和描述Schema类似,都采用XML语法并遵循XML Schema的规则.
获取状态变量(QueryStateVariable)动作已经被UPnP论坛弃用,不应该将它用于控制点. 当需要使用这个功能时,应该先式地定义一个获取状态变量的动作.
RFC 1123, 时间日期格式: http://www/ietf.org/rfc/rfc1123.txt. RFC 2616, HTTP: Hypertext Transfer Protocol 1.1 : http://www.ietf.org/rfc/rfc2616.txt. RFC 2774, HTTP Extension Framework : http://www.ietf.org/rfc/rfc2774.txt. RFC 3986, Uniform Resource Identifiers (URI): Generic Syntax.Available at: http://www.ietf.org/rfc/rfc3986.txt. SOAP, Simple Object Access Protocol : http://www.w3.org/TR/2000/NOTE-SOAP-20000508. XML, Extensible Markup Language : http://www.w3.org/XML. XML Schema (Part 1: Structures, Part 2: Datatypes) : http://www.w3.org/TR/xmlschema-1, http://www.w3.org/TR/xmlschema-2.