我正在尝试在 WCF 中实现一个 UPnP MediaServer。我正在慢慢到达那里,但现在我碰上了一堵砖墙。我需要为 ServiceContract 命名空间添加一个前缀。现在我有以下内容:
[ServiceContract(Namespace = "urn:schemas-upnp-org:service:ContentDirectory:1")]
public interface IContentDirectory
{
[OperationContract(Action = "urn:schemas-upnp-org:service:ContentDirectory:1#Browse")]
void Browse(string ObjectID, string BrowseFlag, string Filter, ulong StartingIndex, ulong RequestedCount, string SortCriteria, out string Result, out ulong NumberReturned, out ulong TotalMatches, out ulong UpdateID);
}
这会听取正确的肥皂信息。但是,我需要肥皂体开始
<u:Browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
WCF 现在正在收听:
<Browse xmlns="urn:schemas-upnp-org:service:ContentDirectory:1">
我如何在那里获得前缀?有关系吗?或者还有其他原因导致参数没有传递到 Browse 方法中?
更新 这里有一些额外的信息:下面的消息是由一个真正的 UPnP 控制点发送的。参数不会传递到 Browse 方法中。
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://XXXXX:8731/ContentDirectory</To>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">urn:schemas-upnp-org:service:ContentDirectory:1#Browse</Action>
</s:Header>
<s:Body>
<u:Browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
<ObjectID>0</ObjectID>
<BrowseFlag>BrowseDirectChildren</BrowseFlag>
<Filter>*</Filter>
<StartingIndex>0</StartingIndex>
<RequestedCount>15</RequestedCount>
<SortCriteria />
</u:Browse>
</s:Body>
</s:Envelope>
这是由 WCF 测试客户端生成的请求。现在参数被传递到 Browse 方法中:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://XXXXXX:8731/ContentDirectory</To>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">urn:schemas-upnp-org:service:ContentDirectory:1#Browse</Action>
</s:Header>
<s:Body>
<Browse xmlns="urn:schemas-upnp-org:service:ContentDirectory:1">
<ObjectID>0</ObjectID>
<BrowseFlag>BrowseMetadata</BrowseFlag>
<Filter>*</Filter>
<StartingIndex>0</StartingIndex>
<RequestedCount>0</RequestedCount>
<SortCriteria i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" />
</Browse>
</s:Body>
</s:Envelope>